-
Notifications
You must be signed in to change notification settings - Fork 900
181 lines (177 loc) · 8.54 KB
/
release-staging.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Staging Release
on:
workflow_dispatch:
inputs:
release-branch:
description: 'Release branch'
type: string
default: 'release'
required: true
source-branch:
description: 'Branch to release from'
type: choice
default: 'main'
required: true
options:
- main
- v8
verbose:
description: 'Enable verbose logging'
type: boolean
default: false
env:
# Bump Node memory limit
NODE_OPTIONS: "--max_old_space_size=4096"
jobs:
deploy:
name: Staging Release
runs-on: ubuntu-latest
# Block this workflow if run on a non-release branch.
if: github.event.inputs.release-branch == 'release' || endsWith(github.event.inputs.release-branch, '-releasebranch')
steps:
- name: Set up node (20)
uses: actions/setup-node@v3
with:
node-version: 22.10.0
- name: Merge main into release
uses: actions/github-script@v6
with:
github-token: ${{ secrets.OSS_BOT_GITHUB_TOKEN }}
script: |
const result = await github.rest.repos.merge({
owner: context.repo.owner,
repo: context.repo.repo,
base: '${{ github.event.inputs.release-branch }}',
head: '${{ github.event.inputs.source-branch }}'
})
console.log(result)
- name: Checkout current branch (with history)
uses: actions/checkout@v4
with:
# Release script requires git history and tags.
fetch-depth: 0
ref: ${{ github.event.inputs.release-branch }}
- name: Yarn install
run: yarn
- name: Publish to NPM
# --skipTests No need to run tests
# --skipReinstall Yarn install has already been run
# --ignoreUnstaged Adding the @firebase/app changeset file means
# there's unstaged changes. Ignore.
# TODO: Make these flags defaults in the release script.
run: yarn release --releaseType Staging --ci --skipTests --skipReinstall --ignoreUnstaged
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN_ANALYTICS: ${{secrets.NPM_TOKEN_ANALYTICS}}
NPM_TOKEN_ANALYTICS_INTEROP_TYPES: ${{secrets.NPM_TOKEN_ANALYTICS_INTEROP_TYPES}}
NPM_TOKEN_ANALYTICS_TYPES: ${{secrets.NPM_TOKEN_ANALYTICS_TYPES}}
NPM_TOKEN_APP: ${{secrets.NPM_TOKEN_APP}}
NPM_TOKEN_APP_TYPES: ${{secrets.NPM_TOKEN_APP_TYPES}}
NPM_TOKEN_APP_CHECK: ${{secrets.NPM_TOKEN_APP_CHECK}}
NPM_TOKEN_APP_CHECK_INTEROP_TYPES: ${{secrets.NPM_TOKEN_APP_CHECK_INTEROP_TYPES}}
NPM_TOKEN_APP_CHECK_TYPES: ${{secrets.NPM_TOKEN_APP_CHECK_TYPES}}
NPM_TOKEN_AUTH: ${{secrets.NPM_TOKEN_AUTH}}
NPM_TOKEN_AUTH_INTEROP_TYPES: ${{secrets.NPM_TOKEN_AUTH_INTEROP_TYPES}}
NPM_TOKEN_AUTH_TYPES: ${{secrets.NPM_TOKEN_AUTH_TYPES}}
NPM_TOKEN_COMPONENT: ${{secrets.NPM_TOKEN_COMPONENT}}
NPM_TOKEN_DATA_CONNECT: ${{secrets.NPM_TOKEN_DATA_CONNECT}}
NPM_TOKEN_DATABASE: ${{secrets.NPM_TOKEN_DATABASE}}
NPM_TOKEN_DATABASE_TYPES: ${{secrets.NPM_TOKEN_DATABASE_TYPES}}
NPM_TOKEN_FIRESTORE: ${{secrets.NPM_TOKEN_FIRESTORE}}
NPM_TOKEN_FIRESTORE_TYPES: ${{secrets.NPM_TOKEN_FIRESTORE_TYPES}}
NPM_TOKEN_FUNCTIONS: ${{secrets.NPM_TOKEN_FUNCTIONS}}
NPM_TOKEN_FUNCTIONS_TYPES: ${{secrets.NPM_TOKEN_FUNCTIONS_TYPES}}
NPM_TOKEN_INSTALLATIONS: ${{secrets.NPM_TOKEN_INSTALLATIONS}}
NPM_TOKEN_INSTALLATIONS_TYPES: ${{secrets.NPM_TOKEN_INSTALLATIONS_TYPES}}
NPM_TOKEN_LOGGER: ${{secrets.NPM_TOKEN_LOGGER}}
NPM_TOKEN_MESSAGING: ${{secrets.NPM_TOKEN_MESSAGING}}
NPM_TOKEN_PERFORMANCE: ${{secrets.NPM_TOKEN_PERFORMANCE}}
NPM_TOKEN_PERFORMANCE_TYPES: ${{secrets.NPM_TOKEN_PERFORMANCE_TYPES}}
NPM_TOKEN_REMOTE_CONFIG: ${{secrets.NPM_TOKEN_REMOTE_CONFIG}}
NPM_TOKEN_REMOTE_CONFIG_TYPES: ${{secrets.NPM_TOKEN_REMOTE_CONFIG_TYPES}}
NPM_TOKEN_RULES_UNIT_TESTING: ${{secrets.NPM_TOKEN_RULES_UNIT_TESTING}}
NPM_TOKEN_STORAGE: ${{secrets.NPM_TOKEN_STORAGE}}
NPM_TOKEN_STORAGE_TYPES: ${{secrets.NPM_TOKEN_STORAGE_TYPES}}
NPM_TOKEN_UTIL: ${{secrets.NPM_TOKEN_UTIL}}
NPM_TOKEN_VERTEXAI: ${{secrets.NPM_TOKEN_VERTEXAI}}
NPM_TOKEN_WEBCHANNEL_WRAPPER: ${{secrets.NPM_TOKEN_WEBCHANNEL_WRAPPER}}
NPM_TOKEN_FIREBASE: ${{secrets.NPM_TOKEN_FIREBASE}}
NPM_TOKEN_APP_COMPAT: ${{ secrets.NPM_TOKEN_APP_COMPAT }}
NPM_TOKEN_INSTALLATIONS_COMPAT: ${{ secrets.NPM_TOKEN_INSTALLATIONS_COMPAT }}
NPM_TOKEN_ANALYTICS_COMPAT: ${{ secrets.NPM_TOKEN_ANALYTICS_COMPAT }}
NPM_TOKEN_AUTH_COMPAT: ${{ secrets.NPM_TOKEN_AUTH_COMPAT }}
NPM_TOKEN_MESSAGING_INTEROP_TYPES: ${{ secrets.NPM_TOKEN_MESSAGING_INTEROP_TYPES }}
NPM_TOKEN_FUNCTIONS_COMPAT: ${{ secrets.NPM_TOKEN_FUNCTIONS_COMPAT }}
NPM_TOKEN_MESSAGING_COMPAT: ${{ secrets.NPM_TOKEN_MESSAGING_COMPAT }}
NPM_TOKEN_PERFORMANCE_COMPAT: ${{ secrets.NPM_TOKEN_PERFORMANCE_COMPAT }}
NPM_TOKEN_REMOTE_CONFIG_COMPAT: ${{ secrets.NPM_TOKEN_REMOTE_CONFIG_COMPAT }}
NPM_TOKEN_DATABASE_COMPAT: ${{ secrets.NPM_TOKEN_DATABASE_COMPAT }}
NPM_TOKEN_FIRESTORE_COMPAT: ${{ secrets.NPM_TOKEN_FIRESTORE_COMPAT }}
NPM_TOKEN_STORAGE_COMPAT: ${{ secrets.NPM_TOKEN_STORAGE_COMPAT }}
NPM_TOKEN_APP_CHECK_COMPAT: ${{ secrets.NPM_TOKEN_APP_CHECK_COMPAT }}
NPM_TOKEN_API_DOCUMENTER: ${{ secrets.NPM_TOKEN_API_DOCUMENTER }}
CI: true
VERBOSE_NPM_LOGGING: ${{github.event.inputs.verbose}}
- 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 "STAGING_VERSION=$VERSION" >> $GITHUB_OUTPUT
BASE_VERSION=$(echo $VERSION | cut -d "-" -f 1)
echo "BASE_VERSION=$BASE_VERSION" >> $GITHUB_OUTPUT
- name: Echo versions in shell
run: |
echo "Staging release ${{ steps.get-version.outputs.STAGING_VERSION }}"
echo "Base version: ${{ steps.get-version.outputs.BASE_VERSION }}"
- name: Launch E2E tests workflow
# Trigger e2e-test.yml
run: |
OSS_BOT_GITHUB_TOKEN=${{ secrets.OSS_BOT_GITHUB_TOKEN }}
VERSION_OR_TAG=${{ steps.get-version.outputs.STAGING_VERSION }}
curl -X POST \
-H "Content-Type:application/json" \
-H "Accept:application/vnd.github.v3+json" \
-H "Authorization:Bearer $OSS_BOT_GITHUB_TOKEN" \
-d "{\"event_type\":\"staging-tests\", \"client_payload\":{\"versionOrTag\":\"$VERSION_OR_TAG\"}}" \
https://api.github.com/repos/firebase/firebase-js-sdk/dispatches
- name: Check for changes requiring a reference doc publish
id: docs-check
# If a diff is found (length of DIFF_CONTENTS > 0) it will write DOCS_NEEDED=true
run: |
LAST_PUBLISHED_VERSION=$(npm info firebase version)
DIFF_CONTENTS=$(git diff firebase@$LAST_PUBLISHED_VERSION HEAD docs-devsite)
if [ -n "$DIFF_CONTENTS" ]
then
echo "DOCS_NEEDED=true" >> $GITHUB_OUTPUT
else
echo "DOCS_NEEDED=false" >> $GITHUB_OUTPUT
fi
- name: Log to release tracker
# Sends release information to cloud functions endpoint of release tracker.
if: ${{ always() }}
run: |
DATE=$(date +'%m/%d/%Y')
BASE_VERSION=${{ steps.get-version.outputs.BASE_VERSION }}
STAGING_VERSION=${{ steps.get-version.outputs.STAGING_VERSION }}
OPERATOR=${{ github.actor }}
RELEASE_TRACKER_URL=${{ secrets.RELEASE_TRACKER_URL }}
DOCS_NEEDED=${{ steps.docs-check.outputs.DOCS_NEEDED }}
curl -X POST -H "Content-Type:application/json" \
-d "{\"version\":\"$BASE_VERSION\",\"tag\":\"$STAGING_VERSION\",\"date\":\"$DATE\",\"operator\":\"$OPERATOR\",\"docs_needed\":\"$DOCS_NEEDED\"}" \
$RELEASE_TRACKER_URL/logStaging