Skip to content

Commit 12cf860

Browse files
committed
chore: Update release workflows for push triggers
1 parent e827655 commit 12cf860

File tree

1 file changed

+24
-35
lines changed

1 file changed

+24
-35
lines changed

.github/workflows/release.yml

Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -15,34 +15,37 @@
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 created or 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+
- 'firebase_admin/__about__.py'
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.
3038
# To stage a release without publishing it, send a 'firebase_build' event or apply
3139
# the 'release:stage' label to a PR.
3240
if: github.event.action == 'firebase_build' ||
3341
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'))
42+
(github.event_name == 'push' && startsWith(github.event.head_commit.message, '[chore] Release '))
3643

3744
runs-on: ubuntu-latest
3845

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

4750
- name: Set up Python
4851
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # 5.6.0
@@ -82,15 +85,13 @@ jobs:
8285
publish_release:
8386
needs: stage_release
8487

85-
# Check whether the release should be published. We publish only when the trigger PR is
86-
# 1. merged
88+
# Check whether the release should be published. We publish only when the trigger is
89+
# 1. a push (merge)
8790
# 2. to the main branch
88-
# 3. with the label 'release:publish', and
89-
# 4. the title prefix '[chore] Release '.
90-
if: github.event.pull_request.merged &&
91+
# 3. and the commit message has the title prefix '[chore] Release '.
92+
if: github.event_name == 'push' &&
9193
github.ref == 'refs/heads/main' &&
92-
contains(github.event.pull_request.labels.*.name, 'release:publish') &&
93-
startsWith(github.event.pull_request.title, '[chore] Release ')
94+
startsWith(github.event.head_commit.message, '[chore] Release ')
9495

9596
runs-on: ubuntu-latest
9697
environment: Release
@@ -120,24 +121,12 @@ jobs:
120121
- name: Create release tag
121122
env:
122123
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
123-
run: gh release create ${{ steps.preflight.outputs.version }}
124-
--title "Firebase Admin Python SDK ${{ steps.preflight.outputs.version }}"
125-
--notes '${{ steps.preflight.outputs.changelog }}'
124+
RELEASE_VER: ${{ steps.preflight.outputs.version }}
125+
RELEASE_BODY: ${{ steps.preflight.outputs.changelog }}
126+
run: |
127+
gh release create "$RELEASE_VER" \
128+
--title "Firebase Admin Python SDK $RELEASE_VER" \
129+
--notes '$RELEASE_BODY'
126130
127131
- name: Publish to Pypi
128132
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
129-
130-
# Post to Twitter if explicitly opted-in by adding the label 'release:tweet'.
131-
- name: Post to Twitter
132-
if: success() &&
133-
contains(github.event.pull_request.labels.*.name, 'release:tweet')
134-
uses: firebase/firebase-admin-node/.github/actions/send-tweet@2e2b36a84ba28679bcb7aecdacabfec0bded2d48 # Admin Node SDK v13.6.0
135-
with:
136-
status: >
137-
${{ steps.preflight.outputs.version }} of @Firebase Admin Python SDK is available.
138-
https://github.com/firebase/firebase-admin-python/releases/tag/${{ steps.preflight.outputs.version }}
139-
consumer-key: ${{ secrets.TWITTER_CONSUMER_KEY }}
140-
consumer-secret: ${{ secrets.TWITTER_CONSUMER_SECRET }}
141-
access-token: ${{ secrets.TWITTER_ACCESS_TOKEN }}
142-
access-token-secret: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
143-
continue-on-error: true

0 commit comments

Comments
 (0)