Skip to content

Commit 4559c51

Browse files
authored
Update script with skipPrompts option (#6294)
1 parent 36dbcc3 commit 4559c51

File tree

3 files changed

+34
-22
lines changed

3 files changed

+34
-22
lines changed

.github/workflows/release-staging.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,6 @@ jobs:
4545
uses: changesets/action@v1
4646
env:
4747
GITHUB_TOKEN: ${{ secrets.OSS_BOT_GITHUB_TOKEN }}
48-
- name: Get release version
49-
id: get-version
50-
# STAGING_VERSION = version with staging hash, e.g. 1.2.3-20430523
51-
# BASE_VERSION = version without staging hash, e.g. 1.2.3
52-
run: |
53-
VERSION_SCRIPT="const pkg = require('./packages/firebase/package.json'); console.log(pkg.version);"
54-
VERSION=`node -e "${VERSION_SCRIPT}"`
55-
echo "::set-output name=STAGING_VERSION::$VERSION"
56-
BASE_VERSION=$(echo ${{ steps.get-version.outputs.STAGING_VERSION }} | cut -d "-" -f 1)
57-
echo "::set-output name=BASE_VERSION::$BASE_VERSION"
58-
- name: Echo version in shell
59-
run: |
60-
echo "Staging release ${{ steps.get-version.outputs.STAGING_VERSION }}"
6148
- name: Publish to NPM
6249
# --skipTests No need to run tests
6350
# --skipReinstall Yarn install has already been run
@@ -116,6 +103,19 @@ jobs:
116103
NPM_TOKEN_APP_CHECK_COMPAT: ${{ secrets.NPM_TOKEN_APP_CHECK_COMPAT }}
117104
NPM_TOKEN_API_DOCUMENTER: ${{ secrets.NPM_TOKEN_API_DOCUMENTER }}
118105
CI: true
106+
- name: Get release version
107+
id: get-version
108+
# STAGING_VERSION = version with staging hash, e.g. 1.2.3-20430523
109+
# BASE_VERSION = version without staging hash, e.g. 1.2.3
110+
run: |
111+
VERSION_SCRIPT="const pkg = require('./packages/firebase/package.json'); console.log(pkg.version);"
112+
VERSION=`node -e "${VERSION_SCRIPT}"`
113+
echo "::set-output name=STAGING_VERSION::$VERSION"
114+
BASE_VERSION=$(echo ${{ steps.get-version.outputs.STAGING_VERSION }} | cut -d "-" -f 1)
115+
echo "::set-output name=BASE_VERSION::$BASE_VERSION"
116+
- name: Echo version in shell
117+
run: |
118+
echo "Staging release ${{ steps.get-version.outputs.STAGING_VERSION }}"
119119
- name: Launch E2E tests workflow
120120
# Trigger e2e-test.yml
121121
run: |

scripts/release/cli.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,17 @@ yargs
4343
default: false
4444
},
4545
releaseType: {
46-
type: 'string'
46+
type: 'string',
47+
desc: '"Staging" or "Production" - this is case sensitive!'
4748
},
4849
dryRun: {
4950
type: 'boolean',
5051
default: false
52+
},
53+
skipPrompts: {
54+
type: 'boolean',
55+
default: false,
56+
desc: 'Skip all interactive prompts (needed if running in CI)'
5157
}
5258
},
5359
argv => runRelease(argv)

scripts/release/release.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,16 @@ interface releaseOptions {
3535
ignoreUnstaged: boolean;
3636
releaseType?: string;
3737
dryRun?: boolean;
38+
skipPrompts: boolean;
3839
}
3940

4041
export async function runRelease({
4142
skipReinstall,
4243
skipTests,
4344
ignoreUnstaged,
4445
releaseType: inputReleaseType,
45-
dryRun
46+
dryRun,
47+
skipPrompts
4648
}: releaseOptions) {
4749
try {
4850
/**
@@ -88,21 +90,25 @@ export async function runRelease({
8890
return responses.releaseType;
8991
})();
9092

93+
console.log(`Publishing ${inputReleaseType} release.`);
94+
9195
/**
9296
* Bump versions for staging release
9397
* NOTE: For prod, versions are bumped in a PR which should be merged before running this script
9498
*/
9599
if (releaseType === ReleaseType.Staging) {
96100
const updatedPackages = await bumpVersionForStaging();
97101

98-
// We don't need to validate versions for prod releases because prod releases
99-
// are validated in the version bump PR which should be merged before running this script
100-
const { versionCheck } = await prompt([
101-
validateVersions(updatedPackages)
102-
]);
102+
if (!skipPrompts) {
103+
// We don't need to validate versions for prod releases because prod releases
104+
// are validated in the version bump PR which should be merged before running this script
105+
const { versionCheck } = await prompt([
106+
validateVersions(updatedPackages)
107+
]);
103108

104-
if (!versionCheck) {
105-
throw new Error('Version check failed');
109+
if (!versionCheck) {
110+
throw new Error('Version check failed');
111+
}
106112
}
107113
}
108114

0 commit comments

Comments
 (0)