Skip to content

Commit dbf623f

Browse files
authored
Create staging release workflow (firebase#6279)
1 parent 11d37ed commit dbf623f

File tree

2 files changed

+145
-8
lines changed

2 files changed

+145
-8
lines changed

Diff for: .github/workflows/e2e-test.yml

+4-8
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@ name: E2E Smoke Tests
22

33
# Allows REST trigger. Currently triggered by release-cli script during a staging run.
44
on:
5-
workflow_dispatch:
6-
inputs:
7-
versionOrTag:
8-
description: 'release version or tag'
9-
required: true
10-
default: 'next'
5+
repository_dispatch:
6+
types: [staging-tests]
117

128
jobs:
139
test:
@@ -39,8 +35,8 @@ jobs:
3935
echo "export const config = $PROJECT_CONFIG; export const testAccount = $TEST_ACCOUNT" > firebase-config.js
4036
- name: Yarn install
4137
run: |
42-
echo "Installing firebase@${{ github.event.inputs.versionOrTag }}"
43-
yarn add firebase@${{ github.event.inputs.versionOrTag }}
38+
echo "Installing firebase@${{ github.event.client_payload.versionOrTag }}"
39+
yarn add firebase@${{ github.event.client_payload.versionOrTag }}
4440
yarn
4541
- name: Deploy "callTest" cloud function
4642
run: |

Diff for: .github/workflows/release-staging.yml

+141
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
name: Staging Release
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
workflow_dispatch:
8+
9+
jobs:
10+
deploy:
11+
name: Staging Release
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Set up Node (14)
16+
uses: actions/setup-node@v2
17+
with:
18+
node-version: 14.x
19+
- name: Merge master into release
20+
uses: actions/github-script@v6
21+
with:
22+
github-token: ${{ secrets.GITHUB_TOKEN }}
23+
script: |
24+
github.repos.merge({
25+
owner: context.repo.owner,
26+
repo: context.repo.repo,
27+
base: 'release',
28+
head: 'master'
29+
})
30+
- name: Checkout release branch (with history)
31+
uses: actions/checkout@master
32+
with:
33+
# Release script requires git history and tags.
34+
fetch-depth: 0
35+
ref: release
36+
- name: Yarn install
37+
run: yarn
38+
# Ensures a new @firebase/app is published with every release.
39+
# This keeps the SDK_VERSION variable up to date.
40+
- name: Add a changeset for @firebase/app
41+
# pull master so changeset can diff against it
42+
run: |
43+
git pull -f --no-rebase origin master:master
44+
yarn ts-node-script scripts/ci/add_changeset.ts
45+
- name: Create Release Pull Request
46+
uses: changesets/action@v1
47+
env:
48+
GITHUB_TOKEN: ${{ secrets.OSS_BOT_GITHUB_TOKEN }}
49+
- name: Get release version
50+
id: get-version
51+
# STAGING_VERSION = version with staging hash, e.g. 1.2.3-20430523
52+
# BASE_VERSION = version without staging hash, e.g. 1.2.3
53+
run: |
54+
VERSION_SCRIPT="const pkg = require('./packages/firebase/package.json'); console.log(pkg.version);"
55+
VERSION=`node -e "${VERSION_SCRIPT}"`
56+
echo "::set-output name=STAGING_VERSION::$VERSION"
57+
BASE_VERSION=$(echo ${{ steps.get-version.outputs.STAGING_VERSION }} | cut -d "-" -f 1)
58+
echo "::set-output name=BASE_VERSION::$BASE_VERSION"
59+
- name: Echo version in shell
60+
run: |
61+
echo "Staging release ${{ steps.get-version.outputs.STAGING_VERSION }}"
62+
- name: Publish to NPM
63+
# --skipTests No need to run tests
64+
# --skipReinstall Yarn install has already been run
65+
# --ignoreUnstaged Adding the @firebase/app changeset file means
66+
# there's unstaged changes. Ignore.
67+
# TODO: Make these flags defaults in the release script.
68+
run: yarn release --releaseType staging --skipTests --skipReinstall --ignoreUnstaged
69+
env:
70+
NPM_TOKEN_ANALYTICS: ${{secrets.NPM_TOKEN_ANALYTICS}}
71+
NPM_TOKEN_ANALYTICS_INTEROP_TYPES: ${{secrets.NPM_TOKEN_ANALYTICS_INTEROP_TYPES}}
72+
NPM_TOKEN_ANALYTICS_TYPES: ${{secrets.NPM_TOKEN_ANALYTICS_TYPES}}
73+
NPM_TOKEN_APP: ${{secrets.NPM_TOKEN_APP}}
74+
NPM_TOKEN_APP_TYPES: ${{secrets.NPM_TOKEN_APP_TYPES}}
75+
NPM_TOKEN_APP_CHECK: ${{secrets.NPM_TOKEN_APP_CHECK}}
76+
NPM_TOKEN_APP_CHECK_INTEROP_TYPES: ${{secrets.NPM_TOKEN_APP_CHECK_INTEROP_TYPES}}
77+
NPM_TOKEN_APP_CHECK_TYPES: ${{secrets.NPM_TOKEN_APP_CHECK_TYPES}}
78+
NPM_TOKEN_AUTH: ${{secrets.NPM_TOKEN_AUTH}}
79+
NPM_TOKEN_AUTH_INTEROP_TYPES: ${{secrets.NPM_TOKEN_AUTH_INTEROP_TYPES}}
80+
NPM_TOKEN_AUTH_TYPES: ${{secrets.NPM_TOKEN_AUTH_TYPES}}
81+
NPM_TOKEN_COMPONENT: ${{secrets.NPM_TOKEN_COMPONENT}}
82+
NPM_TOKEN_DATABASE: ${{secrets.NPM_TOKEN_DATABASE}}
83+
NPM_TOKEN_DATABASE_TYPES: ${{secrets.NPM_TOKEN_DATABASE_TYPES}}
84+
NPM_TOKEN_FIRESTORE: ${{secrets.NPM_TOKEN_FIRESTORE}}
85+
NPM_TOKEN_FIRESTORE_TYPES: ${{secrets.NPM_TOKEN_FIRESTORE_TYPES}}
86+
NPM_TOKEN_FUNCTIONS: ${{secrets.NPM_TOKEN_FUNCTIONS}}
87+
NPM_TOKEN_FUNCTIONS_TYPES: ${{secrets.NPM_TOKEN_FUNCTIONS_TYPES}}
88+
NPM_TOKEN_INSTALLATIONS: ${{secrets.NPM_TOKEN_INSTALLATIONS}}
89+
NPM_TOKEN_INSTALLATIONS_TYPES: ${{secrets.NPM_TOKEN_INSTALLATIONS_TYPES}}
90+
NPM_TOKEN_LOGGER: ${{secrets.NPM_TOKEN_LOGGER}}
91+
NPM_TOKEN_MESSAGING: ${{secrets.NPM_TOKEN_MESSAGING}}
92+
NPM_TOKEN_MESSAGING_TYPES: ${{secrets.NPM_TOKEN_MESSAGING_TYPES}}
93+
NPM_TOKEN_PERFORMANCE: ${{secrets.NPM_TOKEN_PERFORMANCE}}
94+
NPM_TOKEN_PERFORMANCE_TYPES: ${{secrets.NPM_TOKEN_PERFORMANCE_TYPES}}
95+
NPM_TOKEN_POLYFILL: ${{secrets.NPM_TOKEN_POLYFILL}}
96+
NPM_TOKEN_REMOTE_CONFIG: ${{secrets.NPM_TOKEN_REMOTE_CONFIG}}
97+
NPM_TOKEN_REMOTE_CONFIG_TYPES: ${{secrets.NPM_TOKEN_REMOTE_CONFIG_TYPES}}
98+
NPM_TOKEN_RULES_UNIT_TESTING: ${{secrets.NPM_TOKEN_RULES_UNIT_TESTING}}
99+
NPM_TOKEN_STORAGE: ${{secrets.NPM_TOKEN_STORAGE}}
100+
NPM_TOKEN_STORAGE_TYPES: ${{secrets.NPM_TOKEN_STORAGE_TYPES}}
101+
NPM_TOKEN_TESTING: ${{secrets.NPM_TOKEN_TESTING}}
102+
NPM_TOKEN_UTIL: ${{secrets.NPM_TOKEN_UTIL}}
103+
NPM_TOKEN_WEBCHANNEL_WRAPPER: ${{secrets.NPM_TOKEN_WEBCHANNEL_WRAPPER}}
104+
NPM_TOKEN_FIREBASE: ${{secrets.NPM_TOKEN_FIREBASE}}
105+
NPM_TOKEN_APP_COMPAT: ${{ secrets.NPM_TOKEN_APP_COMPAT }}
106+
NPM_TOKEN_INSTALLATIONS_COMPAT: ${{ secrets.NPM_TOKEN_INSTALLATIONS_COMPAT }}
107+
NPM_TOKEN_ANALYTICS_COMPAT: ${{ secrets.NPM_TOKEN_ANALYTICS_COMPAT }}
108+
NPM_TOKEN_AUTH_COMPAT: ${{ secrets.NPM_TOKEN_AUTH_COMPAT }}
109+
NPM_TOKEN_MESSAGING_INTEROP_TYPES: ${{ secrets.NPM_TOKEN_MESSAGING_INTEROP_TYPES }}
110+
NPM_TOKEN_FUNCTIONS_COMPAT: ${{ secrets.NPM_TOKEN_FUNCTIONS_COMPAT }}
111+
NPM_TOKEN_MESSAGING_COMPAT: ${{ secrets.NPM_TOKEN_MESSAGING_COMPAT }}
112+
NPM_TOKEN_PERFORMANCE_COMPAT: ${{ secrets.NPM_TOKEN_PERFORMANCE_COMPAT }}
113+
NPM_TOKEN_REMOTE_CONFIG_COMPAT: ${{ secrets.NPM_TOKEN_REMOTE_CONFIG_COMPAT }}
114+
NPM_TOKEN_DATABASE_COMPAT: ${{ secrets.NPM_TOKEN_DATABASE_COMPAT }}
115+
NPM_TOKEN_FIRESTORE_COMPAT: ${{ secrets.NPM_TOKEN_FIRESTORE_COMPAT }}
116+
NPM_TOKEN_STORAGE_COMPAT: ${{ secrets.NPM_TOKEN_STORAGE_COMPAT }}
117+
NPM_TOKEN_APP_CHECK_COMPAT: ${{ secrets.NPM_TOKEN_APP_CHECK_COMPAT }}
118+
NPM_TOKEN_API_DOCUMENTER: ${{ secrets.NPM_TOKEN_API_DOCUMENTER }}
119+
CI: true
120+
- name: Launch E2E tests workflow
121+
# Trigger e2e-test.yml
122+
run: |
123+
OSS_BOT_GITHUB_TOKEN=${{ secrets.OSS_BOT_GITHUB_TOKEN }}
124+
VERSION_OR_TAG=${{ steps.get-version.outputs.STAGING_VERSION }}
125+
curl -X POST \
126+
-H "Content-Type:application/json" \
127+
-H "Accept:application/vnd.github.v3+json" \
128+
-H "Authorization:Bearer $OSS_BOT_GITHUB_TOKEN" \
129+
-d "{\"event_type\":\"staging-tests\", \"client_payload\":{\"versionOrTag\":\"$VERSION_OR_TAG\"}}" \
130+
https://api.github.com/repos/firebase/firebase-js-sdk/dispatches
131+
- name: Log to release tracker
132+
# Sends release information to cloud functions endpoint of release tracker.
133+
run: |
134+
DATE=$(date +'%m/%d/%Y')
135+
BASE_VERSION=${{ steps.get-version.outputs.BASE_VERSION }}
136+
STAGING_VERSION=${{ steps.get-version.outputs.STAGING_VERSION }}
137+
OPERATOR=${{ github.actor }}
138+
RELEASE_TRACKER_URL=${{ secrets.RELEASE_TRACKER_URL }}
139+
curl -X POST -H "Content-Type:application/json" \
140+
-d "{\"version\":\"$BASE_VERSION\",\"tag\":\"$STAGING_VERSION\",\"date\":\"$DATE\",\"operator\":\"$OPERATOR\"}" \
141+
$RELEASE_TRACKER_URL/logStaging

0 commit comments

Comments
 (0)