Skip to content

Commit fa2303f

Browse files
Merge pull request #15 from HasData/ci/release-on-version-bump
ci(release): release by merging a VERSION bump
2 parents e7c9d6d + 6def8f8 commit fa2303f

3 files changed

Lines changed: 43 additions & 1 deletion

File tree

‎.github/workflows/release.yml‎

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
name: release
22

3+
# Two ways to cut a release:
4+
# 1. Merge a PR that bumps VERSION. This workflow tags the merge commit
5+
# v<VERSION> and builds it. If .github/release-notes/v<VERSION>.md exists,
6+
# it becomes the release body instead of the generated changelog.
7+
# 2. Push a v* tag by hand, as before.
38
on:
49
push:
10+
branches: [main]
11+
paths: [VERSION]
512
tags:
613
- "v*"
714

@@ -16,7 +23,38 @@ jobs:
1623
with:
1724
fetch-depth: 0
1825

26+
# A tag pushed with GITHUB_TOKEN doesn't start another workflow run, so
27+
# tag and build in this job rather than waiting for the tag trigger.
28+
- name: tag VERSION bump
29+
id: tag
30+
if: github.ref_type == 'branch'
31+
run: |
32+
version=$(tr -d '[:space:]' < VERSION)
33+
if ! [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then
34+
echo "VERSION must be semver like 0.3.0, got '$version'"
35+
exit 1
36+
fi
37+
tag="v$version"
38+
if git rev-parse -q --verify "refs/tags/$tag" >/dev/null; then
39+
echo "$tag already exists; nothing to release."
40+
echo "skip=true" >> "$GITHUB_OUTPUT"
41+
exit 0
42+
fi
43+
git tag "$tag"
44+
git push origin "$tag"
45+
echo "tag=$tag" >> "$GITHUB_OUTPUT"
46+
47+
- name: release notes
48+
id: notes
49+
if: steps.tag.outputs.skip != 'true'
50+
run: |
51+
notes=".github/release-notes/${{ steps.tag.outputs.tag || github.ref_name }}.md"
52+
if [ -f "$notes" ]; then
53+
echo "args=--release-notes $notes" >> "$GITHUB_OUTPUT"
54+
fi
55+
1956
- uses: actions/setup-go@v5
57+
if: steps.tag.outputs.skip != 'true'
2058
with:
2159
go-version: "1.24"
2260
cache: true
@@ -35,10 +73,11 @@ jobs:
3573
# owner: HasData
3674

3775
- uses: goreleaser/goreleaser-action@v6
76+
if: steps.tag.outputs.skip != 'true'
3877
with:
3978
distribution: goreleaser
4079
version: latest
41-
args: release --clean
80+
args: release --clean ${{ steps.notes.outputs.args }}
4281
env:
4382
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4483
# HOMEBREW_TAP_TOKEN: ${{ steps.app_token.outputs.token }}

‎README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ go build ./...
190190
go test ./...
191191
```
192192

193+
Releasing: bump `VERSION` in a PR. Merging it tags `v<VERSION>` and publishes the release; add `.github/release-notes/v<VERSION>.md` to write the release body yourself. Pushing a `v*` tag by hand still works.
194+
193195
## Resources
194196

195197
- **HasData docs** — <https://docs.hasdata.com>

‎VERSION‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.2.2

0 commit comments

Comments
 (0)