Skip to content

Commit 7600a81

Browse files
authored
feat(cd): auto-tag releases twice a month (#129)
* feat(cd): auto-tag releases twice a month Avoids the common pitfall where users have to request a release, i.e. the inevitable slack message 'hey could you cut a release with that new fix' Relies on the repository using semver commit messages. This is already implied in this template because commitizen-tools/commitizen is installed as a commit-msg pre-commit hook. Based on https://github.com/aspect-build/rules_lint/pull/427/files where this is already observed to be working. * Update release.yml * fix: don't auto-release majors * Delete MODULE.bazel.lock * chore: this commit was tagged
1 parent fba3b7e commit 7600a81

3 files changed

Lines changed: 72 additions & 6 deletions

File tree

.github/workflows/release.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
# Cut a release whenever a new tag is pushed to the repo.
2-
# You should use an annotated tag, like `git tag -a v1.2.3`
3-
# and put the release notes into the commit message for the tag.
42
name: Release
53

64
on:
5+
# Can be triggered from the tag.yaml workflow
6+
workflow_call:
7+
inputs:
8+
tag_name:
9+
required: true
10+
type: string
11+
# Or, developers can manually push a tag from their clone
712
push:
813
tags:
914
- "v*.*.*"
@@ -13,6 +18,7 @@ permissions:
1318

1419
jobs:
1520
release:
16-
uses: bazel-contrib/.github/.github/workflows/release_ruleset.yaml@v6
21+
uses: bazel-contrib/.github/.github/workflows/release_ruleset.yaml@c9d6d1893b10a8d68584a6ba52c3dd35506486d0 # 2024-12-03
1722
with:
1823
release_files: rules_mylang-*.tar.gz
24+
tag_name: ${{ inputs.tag_name }}

.github/workflows/tag.yaml

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

CONTRIBUTING.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,23 @@ This means that any usage of `@rules_mylang` on your system will point to this f
4444

4545
## Releasing
4646

47-
1. Determine the next release version, following semver (could automate in the future from changelog)
48-
1. Tag the repo and push it (or create a tag in GH UI)
49-
1. Watch the automation run on GitHub actions
47+
Releases are automated on a cron trigger.
48+
The new version is determined automatically from the commit history, assuming the commit messages follow conventions, using
49+
https://github.com/marketplace/actions/conventional-commits-versioner-action.
50+
If you do nothing, eventually the newest commits will be released automatically as a patch or minor release.
51+
This automation is defined in .github/workflows/tag.yaml.
52+
53+
Rather than wait for the cron event, you can trigger manually. Navigate to
54+
https://github.com/myorg/rules_mylang/actions/workflows/tag.yaml
55+
and press the "Run workflow" button.
56+
57+
If you need control over the next release version, for example when making a release candidate for a new major,
58+
then: tag the repo and push the tag, for example
59+
60+
```sh
61+
% git fetch
62+
% git tag v1.0.0-rc0 origin/main
63+
% git push origin v1.0.0-rc0
64+
```
65+
66+
Then watch the automation run on GitHub actions which creates the release.

0 commit comments

Comments
 (0)