-
Notifications
You must be signed in to change notification settings - Fork 44
chore: new release processes #899
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
Open
joaodordio
wants to merge
4
commits into
master
Choose a base branch
from
chore/new-release-processes
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+184
−0
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
5d0d4b7
chore: add Prepare Release and Publish Release workflows
joaodordio 3d4632f
chore: fix publish-release error message to reference master
joaodordio e0bd3fc
fix: pin checkout to default branch, use notes-file, anchor CHANGELOG…
joaodordio cc7d931
chore: use iterable-sdk-release GitHub App for all release auth
joaodordio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| name: Prepare Release | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| version: | ||
| description: 'Version number (e.g., 3.6.0)' | ||
| required: true | ||
| type: string | ||
| ticket: | ||
| description: 'Jira ticket number (e.g., 1234 for SDK-1234)' | ||
| required: true | ||
| type: string | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| prepare-release: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/create-github-app-token@v1 | ||
| id: app-token | ||
| with: | ||
| app-id: ${{ vars.ITERABLE_SDK_RELEASE_APP_ID }} | ||
| private-key: ${{ secrets.ITERABLE_SDK_RELEASE_APP_PRIVATE_KEY }} | ||
|
|
||
| - uses: actions/checkout@v4 | ||
| with: | ||
| ref: master | ||
| token: ${{ steps.app-token.outputs.token }} | ||
|
|
||
| - name: Validate version format | ||
| run: | | ||
| if ! [[ "${{ github.event.inputs.version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?$ ]]; then | ||
| echo "::error::Invalid version format. Use semantic versioning (e.g., 3.6.0 or 3.6.0-beta1)" | ||
| exit 1 | ||
| fi | ||
|
|
||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '22' | ||
|
|
||
| - name: Update Changelog | ||
| id: update_changelog | ||
| run: | | ||
| version="${{ github.event.inputs.version }}" | ||
| changelog_file="CHANGELOG.md" | ||
|
|
||
| # RN has no [Unreleased] section -- insert a new ## version header at the top | ||
| temp_file=$(mktemp) | ||
| { | ||
| echo "## $version" | ||
| echo "" | ||
| cat "$changelog_file" | ||
| } > "$temp_file" | ||
| mv "$temp_file" "$changelog_file" | ||
|
|
||
| echo "See CHANGELOG.md for release notes." > "$RUNNER_TEMP/release-notes.md" | ||
|
|
||
| - name: Bump package.json version | ||
| run: npm --no-git-tag-version --allow-same-version version "${{ github.event.inputs.version }}" | ||
|
|
||
| - name: Regenerate build info | ||
| run: node scripts/autoCreatePackageInfo.js | ||
|
|
||
| - name: Create Pull Request | ||
| uses: peter-evans/create-pull-request@4e1beaa7521e8b457b572c090b25bd3db56bf1c5 # v5 | ||
| with: | ||
| token: ${{ steps.app-token.outputs.token }} | ||
| title: "SDK-${{ github.event.inputs.ticket }}: Prepare for Release ${{ github.event.inputs.version }}" | ||
| body: | | ||
| # Prepare for Release ${{ github.event.inputs.version }} | ||
|
|
||
| ## SDK Release Checklist | ||
| - [ ] CHANGELOG.md updated with release notes under the new version header | ||
| - [ ] Version bumped in package.json | ||
| - [ ] src/itblBuildInfo.ts regenerated | ||
| - [ ] README.md reviewed (if needed) | ||
| - [ ] All tests passing | ||
| - [ ] Documentation updated (if needed) | ||
| branch: "release/SDK-${{ github.event.inputs.ticket }}-${{ github.event.inputs.version }}" | ||
| commit-message: "[SDK-${{ github.event.inputs.ticket }}]: Prepare for release ${{ github.event.inputs.version }}" | ||
| labels: release | ||
| delete-branch: true | ||
|
|
||
| - name: Create Draft GitHub Release | ||
| env: | ||
| GH_TOKEN: ${{ steps.app-token.outputs.token }} | ||
| run: | | ||
| version="${{ github.event.inputs.version }}" | ||
|
|
||
| if gh release view "$version" &>/dev/null; then | ||
| echo "Draft release $version already exists, skipping." | ||
| else | ||
| gh release create "$version" \ | ||
| --draft \ | ||
| --title "$version" \ | ||
| --notes-file "$RUNNER_TEMP/release-notes.md" | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| name: Publish Release | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| version: | ||
| description: 'Version to publish (e.g., 3.6.0)' | ||
| required: true | ||
| type: string | ||
|
|
||
| env: | ||
| VERSION: ${{ github.event.inputs.version }} | ||
|
|
||
| permissions: | ||
| contents: write | ||
| id-token: write | ||
|
|
||
| jobs: | ||
| publish-release: | ||
| runs-on: ubuntu-latest | ||
| environment: npm | ||
| steps: | ||
| - uses: actions/create-github-app-token@v1 | ||
| id: app-token | ||
| with: | ||
| app-id: ${{ vars.ITERABLE_SDK_RELEASE_APP_ID }} | ||
| private-key: ${{ secrets.ITERABLE_SDK_RELEASE_APP_PRIVATE_KEY }} | ||
|
|
||
| - uses: actions/checkout@v4 | ||
| with: | ||
| ref: master | ||
| token: ${{ steps.app-token.outputs.token }} | ||
|
|
||
| - name: Verify release is ready | ||
| run: | | ||
| if ! grep -qE "^## $VERSION\b" CHANGELOG.md; then | ||
| echo "::error::CHANGELOG.md has no entry for $VERSION. Merge the prepare-release PR to master before running this workflow." | ||
| exit 1 | ||
| fi | ||
|
|
||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '22' | ||
| cache: 'yarn' | ||
| registry-url: 'https://registry.npmjs.org' | ||
|
|
||
| - name: Update npm for OIDC support | ||
| run: npm install -g npm@latest | ||
|
|
||
| - run: yarn install --frozen-lockfile | ||
|
|
||
| - run: yarn test --maxWorkers=2 | ||
|
|
||
| - run: yarn prepare | ||
|
|
||
| - name: Publish to npm | ||
| run: npm publish --provenance | ||
|
|
||
| - name: Publish draft GitHub release and tag main | ||
| env: | ||
| GH_TOKEN: ${{ steps.app-token.outputs.token }} | ||
| run: | | ||
| gh release edit "$VERSION" \ | ||
| --draft=false \ | ||
| --target "$(git rev-parse HEAD)" \ | ||
| --latest | ||
|
|
||
| - name: Slack notification | ||
| run: | | ||
| release_url="https://github.com/${{ github.repository }}/releases/tag/$VERSION" | ||
| payload=$(jq -n \ | ||
| --arg text ":package: *React Native SDK ${VERSION}* has been released. <${release_url}|View release notes>." \ | ||
| '{"text": $text}') | ||
| curl -sS -X POST -H 'Content-type: application/json' --data "$payload" "${{ secrets.SLACK_WEBHOOK }}" | ||
|
|
||
| - name: Slack failure notification | ||
| if: failure() | ||
| run: | | ||
| run_url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}" | ||
| payload=$(jq -n \ | ||
| --arg text ":alert: React Native SDK release ${VERSION} failed (attempt ${{ github.run_attempt }}). Run: ${run_url}" \ | ||
| '{"text": $text}') | ||
| curl -sS -X POST -H 'Content-type: application/json' --data "$payload" "${{ secrets.SLACK_WEBHOOK }}" | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Publish does not constrain git to
master, so it neither verifies merge nor tagsmaster.What the code does
actions/checkout@v4has noref. The “merged” check isgrep -qF "## $VERSION" CHANGELOG.mdon whatever ref the operator picked in “Use workflow from”. The tag is created with--target "$(git rev-parse HEAD)". The step is still named “tag main”.What the spec says
“Verifies the prepare-release PR has been merged (checks CHANGELOG on master)” and “Publishes the draft release and creates the tag on master at this moment.”
Why it conflicts
workflow_dispatchchecks out the selected branch, not the default branch. The unmerged prepare branch already contains## $version, so the grep passes without a merge.grep -qF "## 3.1.0"also matches a historical## 3.1.0or a prefix of## 3.1.0-rc.1. Ifgh release create --draftalready created a tag at prepare time, GitHub’starget_commitishis unused once the tag exists, so publish may not retarget.Suggested action
Make publish (and prepare) operate on
masteronly, and make the merge/version/tag gate actually prove “this version is on master at HEAD” before tagging.