Skip to content

Commit 71d5216

Browse files
authored
Fix staging workflow (#6296)
* Update release script to use wombat-dressing-room publish if in CI * Update E2E test workflow to use Node 14 to work with latest Firebase CLI * Delete release.yml (obsolete)
1 parent 4559c51 commit 71d5216

File tree

7 files changed

+72
-66
lines changed

7 files changed

+72
-66
lines changed

.github/workflows/e2e-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ jobs:
1717
steps:
1818
- name: Checkout Repo
1919
uses: actions/checkout@master
20-
- name: Set up Node (12)
20+
- name: Set up Node (14)
2121
uses: actions/setup-node@v2
2222
with:
23-
node-version: 12.x
23+
node-version: 14.x
2424
- name: install Chrome stable
2525
run: |
2626
sudo apt-get update

.github/workflows/release-staging.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,19 @@ jobs:
4545
uses: changesets/action@v1
4646
env:
4747
GITHUB_TOKEN: ${{ secrets.OSS_BOT_GITHUB_TOKEN }}
48+
- name: Go back to release branch
49+
# changesets/action created and checked out a new branch
50+
# return to `release` branch.
51+
run: git checkout release
4852
- name: Publish to NPM
4953
# --skipTests No need to run tests
5054
# --skipReinstall Yarn install has already been run
5155
# --ignoreUnstaged Adding the @firebase/app changeset file means
5256
# there's unstaged changes. Ignore.
5357
# TODO: Make these flags defaults in the release script.
54-
run: yarn release --releaseType staging --skipTests --skipReinstall --ignoreUnstaged
58+
run: yarn release --releaseType Staging --ci --skipTests --skipReinstall --ignoreUnstaged
5559
env:
60+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5661
NPM_TOKEN_ANALYTICS: ${{secrets.NPM_TOKEN_ANALYTICS}}
5762
NPM_TOKEN_ANALYTICS_INTEROP_TYPES: ${{secrets.NPM_TOKEN_ANALYTICS_INTEROP_TYPES}}
5863
NPM_TOKEN_ANALYTICS_TYPES: ${{secrets.NPM_TOKEN_ANALYTICS_TYPES}}
@@ -111,11 +116,12 @@ jobs:
111116
VERSION_SCRIPT="const pkg = require('./packages/firebase/package.json'); console.log(pkg.version);"
112117
VERSION=`node -e "${VERSION_SCRIPT}"`
113118
echo "::set-output name=STAGING_VERSION::$VERSION"
114-
BASE_VERSION=$(echo ${{ steps.get-version.outputs.STAGING_VERSION }} | cut -d "-" -f 1)
119+
BASE_VERSION=$(echo $VERSION | cut -d "-" -f 1)
115120
echo "::set-output name=BASE_VERSION::$BASE_VERSION"
116-
- name: Echo version in shell
121+
- name: Echo versions in shell
117122
run: |
118123
echo "Staging release ${{ steps.get-version.outputs.STAGING_VERSION }}"
124+
echo "Base version: ${{ steps.get-version.outputs.BASE_VERSION }}"
119125
- name: Launch E2E tests workflow
120126
# Trigger e2e-test.yml
121127
run: |

.github/workflows/release.yml

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

scripts/release/cli.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ yargs
5050
type: 'boolean',
5151
default: false
5252
},
53-
skipPrompts: {
53+
ci: {
5454
type: 'boolean',
5555
default: false,
56-
desc: 'Skip all interactive prompts (needed if running in CI)'
56+
desc: 'set if running in CI (skips prompts, uses wombot publish)'
5757
}
5858
},
5959
argv => runRelease(argv)

