Skip to content

Commit a536b2b

Browse files
wenfixclaude
andauthored
ci: build RN playground APK on every release bump (#278)
* ci: build RN playground APK on every release bump * ci: skip RN playground APK build when tag already exists Guards the release-detection step against re-running on a commit whose playground version was previously released — e.g., a re-release after a revert. Without this, the workflow would rebuild the APK and fail when uploading to an existing GitHub Release asset. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 34b8768 commit a536b2b

2 files changed

Lines changed: 41 additions & 13 deletions

File tree

.github/workflows/build-rn-playground-apk.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,19 @@ jobs:
131131
TAG="${{ inputs.release_tag }}"
132132
APK="${{ steps.apk.outputs.apk_name }}"
133133
134+
# The RN playground is `"private": true` so our release tooling
135+
# doesn't tag it the way it tags other workspaces. Create the tag
136+
# on the release commit ourselves so the GitHub Release below has
137+
# something to attach to.
138+
if ! git rev-parse "refs/tags/$TAG" >/dev/null 2>&1; then
139+
echo "Creating git tag $TAG at ${{ github.sha }}..."
140+
git tag "$TAG" "${{ github.sha }}"
141+
git push origin "refs/tags/$TAG"
142+
fi
143+
134144
# Ensure a GitHub Release exists for this tag (action-publish-release
135-
# may only create one for the root monorepo tag). --notes-file /dev/null
136-
# keeps it tidy; --verify-tag ensures the tag already exists in git.
145+
# may only create one for the root monorepo tag). --verify-tag
146+
# ensures the tag exists in git before we create the Release.
137147
if ! gh release view "$TAG" >/dev/null 2>&1; then
138148
echo "Creating GitHub Release for $TAG..."
139149
gh release create "$TAG" \

.github/workflows/publish-release.yml

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -107,20 +107,38 @@ jobs:
107107
PLAYGROUND_TAG="${PKG_NAME}@${PKG_VERSION}"
108108
echo "PLAYGROUND_TAG=$PLAYGROUND_TAG" >> "$GITHUB_OUTPUT"
109109
110-
# Check that the tag exists AND was created on this commit.
111-
# A tag from a prior release would point to an older commit.
112-
TAG_COMMIT=$(git rev-list -n 1 "refs/tags/$PLAYGROUND_TAG" 2>/dev/null || echo "")
113-
114-
if [ "$TAG_COMMIT" = "${{ github.sha }}" ]; then
115-
echo "RELEASED=true" >> "$GITHUB_OUTPUT"
116-
echo "$PLAYGROUND_TAG points to ${{ github.sha }} — released in this run"
110+
# Detect a release by comparing the playground version against the
111+
# parent commit. The RN playground is `"private": true` (so it is
112+
# never npm-published), and our release tooling only tags
113+
# non-private workspaces. We therefore can't rely on a per-package
114+
# tag existing on the release commit the way we can for other
115+
# workspaces — see build-rn-playground-apk.yml, which creates the
116+
# tag itself when uploading the APK.
117+
if git cat-file -e "${{ github.sha }}^:playground/react-native-playground/package.json" 2>/dev/null; then
118+
git show "${{ github.sha }}^:playground/react-native-playground/package.json" > /tmp/prev-rn-pkg.json
119+
PREV_VERSION=$(node -p "require('/tmp/prev-rn-pkg.json').version")
117120
else
118-
echo "RELEASED=false" >> "$GITHUB_OUTPUT"
119-
if [ -z "$TAG_COMMIT" ]; then
120-
echo "$PLAYGROUND_TAG does not exist — playground was not released"
121+
PREV_VERSION=""
122+
fi
123+
124+
# Also skip if a tag for this version already exists. `git revert` of
125+
# a release commit produces a "Revert ..." message that the
126+
# IS_RELEASE filter (main.yml) rejects, so reverts never reach this
127+
# step directly. But a release that re-uses a previously-tagged
128+
# version (e.g., a re-release after a revert, or a workflow re-run)
129+
# would otherwise rebuild the APK and fail when uploading to an
130+
# existing release asset.
131+
if [ -n "$PREV_VERSION" ] && [ "$PREV_VERSION" != "$PKG_VERSION" ]; then
132+
if git rev-parse "refs/tags/$PLAYGROUND_TAG" >/dev/null 2>&1; then
133+
echo "RELEASED=false" >> "$GITHUB_OUTPUT"
134+
echo "$PLAYGROUND_TAG already exists in git — skipping APK build"
121135
else
122-
echo "$PLAYGROUND_TAG points to $TAG_COMMIT, not ${{ github.sha }} — stale tag from a prior release"
136+
echo "RELEASED=true" >> "$GITHUB_OUTPUT"
137+
echo "$PKG_NAME bumped $PREV_VERSION -> $PKG_VERSION in ${{ github.sha }} — will build APK"
123138
fi
139+
else
140+
echo "RELEASED=false" >> "$GITHUB_OUTPUT"
141+
echo "$PKG_NAME version unchanged at $PKG_VERSION — skipping APK build"
124142
fi
125143
126144
publish-wagmi-to-gh-pages:

0 commit comments

Comments
 (0)