Skip to content

Commit 40a3b65

Browse files
authored
feat: allow releasing from GH UI (#66)
It's easy to clone the repo and tag on the command-line, but it's error-prone - you might fetch the wrong remote, then apply a tag you think is at HEAD of origin/main but is actually stale. I've done that! Instead this automation lets us click a button on GitHub and guaranteed to release the right thing. Also adds a cron so we don't accidentally go several weeks without a release. It only makes one if there are fixes or features. Note, it expects our commit history has semantic commits
1 parent 37405fe commit 40a3b65

File tree

3 files changed

+46
-4
lines changed

3 files changed

+46
-4
lines changed

.github/workflows/publish.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
required: true
99
type: string
1010
secrets:
11-
publish_token:
11+
BCR_PUBLISH_TOKEN:
1212
required: true
1313
# In case of problems, let release engineers retry by manually dispatching
1414
# the workflow from the GitHub UI
@@ -32,4 +32,4 @@ jobs:
3232
id-token: write
3333
secrets:
3434
# Necessary to push to the BCR fork, and to open a pull request against a registry
35-
publish_token: ${{ secrets.publish_token || secrets.BCR_PUBLISH_TOKEN }}
35+
publish_token: ${{ secrets.BCR_PUBLISH_TOKEN }}

.github/workflows/release.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
required: true
88
type: string
99
secrets:
10-
publish_token:
10+
BCR_PUBLISH_TOKEN:
1111
required: true
1212
# Or, developers can manually push a tag from their clone
1313
push:
@@ -30,4 +30,4 @@ jobs:
3030
with:
3131
tag_name: ${{ inputs.tag_name || github.ref_name }}
3232
secrets:
33-
publish_token: ${{ secrets.publish_token || secrets.BCR_PUBLISH_TOKEN }}
33+
BCR_PUBLISH_TOKEN: ${{ secrets.BCR_PUBLISH_TOKEN }}

.github/workflows/tag.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Tag a new release
2+
# This is easier than having to run manual `git` operations on a local clone.
3+
# It also runs on a schedule so we don't leave commits unreleased indefinitely
4+
# (avoiding users having to ping "hey could someone cut a release").
5+
name: Tag a Release
6+
on:
7+
# Allow devs to tag manually through the GitHub UI.
8+
# For example after landing a fix that customers are waiting for.
9+
workflow_dispatch:
10+
# Run at 4PM UTC (9AM PST) on the 3rd and 18th of each month.
11+
# This is a trade-off between making too many releases,
12+
# which overwhelms BCR maintainers and over-notifies users,
13+
# and releasing too infrequently which delays delivery of bugfixes and features.
14+
schedule:
15+
- cron: "0 16 3,18 * *"
16+
jobs:
17+
tag:
18+
permissions:
19+
contents: write # allow create tag
20+
runs-on: ubuntu-latest
21+
outputs:
22+
new-tag: ${{ steps.ccv.outputs.new-tag }}
23+
new-tag-version: ${{steps.ccv.outputs.new-tag-version}}
24+
steps:
25+
- uses: actions/checkout@v4
26+
with:
27+
# Need enough history to find the prior release tag
28+
fetch-depth: 0
29+
- name: Bump tag if necessary
30+
id: ccv
31+
uses: smlx/ccv@7318e2f25a52dcd550e75384b84983973251a1f8 # v0.10.0
32+
release:
33+
needs: tag
34+
uses: ./.github/workflows/release.yaml
35+
with:
36+
tag_name: ${{ needs.tag.outputs.new-tag-version }}
37+
if: needs.tag.outputs.new-tag == 'true' && needs.tag.outputs.new-tag-version-type != 'major'
38+
secrets: inherit
39+
permissions:
40+
contents: write
41+
attestations: write
42+
id-token: write

0 commit comments

Comments
 (0)