11name : Bump KMP Submodule
22
3- # Reusable workflow: re-points the OneSignal-KMP-SDK git submodule to a released tag
4- # and opens a PR. Called by the KMP repo's Release workflow (the fan-out pattern used
5- # by OneSignal/sdk-shared), or run manually via workflow_dispatch.
6- #
7- # Cross-repo callers authenticate by passing the shared org push token as
8- # GH_PUSH_TOKEN: a workflow triggered from the KMP repo runs with the KMP repo's
9- # GITHUB_TOKEN, which cannot write here, so GH_PUSH_TOKEN (used across the OneSignal
10- # SDK repos) is required for the checkout/push/PR to target this repo.
11-
123on :
134 workflow_call :
145 inputs :
1910 secrets :
2011 GH_PUSH_TOKEN :
2112 required : false
22- description : Cross-repo push token ( contents + pull-requests write)
13+ description : Cross-repository token with contents and pull-request write access
2314 workflow_dispatch :
2415 inputs :
2516 kmp_version :
@@ -33,123 +24,9 @@ permissions:
3324
3425jobs :
3526 bump :
36- runs-on : ubuntu-latest
37- env :
38- SUBMODULE_PATH : OneSignal-KMP-SDK
39- VERSION : ${{ inputs.kmp_version }}
40- steps :
41- - name : " [Checkout] Android SDK"
42- uses : actions/checkout@v7
43- with :
44- # Reusable workflows keep the caller's github context, so the default
45- # checkout target is the caller (OneSignal-KMP-SDK), not this repo.
46- # Always pin the Android SDK when called via workflow_call.
47- repository : OneSignal/OneSignal-Android-SDK
48- ref : main
49- fetch-depth : 0
50- token : ${{ secrets.GH_PUSH_TOKEN || github.token }}
51- # Only the mode-160000 gitlink SHA is rewritten, so the submodule contents
52- # are not needed (no recursive checkout).
53-
54- - name : " [Setup] Git user"
55- uses : OneSignal/sdk-shared/.github/actions/setup-git-user@main
56-
57- - name : " [Resolve] KMP release tag"
58- env :
59- KMP_REMOTE : https://github.com/OneSignal/OneSignal-KMP-SDK.git
60- run : |
61- set -euo pipefail
62-
63- if [[ ! "$VERSION" =~ ^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]]; then
64- echo "::error::Invalid KMP version '$VERSION'. Expected a release tag such as v0.2.0."
65- exit 1
66- fi
67-
68- if ! git ls-remote --exit-code --refs "$KMP_REMOTE" "refs/tags/${VERSION}" >/dev/null; then
69- echo "::error::KMP release tag '$VERSION' does not exist or could not be resolved."
70- exit 1
71- fi
72-
73- tag_repo="$(mktemp -d)"
74- trap 'rm -rf "$tag_repo"' EXIT
75- git -C "$tag_repo" init --bare --quiet
76- if ! git -C "$tag_repo" fetch --quiet --depth=1 "$KMP_REMOTE" "refs/tags/${VERSION}"; then
77- echo "::error::Failed to fetch KMP release tag '$VERSION'."
78- exit 1
79- fi
80-
81- new_sha="$(git -C "$tag_repo" rev-parse 'FETCH_HEAD^{commit}')"
82- if ! git -C "$tag_repo" cat-file -e "${new_sha}^{commit}"; then
83- echo "::error::KMP release tag '$VERSION' does not resolve to a commit."
84- exit 1
85- fi
86-
87- echo "Resolved $VERSION to $new_sha."
88- echo "NEW_SHA=$new_sha" >> "$GITHUB_ENV"
89-
90- - name : " [Bump] Re-point submodule gitlink"
91- id : bump
92- run : |
93- set -euo pipefail
94- branch="chore/bump-kmp-${VERSION}"
95- echo "branch=$branch" >> "$GITHUB_OUTPUT"
96-
97- git checkout -b "$branch"
98- # Update the mode-160000 gitlink entry to the commit the tag points at.
99- git update-index --add --cacheinfo "160000,${NEW_SHA},${SUBMODULE_PATH}"
100-
101- # No-op guard: if the pointer already matches (e.g. the very first release,
102- # where main already points at the tagged commit), skip the commit/PR
103- # instead of failing on an empty commit.
104- if git diff --cached --quiet; then
105- echo "Submodule already at ${NEW_SHA}; nothing to bump."
106- echo "changed=false" >> "$GITHUB_OUTPUT"
107- exit 0
108- fi
109-
110- echo "changed=true" >> "$GITHUB_OUTPUT"
111- git commit -m "chore(logger): bump ${SUBMODULE_PATH} submodule to ${VERSION}"
112- git push origin "$branch" --force-with-lease
113-
114- - name : " [PR] Open or update bump PR"
115- if : ${{ steps.bump.outputs.changed == 'true' }}
116- env :
117- GH_TOKEN : ${{ secrets.GH_PUSH_TOKEN || github.token }}
118- run : |
119- set -euo pipefail
120- branch="${{ steps.bump.outputs.branch }}"
121- notes_url="https://github.com/OneSignal/OneSignal-KMP-SDK/releases/tag/${VERSION}"
122-
123- # Best-effort: pull the published release notes for this tag so the reviewer can
124- # read exactly what the new version contains before merging the bump, without
125- # leaving the PR. Reading another repo's release needs cross-repo access, which
126- # GH_PUSH_TOKEN has; on any failure (missing token, release not yet visible) we
127- # fall back to just linking the release page.
128- notes="$(gh release view "$VERSION" --repo OneSignal/OneSignal-KMP-SDK --json body --jq .body 2>/dev/null || true)"
129-
130- body_file="$RUNNER_TEMP/bump_pr_body.md"
131- {
132- printf 'Automated bump of the `%s` submodule to **%s** (`%s`).\n\n' "$SUBMODULE_PATH" "$VERSION" "$NEW_SHA"
133- printf '## Release notes — %s\n\n' "$VERSION"
134- if [ -n "$notes" ]; then
135- printf '%s\n\n' "$notes"
136- printf '_Source: [%s](%s)_\n\n' "$VERSION" "$notes_url"
137- else
138- printf 'See [%s](%s).\n\n' "$VERSION" "$notes_url"
139- fi
140- printf 'After merge, run `git submodule update --init --recursive` locally to sync.\n'
141- } > "$body_file"
142-
143- # Reuse the PR if one is already open for this branch (re-runs refresh title/body).
144- if gh pr view "$branch" >/dev/null 2>&1; then
145- echo "PR already exists for $branch; refreshing title and release notes."
146- gh pr edit "$branch" \
147- --title "chore(logger): bump shared KMP logger to ${VERSION}" \
148- --body-file "$body_file"
149- else
150- gh pr create \
151- --base main \
152- --head "$branch" \
153- --title "chore(logger): bump shared KMP logger to ${VERSION}" \
154- --body-file "$body_file"
155- fi
27+ uses : OneSignal/sdk-shared/.github/workflows/bump-kmp-submodule.yml@main
28+ with :
29+ target_repository : OneSignal/OneSignal-Android-SDK
30+ kmp_version : ${{ inputs.kmp_version }}
31+ secrets :
32+ GH_PUSH_TOKEN : ${{ secrets.GH_PUSH_TOKEN }}
0 commit comments