Skip to content

Commit 9614bbd

Browse files
authored
Create production release workflow (#6304)
1 parent 568fd0d commit 9614bbd

File tree

2 files changed

+114
-0
lines changed

2 files changed

+114
-0
lines changed

.github/workflows/release-prod.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
name: Production Release
2+
3+
on: workflow_dispatch
4+
5+
jobs:
6+
deploy:
7+
name: Production Release
8+
runs-on: ubuntu-latest
9+
# Allow GITHUB_TOKEN to have write permissions
10+
permissions:
11+
contents: write
12+
13+
steps:
14+
- name: Set up Node (14)
15+
uses: actions/setup-node@v2
16+
with:
17+
node-version: 14.x
18+
- name: Checkout release branch (with history)
19+
uses: actions/checkout@master
20+
with:
21+
# Release script requires git history and tags.
22+
fetch-depth: 0
23+
ref: release
24+
- name: Yarn install
25+
run: yarn
26+
- name: Publish to NPM
27+
# --skipTests No need to run tests
28+
# --skipReinstall Yarn install has already been run
29+
# --ignoreUnstaged Adding the @firebase/app changeset file means
30+
# there's unstaged changes. Ignore.
31+
# TODO: Make these flags defaults in the release script.
32+
run: yarn release --releaseType Production --ci --skipTests --skipReinstall --ignoreUnstaged
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
NPM_TOKEN_ANALYTICS: ${{secrets.NPM_TOKEN_ANALYTICS}}
36+
NPM_TOKEN_ANALYTICS_INTEROP_TYPES: ${{secrets.NPM_TOKEN_ANALYTICS_INTEROP_TYPES}}
37+
NPM_TOKEN_ANALYTICS_TYPES: ${{secrets.NPM_TOKEN_ANALYTICS_TYPES}}
38+
NPM_TOKEN_APP: ${{secrets.NPM_TOKEN_APP}}
39+
NPM_TOKEN_APP_TYPES: ${{secrets.NPM_TOKEN_APP_TYPES}}
40+
NPM_TOKEN_APP_CHECK: ${{secrets.NPM_TOKEN_APP_CHECK}}
41+
NPM_TOKEN_APP_CHECK_INTEROP_TYPES: ${{secrets.NPM_TOKEN_APP_CHECK_INTEROP_TYPES}}
42+
NPM_TOKEN_APP_CHECK_TYPES: ${{secrets.NPM_TOKEN_APP_CHECK_TYPES}}
43+
NPM_TOKEN_AUTH: ${{secrets.NPM_TOKEN_AUTH}}
44+
NPM_TOKEN_AUTH_INTEROP_TYPES: ${{secrets.NPM_TOKEN_AUTH_INTEROP_TYPES}}
45+
NPM_TOKEN_AUTH_TYPES: ${{secrets.NPM_TOKEN_AUTH_TYPES}}
46+
NPM_TOKEN_COMPONENT: ${{secrets.NPM_TOKEN_COMPONENT}}
47+
NPM_TOKEN_DATABASE: ${{secrets.NPM_TOKEN_DATABASE}}
48+
NPM_TOKEN_DATABASE_TYPES: ${{secrets.NPM_TOKEN_DATABASE_TYPES}}
49+
NPM_TOKEN_FIRESTORE: ${{secrets.NPM_TOKEN_FIRESTORE}}
50+
NPM_TOKEN_FIRESTORE_TYPES: ${{secrets.NPM_TOKEN_FIRESTORE_TYPES}}
51+
NPM_TOKEN_FUNCTIONS: ${{secrets.NPM_TOKEN_FUNCTIONS}}
52+
NPM_TOKEN_FUNCTIONS_TYPES: ${{secrets.NPM_TOKEN_FUNCTIONS_TYPES}}
53+
NPM_TOKEN_INSTALLATIONS: ${{secrets.NPM_TOKEN_INSTALLATIONS}}
54+
NPM_TOKEN_INSTALLATIONS_TYPES: ${{secrets.NPM_TOKEN_INSTALLATIONS_TYPES}}
55+
NPM_TOKEN_LOGGER: ${{secrets.NPM_TOKEN_LOGGER}}
56+
NPM_TOKEN_MESSAGING: ${{secrets.NPM_TOKEN_MESSAGING}}
57+
NPM_TOKEN_MESSAGING_TYPES: ${{secrets.NPM_TOKEN_MESSAGING_TYPES}}
58+
NPM_TOKEN_PERFORMANCE: ${{secrets.NPM_TOKEN_PERFORMANCE}}
59+
NPM_TOKEN_PERFORMANCE_TYPES: ${{secrets.NPM_TOKEN_PERFORMANCE_TYPES}}
60+
NPM_TOKEN_POLYFILL: ${{secrets.NPM_TOKEN_POLYFILL}}
61+
NPM_TOKEN_REMOTE_CONFIG: ${{secrets.NPM_TOKEN_REMOTE_CONFIG}}
62+
NPM_TOKEN_REMOTE_CONFIG_TYPES: ${{secrets.NPM_TOKEN_REMOTE_CONFIG_TYPES}}
63+
NPM_TOKEN_RULES_UNIT_TESTING: ${{secrets.NPM_TOKEN_RULES_UNIT_TESTING}}
64+
NPM_TOKEN_STORAGE: ${{secrets.NPM_TOKEN_STORAGE}}
65+
NPM_TOKEN_STORAGE_TYPES: ${{secrets.NPM_TOKEN_STORAGE_TYPES}}
66+
NPM_TOKEN_TESTING: ${{secrets.NPM_TOKEN_TESTING}}
67+
NPM_TOKEN_UTIL: ${{secrets.NPM_TOKEN_UTIL}}
68+
NPM_TOKEN_WEBCHANNEL_WRAPPER: ${{secrets.NPM_TOKEN_WEBCHANNEL_WRAPPER}}
69+
NPM_TOKEN_FIREBASE: ${{secrets.NPM_TOKEN_FIREBASE}}
70+
NPM_TOKEN_APP_COMPAT: ${{ secrets.NPM_TOKEN_APP_COMPAT }}
71+
NPM_TOKEN_INSTALLATIONS_COMPAT: ${{ secrets.NPM_TOKEN_INSTALLATIONS_COMPAT }}
72+
NPM_TOKEN_ANALYTICS_COMPAT: ${{ secrets.NPM_TOKEN_ANALYTICS_COMPAT }}
73+
NPM_TOKEN_AUTH_COMPAT: ${{ secrets.NPM_TOKEN_AUTH_COMPAT }}
74+
NPM_TOKEN_MESSAGING_INTEROP_TYPES: ${{ secrets.NPM_TOKEN_MESSAGING_INTEROP_TYPES }}
75+
NPM_TOKEN_FUNCTIONS_COMPAT: ${{ secrets.NPM_TOKEN_FUNCTIONS_COMPAT }}
76+
NPM_TOKEN_MESSAGING_COMPAT: ${{ secrets.NPM_TOKEN_MESSAGING_COMPAT }}
77+
NPM_TOKEN_PERFORMANCE_COMPAT: ${{ secrets.NPM_TOKEN_PERFORMANCE_COMPAT }}
78+
NPM_TOKEN_REMOTE_CONFIG_COMPAT: ${{ secrets.NPM_TOKEN_REMOTE_CONFIG_COMPAT }}
79+
NPM_TOKEN_DATABASE_COMPAT: ${{ secrets.NPM_TOKEN_DATABASE_COMPAT }}
80+
NPM_TOKEN_FIRESTORE_COMPAT: ${{ secrets.NPM_TOKEN_FIRESTORE_COMPAT }}
81+
NPM_TOKEN_STORAGE_COMPAT: ${{ secrets.NPM_TOKEN_STORAGE_COMPAT }}
82+
NPM_TOKEN_APP_CHECK_COMPAT: ${{ secrets.NPM_TOKEN_APP_CHECK_COMPAT }}
83+
NPM_TOKEN_API_DOCUMENTER: ${{ secrets.NPM_TOKEN_API_DOCUMENTER }}
84+
CI: true
85+
- name: Get release version
86+
id: get-version
87+
# In production, there is only one version number
88+
run: |
89+
VERSION_SCRIPT="const pkg = require('./packages/firebase/package.json'); console.log(pkg.version);"
90+
VERSION=`node -e "${VERSION_SCRIPT}"`
91+
echo "::set-output name=BASE_VERSION::$VERSION"
92+
- name: Echo version in shell
93+
run: |
94+
echo "Base version: ${{ steps.get-version.outputs.BASE_VERSION }}"
95+
- name: Log to release tracker
96+
# Sends release information to cloud functions endpoint of release tracker.
97+
run: |
98+
DATE=$(date +'%m/%d/%Y')
99+
BASE_VERSION=${{ steps.get-version.outputs.BASE_VERSION }}
100+
RELEASE_TRACKER_URL=${{ secrets.RELEASE_TRACKER_URL }}
101+
curl -X POST -H "Content-Type:application/json" \
102+
-d "{\"version\":\"$BASE_VERSION\",\"date\":\"$DATE\"}" \
103+
$RELEASE_TRACKER_URL/logProduction

scripts/release/utils/publish.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,17 @@ export async function publishInCI(
6464
};
6565
}
6666

67+
/**
68+
* Skip if this version has already been published.
69+
*/
70+
const { stdout: npmVersion } = await exec('npm info firebase version');
71+
if (version === npmVersion.trim()) {
72+
return {
73+
title: `Skipping publish of ${pkg} - version ${version} is already published`,
74+
task: () => {}
75+
};
76+
}
77+
6778
return {
6879
title: `📦 ${pkg}@${version}`,
6980
task: () => publishPackageInCI(pkg, npmTag, dryRun)

0 commit comments

Comments
 (0)