Skip to content

Commit d069dc5

Browse files
committed
ci: rework CI workflows
This commit reworks CI workflows to invoke Release-Please twice: once to create a PR, which later auto-merged and another time to actually create a GitHub Release.
1 parent 0524047 commit d069dc5

File tree

2 files changed

+36
-8
lines changed

2 files changed

+36
-8
lines changed

.github/workflows/release.yaml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,15 @@ jobs:
2626
created: ${{ steps.release.outputs.release_created }}
2727
tag: ${{ steps.release.outputs.tag_name }}
2828
steps:
29-
- uses: googleapis/release-please-action@v4
29+
- name: Auto-merge Release-Please PR
30+
run: |
31+
gh pr merge ${{ github.event.client_payload.pr_number }} --squash
32+
33+
- name: Run Release-Please
34+
uses: googleapis/release-please-action@v4
3035
id: release
3136
with:
32-
token: ${{secrets.GITHUB_TOKEN}}
37+
token: ${{ secrets.ACCESS_TOKEN }}
3338
config-file: "release-please-config.json"
3439
manifest-file: ".release-please-manifest.json"
3540
release-type: bazel
@@ -39,14 +44,14 @@ jobs:
3944
needs: [release]
4045
if: ${{ needs.release.outputs.created && !failure() }}
4146
env:
42-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
4348
steps:
4449
- name: Download Release artifacts
4550
uses: actions/download-artifact@v4
4651
with:
4752
name: distributables
4853
path: dist
49-
github-token: ${{ secrets.GITHUB_TOKEN }}
54+
github-token: ${{ env.GITHUB_TOKEN }}
5055
repository: ${{ github.repository }}
5156
run-id: ${{ github.event.client_payload.run_id }}
5257

.github/workflows/testing.yaml

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ on:
1111

1212
permissions:
1313
contents: write
14+
pull-requests: write
1415

1516
defaults:
1617
run:
@@ -27,7 +28,11 @@ jobs:
2728
os: [ubuntu-latest]
2829
runs-on: ${{ matrix.os }}
2930
env:
31+
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
3032
CACHE_PATH: ${{ matrix.os == 'macos-latest' && '/private/var/tmp/_bazel_runner/' || '~/.cache/bazel' }}
33+
outputs:
34+
created: "${{ steps.release.outputs.prs_created }}"
35+
pr: "${{ steps.output-pr.outputs.number }}"
3136
steps:
3237
- name: Checkout
3338
uses: actions/checkout@v4
@@ -55,15 +60,30 @@ jobs:
5560
run: |
5661
bazel --output_user_root=${{ env.CACHE_PATH }} test //...
5762
63+
# create a release PR
64+
- name: Run Release-Please
65+
uses: googleapis/release-please-action@v4
66+
id: release
67+
with:
68+
token: ${{ env.GITHUB_TOKEN }}
69+
config-file: "release-please-config.json"
70+
manifest-file: ".release-please-manifest.json"
71+
release-type: bazel
72+
73+
- name: Output crated PR number
74+
id: output-pr
75+
run: |
76+
echo "number=${{ fromJSON(steps.release.outputs.pr).number }}" >> "$GITHUB_OUTPUT"
77+
5878
# Fail here if tests didn't succeed
5979
- name: Generate Release artifacts
60-
if: ${{ success() }}
80+
if: ${{ success() && steps.release.outputs.prs_created }}
6181
run: |
6282
scripts/release.sh executables
6383
scripts/release.sh tarballs
6484
6585
- name: Upload Release artifacts
66-
if: ${{ success() }}
86+
if: ${{ success() && steps.release.outputs.prs_created }}
6787
uses: actions/upload-artifact@v4
6888
with:
6989
name: distributables
@@ -73,15 +93,18 @@ jobs:
7393
7494
dispatch:
7595
runs-on: ubuntu-latest
96+
env:
97+
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
7698
needs: [test]
7799
steps:
78100
- name: Dispatch a release workflow run
79-
if: ${{ !failure() }}
101+
if: ${{ needs.test.outputs.created }}
80102
uses: actions/github-script@v7
81103
with:
82-
github-token: ${{ secrets.GITHUB_TOKEN }}
104+
github-token: "${{ env.GITHUB_TOKEN }}"
83105
script: |
84106
const payload = {
107+
pr_number: "${{ needs.test.outputs.pr }}"
85108
run_id: "${{ github.run_id }}",
86109
sha: "${{ github.sha }}"
87110
}

0 commit comments

Comments
 (0)