|
15 | 15 | name: Release Candidate |
16 | 16 |
|
17 | 17 | 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. |
20 | 22 | 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' |
22 | 30 |
|
23 | 31 | repository_dispatch: |
24 | 32 | types: |
25 | 33 | - firebase_build |
26 | 34 |
|
27 | 35 | jobs: |
28 | 36 | 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. |
30 | 39 | # To stage a release without publishing it, send a 'firebase_build' event or apply |
31 | 40 | # the 'release:stage' label to a PR. |
32 | 41 | if: github.event.action == 'firebase_build' || |
33 | 42 | 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 ')) |
36 | 44 |
|
37 | 45 | runs-on: ubuntu-latest |
38 | 46 |
|
39 | | - # When manually triggering the build, the requester can specify a target branch or a tag |
40 | | - # via the 'ref' client parameter. |
41 | 47 | steps: |
42 | 48 | - name: Checkout source for staging |
43 | 49 | uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # 4.3.1 |
44 | | - with: |
45 | | - ref: ${{ github.event.client_payload.ref || github.ref }} |
46 | 50 |
|
47 | 51 | - name: Set up Python |
48 | 52 | uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # 5.6.0 |
@@ -82,15 +86,13 @@ jobs: |
82 | 86 | publish_release: |
83 | 87 | needs: stage_release |
84 | 88 |
|
85 | | - # Check whether the release should be published. We publish only when the trigger PR is |
86 | | - # 1. merged |
| 89 | + # Check whether the release should be published. We publish only when the trigger is |
| 90 | + # 1. a push (merge) |
87 | 91 | # 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 && |
| 92 | + # 3. and the commit message has the title prefix '[chore] Release '. |
| 93 | + if: github.event_name == 'push' && |
91 | 94 | github.ref == 'refs/heads/main' && |
92 | | - contains(github.event.pull_request.labels.*.name, 'release:publish') && |
93 | | - startsWith(github.event.pull_request.title, '[chore] Release ') |
| 95 | + startsWith(github.event.head_commit.message, '[chore] Release ') |
94 | 96 |
|
95 | 97 | runs-on: ubuntu-latest |
96 | 98 | environment: Release |
@@ -120,24 +122,12 @@ jobs: |
120 | 122 | - name: Create release tag |
121 | 123 | env: |
122 | 124 | 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 }}' |
| 125 | + RELEASE_VER: ${{ steps.preflight.outputs.version }} |
| 126 | + RELEASE_BODY: ${{ steps.preflight.outputs.changelog }} |
| 127 | + run: | |
| 128 | + gh release create "$RELEASE_VER" \ |
| 129 | + --title "Firebase Admin Python SDK $RELEASE_VER" \ |
| 130 | + --notes "$RELEASE_BODY" |
126 | 131 |
|
127 | 132 | - name: Publish to Pypi |
128 | 133 | 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