Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add automated release workflow #36

Closed
wants to merge 1 commit into from

Conversation

blakef
Copy link
Collaborator

@blakef blakef commented Jul 8, 2024

Authenticated clients should be able to trigger a release with a request
like:

curl -X POST https://api.github.com/repos/react-native-community/template/dispatches \
  -H "Accept: application/vnd.github.v3+json" \
  -H "Authorization: Bearer $YOUR_TOKEN" \
  -d '
  "event_type": "publish",
  "sender": "Some useful identifier",
  "client_payload": " {
    "version": "0.75.0-rc.4",
    "is_latest_on_npm": true
  }
'

Authenticated clients should be able to trigger a release with a request
like:

  curl -X POST https://api.github.com/repos/react-native-community/template/dispatches \
    -H "Accept: application/vnd.github.v3+json" \
    -H "Authorization: Bearer $YOUR_TOKEN" \
    -d '
    "event_type": "publish",
    "sender": "Some useful identifier",
    "client_payload": " {
      "version": "0.75.0-rc.4",
      "is_latest_on_npm": true
    }
  '
Copy link
Contributor

@cipolleschi cipolleschi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great and quick job. I left a couple of suggestions on how to improve this, if you like them!

Comment on lines +22 to +31
- 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need to do that. The checkout will happen in the right branch automatically.

git config --global user.email '[email protected]'
git commit -am "Bumping template to $VERSION"
git push
git tag $VERSION
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with or without the leading v?

Suggested change
git tag $VERSION
git tag "$VERSION"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good spot.

Comment on lines +49 to +62
- name: Publish NPM
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Set NPM tags
run: |
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 }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we remove these and make the release.yaml job to be triggered on tags, also?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to this. I think having just the release.yaml workflow do both manual/automatic release is probably the way to go

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, will do this.

@blakef
Copy link
Collaborator Author

blakef commented Jul 11, 2024

This isn't necessary, as we're going to make cutting a MINOR branch on template part of the release process. Then it's just a case of calling the release.yaml workflow.

@blakef blakef closed this Jul 11, 2024
facebook-github-bot pushed a commit to facebook/react-native that referenced this pull request Jul 15, 2024
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
cipolleschi pushed a commit to facebook/react-native that referenced this pull request Jul 22, 2024
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants