Skip to content

Update release script with skipPrompts option #6294

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions .github/workflows/release-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,6 @@ jobs:
uses: changesets/action@v1
env:
GITHUB_TOKEN: ${{ secrets.OSS_BOT_GITHUB_TOKEN }}
- name: Get release version
id: get-version
# STAGING_VERSION = version with staging hash, e.g. 1.2.3-20430523
# BASE_VERSION = version without staging hash, e.g. 1.2.3
run: |
VERSION_SCRIPT="const pkg = require('./packages/firebase/package.json'); console.log(pkg.version);"
VERSION=`node -e "${VERSION_SCRIPT}"`
echo "::set-output name=STAGING_VERSION::$VERSION"
BASE_VERSION=$(echo ${{ steps.get-version.outputs.STAGING_VERSION }} | cut -d "-" -f 1)
echo "::set-output name=BASE_VERSION::$BASE_VERSION"
- name: Echo version in shell
run: |
echo "Staging release ${{ steps.get-version.outputs.STAGING_VERSION }}"
- name: Publish to NPM
# --skipTests No need to run tests
# --skipReinstall Yarn install has already been run
Expand Down Expand Up @@ -116,6 +103,19 @@ jobs:
NPM_TOKEN_APP_CHECK_COMPAT: ${{ secrets.NPM_TOKEN_APP_CHECK_COMPAT }}
NPM_TOKEN_API_DOCUMENTER: ${{ secrets.NPM_TOKEN_API_DOCUMENTER }}
CI: true
- name: Get release version
id: get-version
# STAGING_VERSION = version with staging hash, e.g. 1.2.3-20430523
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want to keep these comments in here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep! So we know what those variables are supposed to be.

# BASE_VERSION = version without staging hash, e.g. 1.2.3
run: |
VERSION_SCRIPT="const pkg = require('./packages/firebase/package.json'); console.log(pkg.version);"
VERSION=`node -e "${VERSION_SCRIPT}"`
echo "::set-output name=STAGING_VERSION::$VERSION"
BASE_VERSION=$(echo ${{ steps.get-version.outputs.STAGING_VERSION }} | cut -d "-" -f 1)
echo "::set-output name=BASE_VERSION::$BASE_VERSION"
- name: Echo version in shell
run: |
echo "Staging release ${{ steps.get-version.outputs.STAGING_VERSION }}"
- name: Launch E2E tests workflow
# Trigger e2e-test.yml
run: |
Expand Down
8 changes: 7 additions & 1 deletion scripts/release/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,17 @@ yargs
default: false
},
releaseType: {
type: 'string'
type: 'string',
desc: '"Staging" or "Production" - this is case sensitive!'
},
dryRun: {
type: 'boolean',
default: false
},
skipPrompts: {
type: 'boolean',
default: false,
desc: 'Skip all interactive prompts (needed if running in CI)'
}
},
argv => runRelease(argv)
Expand Down
22 changes: 14 additions & 8 deletions scripts/release/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,16 @@ interface releaseOptions {
ignoreUnstaged: boolean;
releaseType?: string;
dryRun?: boolean;
skipPrompts: boolean;
}

export async function runRelease({
skipReinstall,
skipTests,
ignoreUnstaged,
releaseType: inputReleaseType,
dryRun
dryRun,
skipPrompts
}: releaseOptions) {
try {
/**
Expand Down Expand Up @@ -88,21 +90,25 @@ export async function runRelease({
return responses.releaseType;
})();

console.log(`Publishing ${inputReleaseType} release.`);

/**
* Bump versions for staging release
* NOTE: For prod, versions are bumped in a PR which should be merged before running this script
*/
if (releaseType === ReleaseType.Staging) {
const updatedPackages = await bumpVersionForStaging();

// We don't need to validate versions for prod releases because prod releases
// are validated in the version bump PR which should be merged before running this script
const { versionCheck } = await prompt([
validateVersions(updatedPackages)
]);
if (!skipPrompts) {
// We don't need to validate versions for prod releases because prod releases
// are validated in the version bump PR which should be merged before running this script
const { versionCheck } = await prompt([
validateVersions(updatedPackages)
]);

if (!versionCheck) {
throw new Error('Version check failed');
if (!versionCheck) {
throw new Error('Version check failed');
}
}
}

Expand Down