Skip to content

feat: add automated release workflow #1

feat: add automated release workflow

feat: add automated release workflow #1

Workflow file for this run

name: Release from React Native

Check failure on line 1 in .github/workflows/automated.yaml

View workflow run for this annotation

GitHub Actions / .github/workflows/automated.yaml

Invalid workflow file

`repository_dispatches` is not a valid event name
on:
repository_dispatches:
types: [release]
# NOTE: Changes here need to be reflected in release.yaml
jobs:
publish_template_automation:
runs-on: ubuntu-latest
env:
VERSION: ${{ github.events.client_payload.version }}
LATEST: ${{ github.events.client_payload.is_latest_on_npm }}
steps:
- name: Safeguard against branch name
run: |
if [[ "$BRANCH" != *-stable ]]; then
echo "Error: This workflow can only be executed from a branch ending with '-stable'."
exit 1
fi
- name: Checkout
uses: actions/[email protected]
- name: Move to MAJOR.MINOR-stable or create if it doesn't exist
run: |
VERSION=$(grep -E '\d+\.\d+' <<< "$VERSION" | awk '{ print "branch="$0"-stable" }')
if ! git ls-remote -q --exit-code --heads origin $VERSION > /dev/null; then
echo "Creating missing release branch \"$VERSION\""
git checkout -B "$VERSION"
git push --set-upstream origin "$VERSION"
else
git checkout "$VERSION"
fi
- name: Setup node.js
uses: actions/[email protected]
with:
node-version: 18
registry-url: 'https://registry.npmjs.org'
- name: Update versions to input one
run: node ./scripts/updateTemplateVersion.js "$VERSION"
- name: Update template/package.json to nightly react-native + @react-native
run: node ./scripts/updateReactNativeVersion.js "$VERSION"
- name: Create corresponding commit & git tag
run: |
git config --global user.name 'React Native Bot'
git config --global user.email '[email protected]'
git commit -am "Bumping template to $VERSION"
git push
git tag $VERSION
git push --tags
- name: Publish NPM
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Set NPM tags
run: |
if [[ "$LATEST" == "true" ]]; then
npm dist-tag add @react-native-community/template@$VERSION latest
fi
if [[ "$VERSION" == *"rc"* ]]; then
npm dist-tag add @react-native-community/template@$VERSION next
fi
if [[ "$GITHUB_REF_NAME" == *"-stable" ]]; then
npm dist-tag add @react-native-community/template@$VERSION $GITHUB_REF_NAME
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}