Skip to content

Commit 9cd8afe

Browse files
authored
chore: Update release workflow for push triggers (#1174)
* chore: Update release workflow for push triggers * chore: update release instructions
1 parent eea335a commit 9cd8afe

File tree

1 file changed

+30
-26
lines changed

1 file changed

+30
-26
lines changed

.github/workflows/release.yml

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,34 +15,38 @@
1515
name: Release Candidate
1616

1717
on:
18-
# Only run the workflow when a PR is updated or when a developer explicitly requests
19-
# a build by sending a 'firebase_build' event.
18+
# Run the workflow when:
19+
# 1. A PR is updated (staging checks).
20+
# 2. A commit is pushed to main (release publication).
21+
# 3. A developer explicitly requests a build via 'firebase_build' event.
2022
pull_request:
21-
types: [opened, synchronize, closed]
23+
types: [opened, synchronize]
24+
25+
push:
26+
branches:
27+
- main
28+
paths:
29+
- 'pom.xml'
2230

2331
repository_dispatch:
2432
types:
2533
- firebase_build
2634

2735
jobs:
2836
stage_release:
29-
# To publish a release, merge the release PR with the label 'release:publish'.
37+
# To publish a release, merge a PR with the title prefix '[chore] Release ' to main
38+
# and ensure the squashed commit message also has the prefix.
3039
# To stage a release without publishing it, send a 'firebase_build' event or apply
3140
# the 'release:stage' label to a PR.
3241
if: github.event.action == 'firebase_build' ||
3342
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'))
43+
(github.event_name == 'push' && startsWith(github.event.head_commit.message, '[chore] Release '))
3644

3745
runs-on: ubuntu-latest
3846

39-
# When manually triggering the build, the requester can specify a target branch or a tag
40-
# via the 'ref' client parameter.
4147
steps:
4248
- name: Checkout source for staging
4349
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
44-
with:
45-
ref: ${{ github.event.client_payload.ref || github.ref }}
4650

4751
- name: Set up JDK 8
4852
uses: actions/setup-java@c1e323688fd81a25caa38c78aa6df2d33d3e20d9 # v4.8.0
@@ -67,15 +71,13 @@ jobs:
6771
publish_release:
6872
needs: stage_release
6973

70-
# Check whether the release should be published. We publish only when the trigger PR is
71-
# 1. merged
74+
# Check whether the release should be published. We publish only when the trigger is
75+
# 1. a push (merge)
7276
# 2. to the main branch
73-
# 3. with the label 'release:publish', and
74-
# 4. the title prefix '[chore] Release '.
75-
if: github.event.pull_request.merged &&
77+
# 3. and the commit message has the title prefix '[chore] Release '.
78+
if: github.event_name == 'push' &&
7679
github.ref == 'refs/heads/main' &&
77-
contains(github.event.pull_request.labels.*.name, 'release:publish') &&
78-
startsWith(github.event.pull_request.title, '[chore] Release ')
80+
startsWith(github.event.head_commit.message, '[chore] Release ')
7981

8082
runs-on: ubuntu-latest
8183
environment: Release
@@ -92,6 +94,17 @@ jobs:
9294
distribution: 'zulu'
9395
java-version: 8
9496

97+
# See: https://cli.github.com/manual/gh_release_create
98+
- name: Create release tag
99+
env:
100+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
101+
RELEASE_VER: ${{ steps.preflight.outputs.version }}
102+
RELEASE_BODY: ${{ steps.preflight.outputs.changelog }}
103+
run: |
104+
gh release create "$RELEASE_VER" \
105+
--title "Firebase Admin Java SDK $RELEASE_VER" \
106+
--notes "$RELEASE_BODY"
107+
95108
- name: Publish preflight check
96109
id: preflight
97110
run: ./.github/scripts/publish_preflight_check.sh
@@ -104,12 +117,3 @@ jobs:
104117
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }}
105118
CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }}
106119
CENTRAL_TOKEN: ${{ secrets.CENTRAL_TOKEN }}
107-
108-
# See: https://cli.github.com/manual/gh_release_create
109-
- name: Create release tag
110-
env:
111-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
112-
run: gh release create ${{ steps.preflight.outputs.version }}
113-
--title "Firebase Admin Java SDK ${{ steps.preflight.outputs.version }}"
114-
--notes '${{ steps.preflight.outputs.changelog }}'
115-

0 commit comments

Comments
 (0)