Remove the trigger-react-native-release to use the GHA workflow_dispatch UI (#44898)

Summary:
This change removes the need for the trigger-react-native-release.js script.
Thanks to the migration to Github Actions, we can now leverage the GHA workflow UI to trigger a Prepare Release job that creates a github tag that will spin a new release.

The pro of this approach are:
- less code to maintain: instead of a complex trigger release scripts, we only have to maintain two very straightforward scripts for the CI
- easier to trigger a release: instead of running a script, we can now just use the GH UI

The `trigger-react-native-release` script was doing the following steps:
- check that we are in the release branch ==> Already implemented in the GHA workflow
- Gets the branch name (not needed) ==> the job will automatically run on the stable branch
- Check for unsent changes (not needed) ==> we are not in a local environment
- get the gh token (not needed) ==> You need to be logged in GH and have write access to the repo
- get the version ==> provided as a parameter
- fails if the tag is already there ==> Functionality added in the workflow
- Parse and validate the version ==> Functionality added to the action prepare-release action + the JS Script
- Compute the npmTag ==> Functionality added to the action prepare-release action + the JS Script
- trigger the release workflow ==> The GH UI does that for us

## Changelog:
[Internal] - Remove the trigger-react-native-release.js

Pull Request resolved: https://github.com/facebook/react-native/pull/44898

Test Plan: Testing in Production!

Reviewed By: cortinico, huntie

Differential Revision: D58461470

Pulled By: cipolleschi

fbshipit-source-id: 32bb0ee91370c9483a29e2ca2e18e24557d5fd53
This commit is contained in:
Riccardo Cipolleschi
2024-06-13 08:19:58 -07:00
committed by Facebook GitHub Bot
parent 726a4a1e5e
commit ece68f0efd
6 changed files with 99 additions and 253 deletions
@@ -1,16 +1,17 @@
name: Prepare Release
name: Create release
on:
workflow_dispatch:
inputs:
version:
description: 'The version of React Native we want to release'
description: 'The version of React Native we want to release. For example 0.75.0-rc.0'
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.'
is_latest_on_npm:
description: 'Whether we want to tag this release as latest on NPM'
required: true
type: string
type: boolean
default: false
dry_run:
description: 'Whether the job should be executed in dry-run mode or not'
type: boolean
@@ -33,6 +34,15 @@ jobs:
fi
- name: Print output
run: echo "ON_STABLE_BRANCH ${{steps.check_stable_branch.outputs.ON_STABLE_BRANCH}}"
- name: Check if tag already exists
id: check_if_tag_exists
run: |
TAG="v${{ inputs.version }}"
TAG_EXISTS=$(git tag -l "$TAG")
if [[ -n "$TAG_EXISTS" ]]; then
echo "Version tag already exists!"
echo "TAG_EXISTS=true" >> $GITHUB_OUTPUT
fi
- name: Execute Prepare Release
if: ${{ steps.check_stable_branch.outputs.ON_STABLE_BRANCH }}
uses: ./.github/actions/prepare_release
if: ${{ steps.check_stable_branch.outputs.ON_STABLE_BRANCH && !steps.check_if_tag_exists.outputs.TAG_EXISTS }}
uses: ./.github/actions/create-release