Skip to content

Commit 1190d18

Browse files
committed
Fleshed out the full workflow
1 parent 82b3b2a commit 1190d18

File tree

5 files changed

+104
-13
lines changed

5 files changed

+104
-13
lines changed
1.69 KB
Binary file not shown.

.github/scripts/publish_package.sh

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
# Copyright 2020 Google Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -e
18+
set -u
19+
20+
echo "//wombat-dressing-room.appspot.com/:_authToken=${NPM_AUTH_TOKEN}" >> ~/.npmrc
21+
22+
readonly UNPREFIXED_VERSION=`echo ${VERSION} | cut -c 2-`
23+
npm publish dist/firebase-admin-${UNPREFIXED_VERSION}.tgz --registry https://wombat-dressing-room.appspot.com

.github/scripts/publish_preflight_check.sh

+21
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
#!/bin/bash
22

3+
# Copyright 2020 Google Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
317
###################################### Outputs #####################################
418

519
# 1. version: The version of this release including the 'v' prefix (e.g. v1.2.3).
@@ -78,6 +92,13 @@ else
7892
terminate
7993
fi
8094

95+
readonly ARTIFACT_COUNT=`ls dist/ | wc -l`
96+
if [[ $ARTIFACT_COUNT -ne 1 ]]; then
97+
echo_warn "Unexpected artifacts in the distribution directory."
98+
ls -l dist
99+
terminate
100+
fi
101+
81102

82103
echo_info ""
83104
echo_info "--------------------------------------------"
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
# Copyright 2020 Google Inc.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -e
18+
set -u
19+
20+
gpg --quiet --batch --yes --decrypt --passphrase="${FIREBASE_SERVICE_ACCT_KEY}" \
21+
--output test/resources/key.json .github/resources/integ-service-account.json.gpg
22+
23+
echo "${FIREBASE_API_KEY}" > test/resources/apikey.txt
24+
25+
npm run test:integration -- --updateRules --testMultiTenancy

.github/workflows/release.yml

+35-13
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,13 @@ on:
2626

2727
jobs:
2828
stage_release:
29-
# If triggered by a PR it must contain the label 'release:build'.
29+
# To publish a release, merge the release PR with the label 'release:publish'.
30+
# To stage a release without publishing it, send a 'firebase_build' event or apply
31+
# the 'release:stage' label to a PR.
3032
if: github.event.action == 'firebase_build' ||
31-
contains(github.event.pull_request.labels.*.name, 'release:build')
33+
contains(github.event.pull_request.labels.*.name, 'release:stage') ||
34+
(github.event.pull_request.merged &&
35+
contains(github.event.pull_request.labels.*.name, 'release:publish'))
3236

3337
runs-on: ubuntu-latest
3438

@@ -50,10 +54,14 @@ jobs:
5054
npm ci
5155
npm run build
5256
53-
- name: Run tests
54-
run: |
55-
npm test
56-
echo "Running integration tests"
57+
- name: Run unit tests
58+
run: npm test
59+
60+
- name: Run integration tests
61+
run: ./.github/scripts/run_integration_tests.sh
62+
env:
63+
FIREBASE_SERVICE_ACCT_KEY: ${{ secrets.FIREBASE_SERVICE_ACCT_KEY }}
64+
FIREBASE_API_KEY: ${{ secrets.FIREBASE_API_KEY }}
5765

5866
- name: Package release artifacts
5967
run: |
@@ -69,9 +77,10 @@ jobs:
6977
name: dist
7078
path: dist
7179

80+
# TODO: Move this script to .github/scripts.
7281
- name: Verify tarball
7382
run: |
74-
PACKAGE_TARBALL=`ls *.tgz`
83+
PACKAGE_TARBALL=`ls firebase-admin-*.tgz`
7584
./verifyReleaseTarball.sh $PACKAGE_TARBALL
7685
7786
publish_release:
@@ -80,10 +89,12 @@ jobs:
8089
# Check whether the release should be published. We publish only when the trigger PR is
8190
# 1. merged
8291
# 2. to the master branch
83-
# 3. with the title prefix '[chore] Release '.
84-
if: success() && github.event.pull_request.merged &&
85-
github.ref == 'master' &&
86-
startsWith(github.event.pull_request.title, '[chore] Release ')
92+
# 3. with the label 'release:publish', and
93+
# 4. the title prefix '[chore] Release '.
94+
if: github.event.pull_request.merged &&
95+
github.ref == 'master' &&
96+
contains(github.event.pull_request.labels.*.name, 'release:publish') &&
97+
startsWith(github.event.pull_request.title, '[chore] Release ')
8798

8899
runs-on: ubuntu-latest
89100

@@ -122,11 +133,22 @@ jobs:
122133
prerelease: false
123134

124135
- name: Publish to NPM
125-
run: echo Publishing to NPM
136+
run: ./.github/scripts/publish_package.sh
137+
env:
138+
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
139+
VERSION: ${{ steps.preflight.outputs.version }}
126140

127141
# Post to Twitter if explicitly opted-in by adding the label 'release:tweet'.
128142
- name: Post to Twitter
129143
if: success() &&
130144
contains(github.event.pull_request.labels.*.name, 'release:tweet')
131-
run: echo Posting Tweet
145+
uses: ./.github/actions/send-tweet
146+
with:
147+
status: >
148+
${{ steps.preflight.outputs.version }} of @Firebase Admin Node.js SDK is avaialble.
149+
https://github.com/firebase/firebase-admin-node/releases/tag/${{ steps.preflight.outputs.version }}
150+
consumer-key: ${{ secrets.TWITTER_CONSUMER_KEY }}
151+
consumer-secret: ${{ secrets.TWITTER_CONSUMER_SECRET }}
152+
access-token: ${{ secrets.TWITTER_ACCESS_TOKEN }}
153+
access-token-secret: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
132154
continue-on-error: true

0 commit comments

Comments
 (0)