scripts/release/prerelease.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,9 @@ export async function runPrerelease({
9696
await buildPackages();
9797

9898
/**
99-
* Do not acutally publish if it is a dryrun
99+
* Publish to NPM
100100
*/
101-
if (!dryRun) {
102-
await publishInCI(updates, npmTag);
103-
}
101+
await publishInCI(updates, npmTag, dryRun);
104102
}
105103

106104
const FORBIDDEN_TAGS = ['latest', 'next', 'exp'];

scripts/release/release.ts

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import { exec } from 'child-process-promise';
1919
import { createPromptModule } from 'inquirer';
20-
import { publish } from './utils/publish';
20+
import { publish, publishInCI } from './utils/publish';
2121
import { pushReleaseTagsToGithub, cleanTree, hasDiff } from './utils/git';
2222
import {
2323
releaseType as releaseTypePrompt,
@@ -34,8 +34,8 @@ interface releaseOptions {
3434
skipTests: boolean;
3535
ignoreUnstaged: boolean;
3636
releaseType?: string;
37-
dryRun?: boolean;
38-
skipPrompts: boolean;
37+
dryRun: boolean;
38+
ci: boolean;
3939
}
4040

4141
export async function runRelease({
@@ -44,8 +44,9 @@ export async function runRelease({
4444
ignoreUnstaged,
4545
releaseType: inputReleaseType,
4646
dryRun,
47-
skipPrompts
47+
ci
4848
}: releaseOptions) {
49+
console.log('ci', ci);
4950
try {
5051
/**
5152
* If there are unstaged changes, error.
@@ -92,14 +93,16 @@ export async function runRelease({
9293

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

96+
let packagesToPublish = [];
97+
9598
/**
9699
* Bump versions for staging release
97100
* NOTE: For prod, versions are bumped in a PR which should be merged before running this script
98101
*/
99102
if (releaseType === ReleaseType.Staging) {
100103
const updatedPackages = await bumpVersionForStaging();
101104

102-
if (!skipPrompts) {
105+
if (!ci) {
103106
// We don't need to validate versions for prod releases because prod releases
104107
// are validated in the version bump PR which should be merged before running this script
105108
const { versionCheck } = await prompt([
@@ -110,6 +113,10 @@ export async function runRelease({
110113
throw new Error('Version check failed');
111114
}
112115
}
116+
117+
for (const key of updatedPackages.keys()) {
118+
packagesToPublish.push(key);
119+
}
113120
}
114121

115122
/**
@@ -138,26 +145,43 @@ export async function runRelease({
138145
}
139146

140147
/**
141-
* Do not actually publish if it is a dryrun
148+
* Publish new versions to NPM using changeset (if manual)
149+
* or using wombot for each package (if CI)
150+
* It will also create tags
142151
*/
143-
if (!dryRun) {
152+
if (ci) {
144153
/**
145-
* Release new versions to NPM using changeset
146-
* It will also create tags
154+
* If the script is calling each individual npm command
155+
* it can add the npm flag --dry-run, to better simulate
156+
* everything in the publish process except publishing.
147157
*/
148-
await publish(releaseType);
149-
158+
if (releaseType === ReleaseType.Staging) {
159+
await publishInCI(packagesToPublish, 'next', dryRun);
160+
} else {
161+
// Production.
162+
await publishInCI(packagesToPublish, 'latest', dryRun);
163+
}
164+
} else {
150165
/**
151-
* Changeset creats tags for staging releases as well,
152-
* but we should only push tags to Github for prod releases
166+
* If the script uses changeset to publish, there's no
167+
* way to add the dry-run flag to each npm CLI command.
153168
*/
154-
if (releaseType === ReleaseType.Production) {
155-
/**
156-
* Push release tags created by changeset in publish() to Github
157-
*/
158-
await pushReleaseTagsToGithub();
169+
if (!dryRun) {
170+
// Uses changeset
171+
await publish(releaseType);
159172
}
160173
}
174+
175+
/**
176+
* Changeset creates tags for staging releases as well,
177+
* but we should only push tags to Github for prod releases
178+
*/
179+
if (releaseType === ReleaseType.Production && !dryRun) {
180+
/**
181+
* Push release tags created by changeset in publish() to Github
182+
*/
183+
await pushReleaseTagsToGithub();
184+
}
161185
} catch (err) {
162186
/**
163187
* Log any errors that happened during the process

scripts/release/utils/publish.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ export async function publish(releaseType: string) {
3737
});
3838
}
3939

40-
export async function publishInCI(updatedPkgs: string[], npmTag: string) {
40+
export async function publishInCI(
41+
updatedPkgs: string[],
42+
npmTag: string,
43+
dryRun: boolean
44+
) {
4145
const taskArray = await Promise.all(
4246
updatedPkgs.map(async pkg => {
4347
const path = await mapPkgNameToPkgPath(pkg);
@@ -62,7 +66,7 @@ export async function publishInCI(updatedPkgs: string[], npmTag: string) {
6266

6367
return {
6468
title: `📦 ${pkg}@${version}`,
65-
task: () => publishPackageInCI(pkg, npmTag)
69+
task: () => publishPackageInCI(pkg, npmTag, dryRun)
6670
};
6771
})
6872
);
@@ -75,7 +79,11 @@ export async function publishInCI(updatedPkgs: string[], npmTag: string) {
7579
return tasks.run();
7680
}
7781

78-
async function publishPackageInCI(pkg: string, npmTag: string) {
82+
async function publishPackageInCI(
83+
pkg: string,
84+
npmTag: string,
85+
dryRun: boolean
86+
) {
7987
try {
8088
const path = await mapPkgNameToPkgPath(pkg);
8189

@@ -92,6 +100,10 @@ async function publishPackageInCI(pkg: string, npmTag: string) {
92100
'https://wombat-dressing-room.appspot.com'
93101
];
94102

103+
if (dryRun) {
104+
args.push('--dry-run');
105+
}
106+
95107
// Write proxy registry token for this package to .npmrc.
96108
await exec(
97109
`echo "//wombat-dressing-room.appspot.com/:_authToken=${

0 commit comments

Comments
 (0)