Skip to content

Commit 8bb110d

Browse files
committed
Fix post-release workflow execution
1 parent ee90a75 commit 8bb110d

4 files changed

Lines changed: 84 additions & 14 deletions

File tree

.github/workflows/bump-podfile-lock.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ name: Bump Podfile.lock
22

33
on:
44
workflow_call: # this directive allow us to call this workflow from other workflows
5+
inputs:
6+
releaseVersion:
7+
required: false
8+
type: string
9+
checkoutRef:
10+
required: false
11+
type: string
512

613
jobs:
714
bump-podfile-lock:
@@ -11,6 +18,7 @@ jobs:
1118
uses: actions/checkout@v6
1219
with:
1320
token: ${{ secrets.REACT_NATIVE_BOT_GITHUB_TOKEN }}
21+
ref: ${{ inputs.checkoutRef || github.ref }}
1422
fetch-depth: 0
1523
fetch-tags: true
1624
- name: Install dependencies
@@ -23,7 +31,7 @@ jobs:
2331
uses: ./.github/actions/setup-xcode
2432
- name: Extract branch name
2533
run: |
26-
TAG="${{ github.ref_name }}";
34+
TAG="${{ inputs.releaseVersion || github.ref_name }}";
2735
BRANCH_NAME=$(echo "$TAG" | sed -E 's/v([0-9]+\.[0-9]+)\.[0-9]+(-rc\.[0-9]+)?/\1-stable/')
2836
echo "Branch Name is $BRANCH_NAME"
2937
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV

