Skip to content

Commit 8b144f6

Browse files
authored
chore: automate tagging releases
1 parent 71afe05 commit 8b144f6

File tree

4 files changed

+68
-12
lines changed

4 files changed

+68
-12
lines changed

.github/workflows/publish.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
required: true
1010
type: string
1111
secrets:
12-
publish_token:
12+
BCR_PUBLISH_TOKEN:
1313
required: true
1414
# In case of problems, let release engineers retry by manually dispatching
1515
# the workflow from the GitHub UI
@@ -20,8 +20,9 @@ on:
2020
type: string
2121
jobs:
2222
publish:
23-
uses: bazel-contrib/publish-to-bcr/.github/workflows/publish.yaml@v0.0.4
23+
uses: bazel-contrib/publish-to-bcr/.github/workflows/publish.yaml@v1.0.0
2424
with:
25+
draft: false
2526
tag_name: ${{ inputs.tag_name }}
2627
# GitHub repository which is a fork of the upstream where the Pull Request will be opened.
2728
registry_fork: aspect-build/bazel-central-registry
@@ -31,4 +32,4 @@ jobs:
3132
id-token: write
3233
secrets:
3334
# Necessary to push to the BCR fork, and to open a pull request against a registry
34-
publish_token: ${{ secrets.publish_token || secrets.BCR_PUBLISH_TOKEN }}
35+
publish_token: ${{ secrets.BCR_PUBLISH_TOKEN }}

.github/workflows/release.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,34 @@
44
name: Release
55

66
on:
7-
push:
8-
tags:
9-
- 'v*.*.*'
7+
# Can be triggered from the tag.yaml workflow
8+
workflow_call:
9+
inputs:
10+
tag_name:
11+
required: true
12+
type: string
13+
secrets:
14+
BCR_PUBLISH_TOKEN:
15+
required: true
16+
# Or, developers can manually push a tag from their clone
17+
push:
18+
tags:
19+
- "v*.*.*"
1020
permissions:
1121
id-token: write
1222
attestations: write
1323
contents: write
1424
jobs:
1525
release:
16-
uses: bazel-contrib/.github/.github/workflows/[email protected].2
26+
uses: bazel-contrib/.github/.github/workflows/[email protected].3
1727
with:
1828
release_files: rules_ts-*.tar.gz
1929
prerelease: false
20-
tag_name: ${{ github.ref_name }}
30+
tag_name: ${{ inputs.tag_name || github.ref_name }}
2131
publish:
2232
needs: release
2333
uses: ./.github/workflows/publish.yaml
2434
with:
25-
tag_name: ${{ github.ref_name }}
35+
tag_name: ${{ inputs.tag_name || github.ref_name }}
2636
secrets:
2737
publish_token: ${{ secrets.BCR_PUBLISH_TOKEN }}

.github/workflows/release_prep.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
set -o errexit -o nounset -o pipefail
44

5-
# Set by GH actions, see
6-
# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
7-
TAG=${GITHUB_REF_NAME}
5+
# Argument provided by reusable workflow caller, see
6+
# https://github.com/bazel-contrib/.github/blob/d197a6427c5435ac22e56e33340dff912bc9334e/.github/workflows/release_ruleset.yaml#L72
7+
TAG=$1
88
# Strip leading 'v'
99
PREFIX="rules_ts-${TAG:1}"
1010
ARCHIVE="rules_ts-$TAG.tar.gz"

.github/workflows/tag.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
# Run twice a month, on the 1rst and 15th at 3PM UTC (8AM PST)
13+
# This is a trade-off between making too many releases,
14+
# which overwhelms BCR maintainers and over-notifies users,
15+
# and releasing too infrequently which delays delivery of bugfixes and features.
16+
schedule:
17+
- cron: "0 15 1,15 * *"
18+
jobs:
19+
tag:
20+
permissions:
21+
contents: write # allow create tag
22+
runs-on: ubuntu-latest
23+
outputs:
24+
new-tag: ${{ steps.ccv.outputs.new-tag }}
25+
new-tag-version: ${{steps.ccv.outputs.new-tag-version}}
26+
steps:
27+
- uses: actions/checkout@v5
28+
with:
29+
# Need enough history to find the prior release tag
30+
fetch-depth: 0
31+
- name: Bump tag if necessary
32+
id: ccv
33+
uses: smlx/ccv@7318e2f25a52dcd550e75384b84983973251a1f8 # v0.10.0
34+
release:
35+
needs: tag
36+
uses: ./.github/workflows/release.yml
37+
with:
38+
tag_name: ${{ needs.tag.outputs.new-tag-version }}
39+
secrets:
40+
BCR_PUBLISH_TOKEN: ${{ secrets.BCR_PUBLISH_TOKEN }}
41+
if: needs.tag.outputs.new-tag == 'true' && needs.tag.outputs.new-tag-version-type != 'major'
42+
permissions:
43+
id-token: write
44+
attestations: write
45+
contents: write

0 commit comments

Comments
 (0)