Skip to content

Commit

Permalink
[RN][GHA] Migrate the Prepare Release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
cipolleschi committed Jun 7, 2024
1 parent f57d624 commit 26fe70f
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 19 deletions.
29 changes: 29 additions & 0 deletions .github/actions/prepare_release/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: prepare_release
description: Prepare React Native release
runs:
using: composite
steps:
- name: Yarn Install
shell: bash
run: yarn install --non-interactive
- name: Versioning workspace packages
shell: bash
run: |
node scripts/releases/set-version "${{ inputs.version }}"
- name: Creating Release commit
shell: bash
run: |
git commit -a -m "Release ${{ inputs.version }}" -m "#publish-packages-to-npm&${{ inputs.tag }}"
git tag -a "v${{ inputs.version }}" -m "v${{ inputs.version }}"
GIT_PAGER=cat git show HEAD
- name: Update latest if needed
shell: bash
if: ${{ inputs.tag == 'latest' }}
run: |
git tag -d "latest"
git push origin :latest
git tag -a "latest" -m "latest"
- name: Pushing release commit
shell: bash
run: |
git push origin $CIRCLE_BRANCH --follow-tags
34 changes: 34 additions & 0 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Prepare Release

on:
workflow_dispatch:
inputs:
version:
description: 'The version of React Native we want to release'
required: true
type: string
tag:
description: 'The tag that should be added to Github'
required: true
type: string

jobs:
prepare_release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- name: Check if on stable branch
id: check_stable_branch
run: |
BRANCH="$(git branch --show-current)"
PATTERN='^0\.[0-9]+-stable$'
if [[ $BRANCH =~ $PATTERN ]]; then
echo "On a stable branch"
echo "ON_STABLE_BRANCH=true" >> $GITHUB_OUTPUT
fi
- name: Print output
run: echo "ON_STABLE_BRANCH ${{steps.check_stable_branch.outputs.ON_STABLE_BRANCH}}"
- name: Execute Prepare Release
if: ${{ steps.check_stable_branch.outputs.ON_STABLE_BRANCH }}
uses: ./.github/actions/prepare_release
30 changes: 11 additions & 19 deletions scripts/releases-local/trigger-react-native-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,14 @@ let argv = yargs
.option('t', {
alias: 'token',
describe:
'Your CircleCI personal API token. See https://circleci.com/docs/2.0/managing-api-tokens/#creating-a-personal-api-token to set one',
'Your Github Action personal API token. See https://circleci.com/docs/2.0/managing-api-tokens/#creating-a-personal-api-token to set one',
required: true,
})
.option('v', {
alias: 'to-version',
describe: 'Version you aim to release, ex. 0.67.0-rc.1, 0.66.3',
required: true,
})
.option('dry-run', {
type: 'boolean',
default: false,
})
.check(() => {
const branch = exitIfNotOnGit(
() => getBranchName(),
Expand Down Expand Up @@ -183,34 +179,30 @@ async function main() {
}

const parameters = {
run_release_workflow: true,
release_version: version,
release_tag: npmTag,
// NOTE: Necessary for 0.74, should be dropped for 0.75+
release_monorepo_packages_version: nextMonorepoPackagesVersion,
// $FlowFixMe[prop-missing]
release_dry_run: argv.dryRun,
version: version,
tag: npmTag,
};

const options = {
method: 'POST',
url: 'https://circleci.com/api/v2/project/github/facebook/react-native/pipeline',
headers: {
'Circle-Token': token,
'content-type': 'application/json',
'Authorization': `Bearer ${token}`,
'Accept': 'application/vnd.github+json',
'X-GitHub-Api-Version': '2022-11-28',
},
body: {
branch,
parameters,
},
json: true,
ref: branch,
inputs: parameters,
}
};

// See response: https://circleci.com/docs/api/v2/#operation/triggerPipeline
const body = await triggerReleaseWorkflow(options);
console.log(
// $FlowFixMe[incompatible-use]
`Monitor your release workflow: https://app.circleci.com/pipelines/github/facebook/react-native/${body.number}`,
`Monitor your release workflow: https://github.com/facebook/react-native/actions/workflows/prepare-release.yml \n`,
JSON.stringify(body, null, 2),
);

// TODO
Expand Down

0 comments on commit 26fe70f

Please sign in to comment.