.github/workflows/create-draft-release.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ name: Create Draft Release
33
on:
44
workflow_call:
55
inputs:
6+
releaseVersion:
7+
required: false
8+
type: string
9+
checkoutRef:
10+
required: false
11+
type: string
612
hermesVersion:
713
required: false
814
type: string
@@ -20,6 +26,7 @@ jobs:
2026
uses: actions/checkout@v6
2127
with:
2228
token: ${{ secrets.REACT_NATIVE_BOT_GITHUB_TOKEN }}
29+
ref: ${{ inputs.checkoutRef || github.ref }}
2330
fetch-depth: 0
2431
fetch-tags: true
2532
- name: Install dependencies
@@ -35,7 +42,7 @@ jobs:
3542
with:
3643
script: |
3744
const {createDraftRelease} = require('./.github/workflow-scripts/createDraftRelease.js');
38-
const version = '${{ github.ref_name }}';
45+
const version = '${{ inputs.releaseVersion || github.ref_name }}';
3946
const {isLatest} = require('./.github/workflow-scripts/publishTemplate.js');
4047
return (await createDraftRelease(version, isLatest(), '${{secrets.REACT_NATIVE_BOT_GITHUB_TOKEN}}', '${{ inputs.hermesVersion }}', '${{ inputs.hermesV1Version }}')).id;
4148
result-encoding: string
@@ -46,7 +53,7 @@ jobs:
4653
with:
4754
script: |
4855
const {uploadReleaseAssetsForDotSlashFiles} = require('./scripts/releases/upload-release-assets-for-dotslash.js');
49-
const version = '${{ github.ref_name }}';
56+
const version = '${{ inputs.releaseVersion || github.ref_name }}';
5057
await uploadReleaseAssetsForDotSlashFiles({
5158
version,
5259
token: '${{secrets.REACT_NATIVE_BOT_GITHUB_TOKEN}}',

.github/workflows/generate-changelog.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ name: Generate Changelog
22

33
on:
44
workflow_call:
5+
inputs:
6+
releaseVersion:
7+
required: false
8+
type: string
9+
checkoutRef:
10+
required: false
11+
type: string
512

613
jobs:
714
generate-changelog:
@@ -11,6 +18,7 @@ jobs:
1118
uses: actions/checkout@v6
1219
with:
1320
token: ${{ secrets.REACT_NATIVE_BOT_GITHUB_TOKEN }}
21+
ref: ${{ inputs.checkoutRef || github.ref }}
1422
fetch-depth: 0
1523
fetch-tags: true
1624
- name: Install dependencies
@@ -25,5 +33,5 @@ jobs:
2533
with:
2634
script: |
2735
const {generateChangelog} = require('./.github/workflow-scripts/generateChangelog');
28-
const version = '${{ github.ref_name }}';
36+
const version = '${{ inputs.releaseVersion || github.ref_name }}';
2937
await generateChangelog(version, '${{secrets.REACT_NATIVE_BOT_GITHUB_TOKEN}}');

.github/workflows/publish-npm.yml

Lines changed: 57 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ on:
2323
- 'main'
2424
- '*-stable'
2525
workflow_dispatch:
26+
inputs:
27+
release-tag:
28+
description: Tag whose successful publish needs post-release recovery
29+
required: false
30+
type: string
2631
# nightly build @ 2:15 AM UTC
2732
schedule:
2833
- cron: '15 2 * * *'
@@ -38,12 +43,24 @@ jobs:
3843
outputs:
3944
mode: ${{ steps.mode.outputs.mode }}
4045
release-type: ${{ steps.mode.outputs.release-type }}
46+
release-tag: ${{ steps.mode.outputs.release-tag }}
4147
steps:
4248
- id: mode
49+
env:
50+
RECOVERY_RELEASE_TAG: ${{ inputs.release-tag }}
4351
run: |
4452
if [[ "${{ github.ref_type }}" == "tag" ]]; then
4553
echo "mode=release" >> $GITHUB_OUTPUT
4654
echo "release-type=release" >> $GITHUB_OUTPUT
55+
echo "release-tag=${{ github.ref_name }}" >> $GITHUB_OUTPUT
56+
elif [[ -n "$RECOVERY_RELEASE_TAG" ]]; then
57+
if [[ ! "$RECOVERY_RELEASE_TAG" =~ ^v0\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?$ ]]; then
58+
echo "Invalid release tag: $RECOVERY_RELEASE_TAG" >&2
59+
exit 1
60+
fi
61+
echo "mode=post-release" >> $GITHUB_OUTPUT
62+
echo "release-type=" >> $GITHUB_OUTPUT
63+
echo "release-tag=$RECOVERY_RELEASE_TAG" >> $GITHUB_OUTPUT
4764
elif [[ "${{ github.event_name }}" == "schedule" || "${{ github.event_name }}" == "workflow_dispatch" ]]; then
4865
echo "mode=nightly" >> $GITHUB_OUTPUT
4966
echo "release-type=nightly" >> $GITHUB_OUTPUT
@@ -54,17 +71,21 @@ jobs:
5471
- run: |
5572
echo "Mode: ${{ steps.mode.outputs.mode }}"
5673
echo "Release type: ${{ steps.mode.outputs.release-type }}"
74+
echo "Release tag: ${{ steps.mode.outputs.release-tag }}"
5775
5876
# ─── Release-only: extract Hermes version for draft release ──────
5977
set_hermes_versions:
6078
runs-on: ubuntu-latest
61-
if: github.ref_type == 'tag'
79+
needs: [determine_mode]
80+
if: needs.determine_mode.outputs.mode == 'release' || needs.determine_mode.outputs.mode == 'post-release'
6281
outputs:
6382
HERMES_VERSION: ${{ steps.set_hermes_versions.outputs.HERMES_VERSION }}
6483
HERMES_V1_VERSION: ${{ steps.set_hermes_versions.outputs.HERMES_V1_VERSION }}
6584
steps:
6685
- name: Checkout
6786
uses: actions/checkout@v6
87+
with:
88+
ref: ${{ needs.determine_mode.outputs.release-tag }}
6889
- id: set_hermes_versions
6990
run: |
7091
echo "Setting hermes versions to latest"
@@ -209,13 +230,18 @@ jobs:
209230
post_publish:
210231
runs-on: ubuntu-latest
211232
needs: [determine_mode, publish_react_native]
212-
if: needs.determine_mode.outputs.mode == 'release'
233+
if: |
234+
always() &&
235+
needs.determine_mode.result == 'success' &&
236+
((needs.determine_mode.outputs.mode == 'release' && needs.publish_react_native.result == 'success') ||
237+
needs.determine_mode.outputs.mode == 'post-release')
213238
env:
214239
REACT_NATIVE_BOT_GITHUB_TOKEN: ${{ secrets.REACT_NATIVE_BOT_GITHUB_TOKEN }}
215240
steps:
216241
- name: Checkout
217242
uses: actions/checkout@v6
218243
with:
244+
ref: ${{ needs.determine_mode.outputs.release-tag }}
219245
fetch-depth: 0
220246
fetch-tags: true
221247
- name: Publish @react-native-community/template
@@ -225,7 +251,7 @@ jobs:
225251
github-token: ${{ secrets.REACT_NATIVE_BOT_GITHUB_TOKEN }}
226252
script: |
227253
const {publishTemplate} = require('./.github/workflow-scripts/publishTemplate.js')
228-
const version = "${{ github.ref_name }}"
254+
const version = "${{ needs.determine_mode.outputs.release-tag }}"
229255
const isDryRun = false
230256
await publishTemplate(github, version, isDryRun);
231257
- name: Wait for template to be published
@@ -235,14 +261,14 @@ jobs:
235261
github-token: ${{ secrets.REACT_NATIVE_BOT_GITHUB_TOKEN }}
236262
script: |
237263
const {verifyPublishedTemplate, isLatest} = require('./.github/workflow-scripts/publishTemplate.js')
238-
const version = "${{ github.ref_name }}"
264+
const version = "${{ needs.determine_mode.outputs.release-tag }}"
239265
await verifyPublishedTemplate(version, isLatest());
240266
- name: Update rn-diff-purge to generate upgrade-support diff
241267
run: |
242268
curl -X POST https://api.github.com/repos/react-native-community/rn-diff-purge/dispatches \
243269
-H "Accept: application/vnd.github.v3+json" \
244270
-H "Authorization: Bearer $REACT_NATIVE_BOT_GITHUB_TOKEN" \
245-
-d "{\"event_type\": \"publish\", \"client_payload\": { \"version\": \"${{ github.ref_name }}\" }}"
271+
-d "{\"event_type\": \"publish\", \"client_payload\": { \"version\": \"${{ needs.determine_mode.outputs.release-tag }}\" }}"
246272
- name: Verify Release is on NPM
247273
timeout-minutes: 3
248274
uses: actions/github-script@v8
@@ -251,34 +277,55 @@ jobs:
251277
script: |
252278
const {verifyReleaseOnNpm} = require('./.github/workflow-scripts/verifyReleaseOnNpm.js');
253279
const {isLatest} = require('./.github/workflow-scripts/publishTemplate.js');
254-
const version = "${{ github.ref_name }}";
280+
const version = "${{ needs.determine_mode.outputs.release-tag }}";
255281
await verifyReleaseOnNpm(version, isLatest());
256282
- name: Verify that artifacts are on Maven
257283
uses: actions/github-script@v8
258284
with:
259285
script: |
260286
const {verifyArtifactsAreOnMaven} = require('./.github/workflow-scripts/verifyArtifactsAreOnMaven.js');
261-
const version = "${{ github.ref_name }}";
287+
const version = "${{ needs.determine_mode.outputs.release-tag }}";
262288
await verifyArtifactsAreOnMaven(version);
263289
264290
# ─── Release-only: changelog, podfile bump, draft release ────────
265291
generate_changelog:
266292
needs: [determine_mode, publish_react_native]
267-
if: needs.determine_mode.outputs.mode == 'release'
293+
if: |
294+
always() &&
295+
needs.determine_mode.result == 'success' &&
296+
((needs.determine_mode.outputs.mode == 'release' && needs.publish_react_native.result == 'success') ||
297+
needs.determine_mode.outputs.mode == 'post-release')
268298
uses: ./.github/workflows/generate-changelog.yml
269299
secrets: inherit
300+
with:
301+
releaseVersion: ${{ needs.determine_mode.outputs.release-tag }}
302+
checkoutRef: ${{ needs.determine_mode.outputs.release-tag }}
270303

271304
bump_podfile_lock:
272305
needs: [determine_mode, publish_react_native]
273-
if: needs.determine_mode.outputs.mode == 'release'
306+
if: |
307+
always() &&
308+
needs.determine_mode.result == 'success' &&
309+
((needs.determine_mode.outputs.mode == 'release' && needs.publish_react_native.result == 'success') ||
310+
needs.determine_mode.outputs.mode == 'post-release')
274311
uses: ./.github/workflows/bump-podfile-lock.yml
275312
secrets: inherit
313+
with:
314+
releaseVersion: ${{ needs.determine_mode.outputs.release-tag }}
315+
checkoutRef: ${{ needs.determine_mode.outputs.release-tag }}
276316

277317
create_draft_release:
278318
needs: [determine_mode, generate_changelog, set_hermes_versions]
279-
if: needs.determine_mode.outputs.mode == 'release'
319+
if: |
320+
always() &&
321+
needs.determine_mode.result == 'success' &&
322+
needs.generate_changelog.result == 'success' &&
323+
needs.set_hermes_versions.result == 'success' &&
324+
(needs.determine_mode.outputs.mode == 'release' || needs.determine_mode.outputs.mode == 'post-release')
280325
uses: ./.github/workflows/create-draft-release.yml
281326
secrets: inherit
282327
with:
328+
releaseVersion: ${{ needs.determine_mode.outputs.release-tag }}
329+
checkoutRef: ${{ needs.determine_mode.outputs.release-tag }}
283330
hermesVersion: ${{ needs.set_hermes_versions.outputs.HERMES_VERSION }}
284331
hermesV1Version: ${{ needs.set_hermes_versions.outputs.HERMES_V1_VERSION }}

0 commit comments

Comments
 (0)