Skip to content

Commit 7dba339

Browse files
committed
chore: Update release actions to run on Release env
1 parent 1c367ca commit 7dba339

File tree

3 files changed

+37
-37
lines changed

3 files changed

+37
-37
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
name: Continuous Integration
2-
on: pull_request
3-
jobs:
2+
on:
3+
pull_request:
4+
push:
5+
branches: [dev]
46

7+
jobs:
58
module:
69
name: Module build
710
runs-on: ubuntu-latest

.github/workflows/release.yml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,34 @@ on:
1818
# 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:
21-
types: [opened, synchronize, closed]
21+
types: [opened, synchronize]
2222

2323
repository_dispatch:
2424
types:
2525
- firebase_build
2626

27+
# Run the release candidate action when code is pushed to dev and only if firebase.go is changed
28+
push:
29+
branches:
30+
- dev
31+
paths:
32+
- 'firebase.go'
33+
2734
jobs:
2835
stage_release:
2936
# To publish a release, merge the release PR with the label 'release:publish'.
3037
# To stage a release without publishing it, send a 'firebase_build' event or apply
3138
# the 'release:stage' label to a PR.
3239
if: github.event.action == 'firebase_build' ||
3340
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'))
41+
(github.event_name == 'push' && github.ref == 'refs/heads/dev' &&
42+
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: Check out code
4348
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
44-
with:
45-
ref: ${{ github.event.client_payload.ref || github.ref }}
4649

4750
- name: Set up Go
4851
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
@@ -65,26 +68,22 @@ jobs:
6568
publish_release:
6669
needs: stage_release
6770

68-
# Check whether the release should be published. We publish only when the trigger PR is
69-
# 1. merged
70-
# 2. to the dev branch
71-
# 3. with the label 'release:publish', and
72-
# 4. the title prefix '[chore] Release '.
73-
if: github.event.pull_request.merged &&
74-
github.ref == 'refs/heads/dev' &&
75-
contains(github.event.pull_request.labels.*.name, 'release:publish') &&
76-
startsWith(github.event.pull_request.title, '[chore] Release ')
71+
# Run this ONLY when code is pushed/merged to dev
72+
# This automatically satisfies the 'Release' environment protection
73+
if: github.event_name == 'push' && github.ref == 'refs/heads/dev' &&
74+
startsWith(github.event.head_commit.message, '[chore] Release ')
7775

7876
runs-on: ubuntu-latest
7977
environment: Release
8078
permissions:
81-
contents: write
79+
pull-requests: write
8280

8381
steps:
8482
- name: Checkout source for publish
8583
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
8684
with:
8785
persist-credentials: false
86+
fetch-depth: 0
8887

8988
- name: Publish preflight check
9089
id: preflight
@@ -94,10 +93,11 @@ jobs:
9493
- name: Create Release PR
9594
env:
9695
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
96+
RELEASE_BODY: ${{ steps.preflight.outputs.changelog }}
97+
RELEASE_TITLE: "[chore] Release ${{ steps.preflight.outputs.version }}"
9798
run: |
9899
gh pr create \
99100
--base master \
100101
--head dev \
101-
--title "[chore] Release ${{ steps.preflight.outputs.version }}" \
102-
--body "${{ steps.preflight.outputs.changelog }}" \
103-
--label "release:tag"
102+
--title "$RELEASE_TITLE" \
103+
--body "$RELEASE_BODY"

.github/workflows/tag_release.yml

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,15 @@
1515
name: Tag Release
1616

1717
on:
18-
pull_request:
19-
types: [closed]
18+
push:
19+
branches:
20+
- master
21+
paths:
22+
- 'firebase.go'
2023

2124
jobs:
2225
tag_release:
23-
# Trigger only when:
24-
# 1. The PR is merged.
25-
# 2. The PR targets the master branch.
26-
# 3. The PR has the label 'release:tag'.
27-
if: github.event.pull_request.merged &&
28-
github.event.pull_request.base.ref == 'master' &&
29-
contains(github.event.pull_request.labels.*.name, 'release:tag') &&
30-
startsWith(github.event.pull_request.title, '[chore] Release ')
26+
if: startsWith(github.event.head_commit.message, '[chore] Release ')
3127

3228
runs-on: ubuntu-latest
3329
environment: Release
@@ -38,17 +34,18 @@ jobs:
3834
- name: Checkout code
3935
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
4036
with:
41-
ref: master
37+
fetch-depth: 0
4238

4339
- name: Publish preflight check
4440
id: preflight
4541
run: ./.github/scripts/publish_preflight_check.sh
4642

47-
# See: https://cli.github.com/manual/gh_release_create
4843
- name: Create release tag
4944
env:
5045
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51-
run: gh release create ${{ steps.preflight.outputs.version }}
52-
--title "Firebase Admin Go SDK ${{ steps.preflight.outputs.version }}"
53-
--notes '${{ steps.preflight.outputs.changelog }}'
46+
RELEASE_VER: ${{ steps.preflight.outputs.version }}
47+
RELEASE_NOTES: ${{ steps.preflight.outputs.changelog }}
48+
run: gh release create "$RELEASE_VER" \
49+
--title "Firebase Admin Go SDK $RELEASE_VER" \
50+
--notes "$RELEASE_NOTES" \
5451
--target "master"

0 commit comments

Comments
 (0)