Skip to content

Commit 6931e54

Browse files
committed
Add workflow to backfill assets for a manual/incomplete GitHub release
1 parent 813b944 commit 6931e54

2 files changed

Lines changed: 84 additions & 0 deletions

File tree

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Backfill Release Assets
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: "The version of React Native we want to backfill assets for. For example 0.75.0-rc.0"
8+
required: true
9+
type: string
10+
dry-run:
11+
description: "Whether the job should be executed in dry-run mode or not"
12+
type: boolean
13+
default: true
14+
force:
15+
description: "Whether to reupload assets even if they already exist"
16+
type: boolean
17+
default: false
18+
19+
jobs:
20+
backfill-release-assets:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
27+
fetch-tags: true
28+
- name: Check if on stable branch
29+
id: check_stable_branch
30+
run: |
31+
BRANCH="$(git branch --show-current)"
32+
PATTERN='^0\.[0-9]+-stable$'
33+
if [[ $BRANCH =~ $PATTERN ]]; then
34+
echo "On a stable branch"
35+
echo "ON_STABLE_BRANCH=true" >> $GITHUB_OUTPUT
36+
fi
37+
- name: Install dependencies
38+
uses: ./.github/actions/yarn-install
39+
- name: Configure Git
40+
shell: bash
41+
run: |
42+
git config --local user.email "bot@reactnative.dev"
43+
git config --local user.name "React Native Bot"
44+
- name: Resolve release ID
45+
uses: actions/github-script@v6
46+
env:
47+
VERSION: ${{ inputs.version }}
48+
id: resolve-release-id
49+
with:
50+
github-token: ${{ secrets.REACT_NATIVE_BOT_GITHUB_TOKEN }}
51+
script: |
52+
const tag = 'v' + process.env.VERSION;
53+
const releaseId = await github.rest.repos.getReleaseByTag({
54+
owner: 'facebook',
55+
repo: 'react-native',
56+
tag,
57+
}).then(({data}) => data.id);
58+
console.log(`Resolved release ID: ${releaseId}`);
59+
return releaseId;
60+
result-encoding: string
61+
- name: Upload release assets for DotSlash
62+
if: ${{ steps.check_stable_branch.outputs.ON_STABLE_BRANCH }}
63+
uses: actions/github-script@v6
64+
env:
65+
RELEASE_ID: ${{ steps.resolve-release-id.outputs.result }}
66+
REACT_NATIVE_VERSION: ${{ inputs.version }}
67+
DRY_RUN: ${{ inputs.dry-run }}
68+
FORCE: ${{ inputs.force }}
69+
with:
70+
github-token: ${{ secrets.REACT_NATIVE_BOT_GITHUB_TOKEN }}
71+
script: |
72+
const {uploadReleaseAssetsForDotSlashFiles} = require('./scripts/releases/upload-release-assets-for-dotslash.js');
73+
await uploadReleaseAssetsForDotSlashFiles({
74+
version: process.env.REACT_NATIVE_VERSION,
75+
token: github.token,
76+
releaseId: process.env.RELEASE_ID,
77+
dryRun: process.env.DRY_RUN === 'true',
78+
force: process.env.FORCE === 'true',
79+
});
80+
81+
validate-dotslash-artifacts:
82+
uses: ./.github/workflows/validate-dotslash-artifacts
83+
needs: backfill-release-assets

.github/workflows/validate-dotslash-artifacts.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Validate DotSlash Artifacts
22

33
on:
4+
workflow_call:
45
workflow_dispatch:
56
release:
67
types: [published]

0 commit comments

Comments
 (0)