Skip to content

Commit 0c57dbc

Browse files
committed
Splitting staging and publish phases into separate jobs
1 parent 1830a0b commit 0c57dbc

File tree

2 files changed

+51
-13
lines changed

2 files changed

+51
-13
lines changed

.github/scripts/publish_preflight_check.sh

+20
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,26 @@ echo_info "Extracted release version: ${RELEASE_VERSION}"
5959
echo "::set-output name=version::v${RELEASE_VERSION}"
6060

6161

62+
echo_info ""
63+
echo_info "--------------------------------------------"
64+
echo_info "Check release artifacts"
65+
echo_info "--------------------------------------------"
66+
echo_info ""
67+
68+
if [[ ! -d dist ]]; then
69+
echo_warn "dist directory does not exist."
70+
terminate
71+
fi
72+
73+
readonly RELEASE_ARTIFACT="dist/firebase-admin-${RELEASE_VERSION}.tgz"
74+
if [[ -f "${RELEASE_ARTIFACT}" ]]; then
75+
echo_info "Found release artifact: ${RELEASE_ARTIFACT}"
76+
else
77+
echo_warn "Release artifact ${RELEASE_ARTIFACT} not found."
78+
terminate
79+
fi
80+
81+
6282
echo_info ""
6383
echo_info "--------------------------------------------"
6484
echo_info "Checking previous releases"

.github/workflows/release.yml

+31-13
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
name: Release
15+
name: Release Candidate
1616

1717
on:
18-
# Only run the workflow when a PR is closed, or when a developer explicitly requests
18+
# Only run the workflow when a PR is updated or when a developer explicitly requests
1919
# a build by sending a 'firebase_build' event.
2020
pull_request:
2121
types: [opened, synchronize, closed]
@@ -74,24 +74,43 @@ jobs:
7474
PACKAGE_TARBALL=`ls *.tgz`
7575
./verifyReleaseTarball.sh $PACKAGE_TARBALL
7676
77+
publish_release:
78+
needs: stage_release
79+
7780
# Check whether the release should be published. We publish only when the trigger PR is
7881
# 1. merged
7982
# 2. to the master branch
8083
# 3. with the title prefix '[chore] Release '.
81-
- name: Publish preflight check
82-
if: success() && github.event.pull_request.merged &&
84+
if: success() && github.event.pull_request.merged &&
8385
github.ref == 'master' &&
8486
startsWith(github.event.pull_request.title, '[chore] Release ')
87+
88+
runs-on: ubuntu-latest
89+
90+
steps:
91+
- name: Checkout source for publish
92+
uses: actions/checkout@v2
93+
94+
# Download the artifacts created by the stage_release job.
95+
- name: Download release candidates
96+
uses: actions/download-artifact@v1
97+
with:
98+
name: dist
99+
100+
# Node.js and NPM are needed to complete the publish.
101+
- name: Set up Node.js
102+
uses: actions/setup-node@v1
103+
with:
104+
node-version: 8.x
105+
106+
- name: Publish preflight check
85107
id: preflight
86-
run: |
87-
./.github/scripts/publish_preflight_check.sh
88-
echo ::set-env name=FIREBASE_PUBLISH::true
108+
run: ./.github/scripts/publish_preflight_check.sh
89109

90-
# Tag the release if not executing in the dryrun mode. We pull this action froma
91-
# custom fork of a contributor until https://github.com/actions/create-release/pull/32
92-
# is merged. Also note that v1 of this action does not support the "body" parameter.
110+
# We pull this action from a custom fork of a contributor until
111+
# https://github.com/actions/create-release/pull/32 is merged. Also note that v1 of
112+
# this action does not support the "body" parameter.
93113
- name: Create release tag
94-
if: success() && env.FIREBASE_PUBLISH
95114
uses: fleskesvor/create-release@1a72e235c178bf2ae6c51a8ae36febc24568c5fe
96115
env:
97116
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -103,12 +122,11 @@ jobs:
103122
prerelease: false
104123

105124
- name: Publish to NPM
106-
if: success() && env.FIREBASE_PUBLISH
107125
run: echo Publishing to NPM
108126

109127
# Post to Twitter if explicitly opted-in by adding the label 'release:tweet'.
110128
- name: Post to Twitter
111-
if: success() && env.FIREBASE_PUBLISH &&
129+
if: success() &&
112130
contains(github.event.pull_request.labels.*.name, 'release:tweet')
113131
run: echo Posting Tweet
114132
continue-on-error: true

0 commit comments

Comments
 (0)