Skip to content
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

[RN][GHA] Migrate the Prepare Release workflow #44833

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/actions/prepare_release/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
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 }}" --skip-react-native-version
- name: Versioning react-native package
shell: bash
run: |
node scripts/releases/set-rn-version.js -v "<< parameters.version >>" --build-type "release"
- 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" tag 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
if: ${{ inputs.dry_run == false }}
run: |
CURR_BRANCH="$(git branch --show-current)"
git push origin "$CURR_BRANCH" --follow-tags
38 changes: 38 additions & 0 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
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 name that will be associated with the published npm packages. A tag of "latest" will also be written as a Git tag.'
required: true
type: string
dry_run:
description: 'Whether the job should be executed in dry-run mode or not'
type: boolean
default: false

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
28 changes: 13 additions & 15 deletions scripts/releases-local/trigger-react-native-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ 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 personal API token. See https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens.',
required: true,
})
.option('v', {
Expand Down Expand Up @@ -183,34 +183,32 @@ 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,
version: version,
tag: npmTag,
// $FlowFixMe[prop-missing]
release_dry_run: argv.dryRun,
dry_run: argv.dryRun,
};

const options = {
method: 'POST',
url: 'https://circleci.com/api/v2/project/github/facebook/react-native/pipeline',
url: 'https://api.github.com/repos/facebook/react-native/actions/workflows/prepare-release/dispatches',
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,
ref: branch,
inputs: parameters,
},
json: true,
};

// See response: https://circleci.com/docs/api/v2/#operation/triggerPipeline
const body = await triggerReleaseWorkflow(options);
// See response: https://docs.github.com/en/rest/actions/workflows?apiVersion=2022-11-28#create-a-workflow-dispatch-event
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',
);

// TODO
Expand Down
Loading