Skip to content

Commit

Permalink
publish template on publishing release (#45327)
Browse files Browse the repository at this point in the history
Summary:
Call the react-native-community/template GHA to trigger a new release when we publish a react-native release. This then waits to confirm that the package is published.

See react-native-community/template#36 for the matching change

Changelog: [General][Added] trigger template publish

Pull Request resolved: #45327

Test Plan: Not sure on the best way forward here.

Reviewed By: cipolleschi

Differential Revision: D59467829

Pulled By: blakef

fbshipit-source-id: 091269e7ecdae5801ac7c03a1ede54452ae99b24
  • Loading branch information
blakef authored and facebook-github-bot committed Jul 15, 2024
1 parent 3c7e307 commit 4e14c5e
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,48 @@ jobs:
with:
name: react-native-package
path: build
- name: Publish @react-native-community/template
if: needs.set_release_type.outputs.RELEASE_TYPE == 'release'
id: publish-to-npm
run: |
COMMIT_MSG=$(git log -n1 --pretty=%B);
if grep -q '#publish-packages-to-npm&latest' <<< "$COMMIT_MSG"; then
echo "TAG=latest" >> $GITHUB_OUTPUT
IS_LATEST=true
else
IS_LATEST=false
fi
# Go from v0.75.0-rc.4 -> 0.75-stable, which is the template's branching scheme
VERSION=$(grep -oE '\d+\.\d+' <<< "${{ github.ref_name }}" | { read version; echo "$version-stable" })
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
curl -L -X POST https://api.github.com/repos/react-native-community/template/release.yaml/dispatches \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer $REACT_NATIVE_BOT_GITHUB_TOKEN" \
-d "{\"ref\":\"$VERSION\",\"inputs\":{\"version\":\"${{ github.ref_name }}\",\"is_latest_on_npm\":\"$IS_LATEST\"}}\n"
- name: Wait for template to be published
if: needs.set_release_type.outputs.RELEASE_TYPE == 'release'
timeout-minutes: 3
env:
VERSION: ${{ steps.publish-to-npm.outputs.VERSION }}
TAG: ${{ steps.publish-to-npm.outputs.TAG }}
run: |
echo "Waiting until @react-native-community/template is published to npm"
while true; do
if curl -o /dev/null -s -f "https://registry.npmjs.org/@react-native-community/template/$VERSION"; then
echo "Confirm that @react-native-community/template@$VERSION is published on npm"
break
fi
sleep 10
done
while [ "$TAG" == "latest" ]; do
CURRENT=$(curl -s "https://registry.npmjs.org/react-native/latest" | jq -r '.version');
if [ "$CURRENT" == "$VERSION" ]; then
echo "Confirm that @react-native-community/template@latest == $VERSION on npm"
break
fi
sleep 10
done
- name: Update rn-diff-purge to generate upgrade-support diff
if: needs.set_release_type.outputs.RELEASE_TYPE == 'release'
run: |
Expand Down

0 comments on commit 4e14c5e

Please sign in to comment.