Skip to content

Commit

Permalink
[RN][GHA] Remove the trigger-react-native-release to use the GHA work…
Browse files Browse the repository at this point in the history
…flow_dispatch UI
  • Loading branch information
cipolleschi committed Jun 12, 2024
1 parent 14ccf6b commit c63a902
Show file tree
Hide file tree
Showing 7 changed files with 158 additions and 239 deletions.
12 changes: 11 additions & 1 deletion .github/actions/prepare_release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ runs:
- name: Yarn install
shell: bash
run: yarn install --non-interactive
- name: Validate version
shell: bash
run: node ./scripts/releases/validate-version.js --build-type release --version "${{ inputs.version }}"
- name: Versioning workspace packages
shell: bash
run: |
Expand All @@ -17,7 +20,14 @@ runs:
- name: Creating release commit
shell: bash
run: |
git commit -a -m "Release ${{ inputs.version }}" -m "#publish-packages-to-npm&${{ inputs.tag }}"
BRANCH="$(git branch --show-current)"
NPM_TAG="$(node ./scripts/releases/compute-npm-tag.js --version ${{ inputs.version }} --branch $BRANCH)"
if [[ "${{ inputs.is-latest-on-npm }}" ]]; then
NPM_TAG="$(node ./scripts/releases/compute-npm-tag.js --is_latest_on_npm --version ${{ inputs.version }} --branch $BRANCH)"
fi
git commit -a -m "Release ${{ inputs.version }}" -m "#publish-packages-to-npm&$NPM_TAG"
git tag -a "v${{ inputs.version }}" -m "v${{ inputs.version }}"
GIT_PAGER=cat git show HEAD
- name: Update "latest" tag if needed
Expand Down
18 changes: 14 additions & 4 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ on:
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.'
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
Expand All @@ -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 }}
if: ${{ steps.check_stable_branch.outputs.ON_STABLE_BRANCH && !steps.check_if_tag_exists.outputs.TAG_EXISTS }}
uses: ./.github/actions/prepare_release
11 changes: 0 additions & 11 deletions scripts/releases-local/README.md

This file was deleted.

223 changes: 0 additions & 223 deletions scripts/releases-local/trigger-react-native-release.js

This file was deleted.

9 changes: 9 additions & 0 deletions scripts/releases/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,12 @@ Updates relevant files in the `react-native` package and template to materialize
### `update-template-package`

Updates workspace dependencies in the template app`package.json`

### `validate-version`

Takes a version and a build type and validates whether the version passed is valid for the given build type
It is intended to use in CI

### `compute-npm-tag`

Takes a version, a branch and whether we want to explicitly tag the release as "latest" and outputs the most appropriate NPM tag for the release.
64 changes: 64 additions & 0 deletions scripts/releases/compute-npm-tag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @format
* @oncall react_native
*/

const {parseVersion} = require('./utils/version-utils');
const {parseArgs} = require('@pkgjs/parseargs');

const config = {
options: {
is_latest_on_npm: {
type: 'boolean',
short: 'l',
default: false,
},
version: {
type: 'string',
short: 'v',
},
branch: {
type: 'string',
short: 'b',
},
help: {type: 'boolean'},
},
};

async function main() {
const {
values: {help, is_latest_on_npm: latest, version: version, branch: branch},
} = parseArgs(config);

if (help) {
console.log(`
Usage: node ./scripts/releases/compute-npm-tag.js [OPTIONS]
Validates a version string for a given build type.
Options:
--is-latest-on-npm Whether we need to publish this as latest on NPM or not. Defaults to false.
--version The new version string.
--branch The branch name.
`);
return;
}

const {prerelease} = parseVersion(version, 'release');

const npmTag = latest ? 'latest' : !prerelease ? branch : 'next';

console.log(npmTag);
return;
}

if (require.main === module) {
// eslint-disable-next-line no-void
void main();
}
Loading

0 comments on commit c63a902

Please sign in to comment.