diff --git a/.github/actions/prepare_release/action.yml b/.github/actions/prepare_release/action.yml new file mode 100644 index 00000000000000..34a15b15c630a3 --- /dev/null +++ b/.github/actions/prepare_release/action.yml @@ -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 diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml new file mode 100644 index 00000000000000..46d04122da57a6 --- /dev/null +++ b/.github/workflows/prepare-release.yml @@ -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/checkout@v4.1.1 + - 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 diff --git a/scripts/releases-local/trigger-react-native-release.js b/scripts/releases-local/trigger-react-native-release.js index fec627395f4319..bd909c745eca87 100644 --- a/scripts/releases-local/trigger-react-native-release.js +++ b/scripts/releases-local/trigger-react-native-release.js @@ -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 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', { @@ -46,10 +46,6 @@ let argv = yargs 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(), @@ -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', + 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 \n`, ); // TODO