Skip to content

Commit f124e9a

Browse files
committedJun 13, 2024
Refactor scripts into a single one
1 parent 5860509 commit f124e9a

File tree

7 files changed

+107
-180
lines changed

7 files changed

+107
-180
lines changed
 
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: prepare_release
2+
description: Prepare React Native release
3+
runs:
4+
using: composite
5+
steps:
6+
- name: Yarn install
7+
shell: bash
8+
run: yarn install --non-interactive
9+
- name: Creating release commit
10+
shell: bash
11+
run: |
12+
node scripts/releases/create-release-commit.js \
13+
--reactNativeVersion "${{ inputs.version }}" \
14+
--tagAsLatestRelease "${{ inputs.is_latest_on_npm }}" \
15+
--dryRun "${{ inputs.dry_run }}"
16+
GIT_PAGER=cat git show HEAD
17+
- name: Update "latest" tag if needed
18+
shell: bash
19+
if: ${{ inputs.tag == 'latest' }}
20+
run: |
21+
git tag -d "latest"
22+
git push origin :latest
23+
git tag -a "latest" -m "latest"
24+
- name: Pushing release commit
25+
shell: bash
26+
if: ${{ inputs.dry_run == false }}
27+
run: |
28+
CURR_BRANCH="$(git branch --show-current)"
29+
git push origin "$CURR_BRANCH" --follow-tags

‎.github/actions/prepare_release/action.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.

‎.github/workflows/prepare-release.yml renamed to ‎.github/workflows/create-release.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
name: Prepare Release
1+
name: Create release
22

33
on:
44
workflow_dispatch:
55
inputs:
66
version:
7-
description: 'The version of React Native we want to release'
7+
description: 'The version of React Native we want to release. For example 0.75.0-rc.0'
88
required: true
99
type: string
10-
is-latest-on-npm:
10+
is_latest_on_npm:
1111
description: 'Whether we want to tag this release as latest on NPM'
1212
required: true
1313
type: boolean
@@ -45,4 +45,4 @@ jobs:
4545
fi
4646
- name: Execute Prepare Release
4747
if: ${{ steps.check_stable_branch.outputs.ON_STABLE_BRANCH && !steps.check_if_tag_exists.outputs.TAG_EXISTS }}
48-
uses: ./.github/actions/prepare_release
48+
uses: ./.github/actions/create-release

‎scripts/releases/README.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@ Updates relevant files in the `react-native` package and template to materialize
2222

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

25-
### `validate-version`
25+
### `create-release-commit`
2626

27-
Takes a version and a build type and validates whether the version passed is valid for the given build type
28-
It is intended to use in CI
29-
30-
### `compute-npm-tag`
31-
32-
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.
27+
Creates a release commit to trigger a new release

‎scripts/releases/compute-npm-tag.js

Lines changed: 0 additions & 64 deletions
This file was deleted.
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow
8+
* @format
9+
* @oncall react_native
10+
*/
11+
12+
const setVersion = require('../releases/set-version');
13+
const {getBranchName} = require('../scm-utils');
14+
const {parseVersion} = require('./utils/version-utils');
15+
const {execSync} = require('child_process');
16+
const yargs = require('yargs');
17+
18+
async function main() {
19+
const argv = await yargs
20+
.option('reactNativeVersion', {
21+
describe: 'The new React Native version.',
22+
type: 'string',
23+
required: true,
24+
})
25+
.option('tagAsLatestRelease', {
26+
describe:
27+
'Whether the version should be published as the latest version on npm.',
28+
type: 'boolean',
29+
default: false,
30+
})
31+
.option('dryRun', {
32+
description: 'Whether we should push the commit to github or not',
33+
type: 'boolean',
34+
default: true,
35+
}).argv;
36+
37+
const buildType = 'release';
38+
const version = argv.reactNativeVersion;
39+
const latest = argv.tagAsLatestRelease;
40+
const dryRun = argv.dryRun;
41+
const branch = getBranchName();
42+
console.info(`Running on branch: ${branch}`);
43+
44+
console.info('Validating version', version);
45+
const {prerelease} = parseVersion(version, buildType);
46+
47+
const npmTag = latest ? 'latest' : prerelease ? 'next' : branch;
48+
console.info('NPM tag:', npmTag);
49+
50+
console.info('Setting version for monorepo packages and react-native');
51+
await setVersion(version, false); // version, skip-react-native
52+
53+
if (dryRun) {
54+
console.info('Running in dry-run mode, skipping git commit');
55+
console.info(
56+
`git commit -a -m "Release ${version}" -m "#publish-packages-to-npm&${npmTag}"`,
57+
);
58+
console.info(`git tag -a v${version} -m "v${version}"`);
59+
return;
60+
}
61+
62+
console.info('Committing to git');
63+
execSync(
64+
`git commit -a -m "Release ${version}" -m "#publish-packages-to-npm&${npmTag}"`,
65+
);
66+
execSync(`git tag -a v${version} -m "v${version}"`);
67+
}
68+
69+
if (require.main === module) {
70+
// eslint-disable-next-line no-void
71+
void main();
72+
}

‎scripts/releases/validate-version.js

Lines changed: 0 additions & 60 deletions
This file was deleted.

0 commit comments

Comments
 (0)