Skip to content

Commit 5d0d4b7

Browse files
committed
chore: add Prepare Release and Publish Release workflows
Replaces the existing ad-hoc release workflows with a two-step process: - Prepare Release: bumps version, updates changelog, opens PR, creates GitHub draft release - Publish Release: promotes draft, tags main, publishes to npm, posts Slack Ref: SDK release process team agreement 2026-09-11
1 parent e0b46ae commit 5d0d4b7

2 files changed

Lines changed: 166 additions & 0 deletions

File tree

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Prepare Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version number (e.g., 3.6.0)'
8+
required: true
9+
type: string
10+
ticket:
11+
description: 'Jira ticket number (e.g., 1234 for SDK-1234)'
12+
required: true
13+
type: string
14+
15+
permissions:
16+
contents: write
17+
pull-requests: write
18+
19+
jobs:
20+
prepare-release:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v4
24+
with:
25+
token: ${{ secrets.GITHUB_TOKEN }}
26+
27+
- name: Validate version format
28+
run: |
29+
if ! [[ "${{ github.event.inputs.version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?$ ]]; then
30+
echo "::error::Invalid version format. Use semantic versioning (e.g., 3.6.0 or 3.6.0-beta1)"
31+
exit 1
32+
fi
33+
34+
- uses: actions/setup-node@v4
35+
with:
36+
node-version: '22'
37+
38+
- name: Update Changelog
39+
id: update_changelog
40+
run: |
41+
version="${{ github.event.inputs.version }}"
42+
changelog_file="CHANGELOG.md"
43+
44+
# RN has no [Unreleased] section -- insert a new ## version header at the top
45+
temp_file=$(mktemp)
46+
{
47+
echo "## $version"
48+
echo ""
49+
cat "$changelog_file"
50+
} > "$temp_file"
51+
mv "$temp_file" "$changelog_file"
52+
53+
- name: Bump package.json version
54+
run: npm --no-git-tag-version --allow-same-version version "${{ github.event.inputs.version }}"
55+
56+
- name: Regenerate build info
57+
run: node scripts/autoCreatePackageInfo.js
58+
59+
- name: Create Pull Request
60+
uses: peter-evans/create-pull-request@4e1beaa7521e8b457b572c090b25bd3db56bf1c5 # v5
61+
with:
62+
token: ${{ secrets.GITHUB_TOKEN }}
63+
title: "SDK-${{ github.event.inputs.ticket }}: Prepare for Release ${{ github.event.inputs.version }}"
64+
body: |
65+
# Prepare for Release ${{ github.event.inputs.version }}
66+
67+
## SDK Release Checklist
68+
- [ ] CHANGELOG.md updated with release notes under the new version header
69+
- [ ] Version bumped in package.json
70+
- [ ] src/itblBuildInfo.ts regenerated
71+
- [ ] README.md reviewed (if needed)
72+
- [ ] All tests passing
73+
- [ ] Documentation updated (if needed)
74+
branch: "release/SDK-${{ github.event.inputs.ticket }}-${{ github.event.inputs.version }}"
75+
commit-message: "[SDK-${{ github.event.inputs.ticket }}]: Prepare for release ${{ github.event.inputs.version }}"
76+
labels: release
77+
delete-branch: true
78+
79+
- name: Create Draft GitHub Release
80+
env:
81+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82+
run: |
83+
version="${{ github.event.inputs.version }}"
84+
85+
if gh release view "$version" &>/dev/null; then
86+
echo "Draft release $version already exists, skipping."
87+
else
88+
gh release create "$version" \
89+
--draft \
90+
--title "$version" \
91+
--notes "See CHANGELOG.md for release notes."
92+
fi
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Publish Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version to publish (e.g., 3.6.0)'
8+
required: true
9+
type: string
10+
11+
env:
12+
VERSION: ${{ github.event.inputs.version }}
13+
14+
permissions:
15+
contents: write
16+
id-token: write
17+
18+
jobs:
19+
publish-release:
20+
runs-on: ubuntu-latest
21+
environment: npm
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- name: Verify release is ready
26+
run: |
27+
if ! grep -qF "## $VERSION" CHANGELOG.md; then
28+
echo "::error::CHANGELOG.md has no entry for $VERSION. Merge the prepare-release PR to main before running this workflow."
29+
exit 1
30+
fi
31+
32+
- uses: actions/setup-node@v4
33+
with:
34+
node-version: '22'
35+
cache: 'yarn'
36+
registry-url: 'https://registry.npmjs.org'
37+
38+
- name: Update npm for OIDC support
39+
run: npm install -g npm@latest
40+
41+
- run: yarn install --frozen-lockfile
42+
43+
- run: yarn test --maxWorkers=2
44+
45+
- run: yarn prepare
46+
47+
- name: Publish to npm
48+
run: npm publish --provenance
49+
50+
- name: Publish draft GitHub release and tag main
51+
env:
52+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
run: |
54+
gh release edit "$VERSION" \
55+
--draft=false \
56+
--target "$(git rev-parse HEAD)" \
57+
--latest
58+
59+
- name: Slack notification
60+
run: |
61+
release_url="https://github.com/${{ github.repository }}/releases/tag/$VERSION"
62+
payload=$(jq -n \
63+
--arg text ":package: *React Native SDK ${VERSION}* has been released. <${release_url}|View release notes>." \
64+
'{"text": $text}')
65+
curl -sS -X POST -H 'Content-type: application/json' --data "$payload" "${{ secrets.SLACK_WEBHOOK }}"
66+
67+
- name: Slack failure notification
68+
if: failure()
69+
run: |
70+
run_url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/attempts/${{ github.run_attempt }}"
71+
payload=$(jq -n \
72+
--arg text ":alert: React Native SDK release ${VERSION} failed (attempt ${{ github.run_attempt }}). Run: ${run_url}" \
73+
'{"text": $text}')
74+
curl -sS -X POST -H 'Content-type: application/json' --data "$payload" "${{ secrets.SLACK_WEBHOOK }}"

0 commit comments

Comments
 (0)