Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 40 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
name: release

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

Expand All @@ -16,7 +23,38 @@ jobs:
with:
fetch-depth: 0

# A tag pushed with GITHUB_TOKEN doesn't start another workflow run, so
# tag and build in this job rather than waiting for the tag trigger.
- name: tag VERSION bump
id: tag
if: github.ref_type == 'branch'
run: |
version=$(tr -d '[:space:]' < VERSION)
if ! [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then
echo "VERSION must be semver like 0.3.0, got '$version'"
exit 1
fi
tag="v$version"
if git rev-parse -q --verify "refs/tags/$tag" >/dev/null; then
echo "$tag already exists; nothing to release."
echo "skip=true" >> "$GITHUB_OUTPUT"
exit 0
fi
git tag "$tag"
git push origin "$tag"
echo "tag=$tag" >> "$GITHUB_OUTPUT"

- name: release notes
id: notes
if: steps.tag.outputs.skip != 'true'
run: |
notes=".github/release-notes/${{ steps.tag.outputs.tag || github.ref_name }}.md"
if [ -f "$notes" ]; then
echo "args=--release-notes $notes" >> "$GITHUB_OUTPUT"
fi

- uses: actions/setup-go@v5
if: steps.tag.outputs.skip != 'true'
with:
go-version: "1.24"
cache: true
Expand All @@ -35,10 +73,11 @@ jobs:
# owner: HasData

- uses: goreleaser/goreleaser-action@v6
if: steps.tag.outputs.skip != 'true'
with:
distribution: goreleaser
version: latest
args: release --clean
args: release --clean ${{ steps.notes.outputs.args }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# HOMEBREW_TAP_TOKEN: ${{ steps.app_token.outputs.token }}
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ go build ./...
go test ./...
```

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.

## Resources

- **HasData docs** — <https://docs.hasdata.com>
Expand Down
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.2.2
Loading