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
31 changes: 25 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ on:
push:
branches:
- main
release:
types:
- published
tags:
- 'v*'

permissions: {}

jobs:
goreleaser-check:
name: Check GoReleaser
if: github.event_name != 'release'
if: github.ref_type != 'tag'
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -40,7 +41,7 @@ jobs:

goreleaser:
name: Release with GoReleaser
if: github.event_name == 'release' && github.event.action == 'published'
if: github.event_name == 'push' && github.ref_type == 'tag'
runs-on: ubuntu-latest
environment: release
permissions:
Expand All @@ -53,6 +54,23 @@ jobs:
submodules: recursive
persist-credentials: false

# On a tag push, actions/checkout replaces the annotated tag with a
# lightweight tag. Fetch the tags again to get the tag message.
- name: Fetch annotated tags
run: git fetch --force --tags

- name: Get release notes from the tag
run: |
if [ "$(git cat-file -t "refs/tags/$GITHUB_REF_NAME")" != tag ]; then
echo "Tag $GITHUB_REF_NAME is not an annotated tag. Create it with dev-bin/release.sh."
exit 1
fi
git tag -l --format='%(contents:body)' "$GITHUB_REF_NAME" > "$RUNNER_TEMP/release-notes.md"
if ! grep -q '[^[:space:]]' "$RUNNER_TEMP/release-notes.md"; then
echo "Tag $GITHUB_REF_NAME has no release notes. Create it with dev-bin/release.sh."
exit 1
fi

- name: Set up Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
Expand All @@ -64,6 +82,7 @@ jobs:
with:
distribution: goreleaser
version: latest
args: release --clean
args: release --clean --release-notes ${{ runner.temp }}/release-notes.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GORELEASER_CURRENT_TAG: ${{ github.ref_name }}
3 changes: 0 additions & 3 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ checksum:
snapshot:
version_template: "{{ .Tag }}-next"

changelog:
disable: true

nfpms:
- id: 'mmdbconvert'
ids:
Expand Down
16 changes: 16 additions & 0 deletions README.dev.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Releasing

- Install `bash`, `git`, `go`, `gh`, and `sed`. Authenticate with
`gh auth login` and ensure your Git credentials can push to the repository.
- Create a release branch from `main`.
- Update the version, date, and notes in `CHANGELOG.md`. Use the format
`## [0.2.2] - YYYY-MM-DD` with today's date and a semantic version.
- Commit the changes.
- Run `dev-bin/release.sh` and review the version and notes before confirming.
The script pushes the branch, then pushes an annotated tag containing the
release notes.
- An authorized releaser must approve the Release workflow's pending deployment.
GoReleaser uploads the binaries and packages to a draft release, then
publishes it with the notes from the tag.
- Verify the assets and notes on the GitHub Releases page.
- Open a PR for the release branch and get it merged.
10 changes: 8 additions & 2 deletions dev-bin/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ date="${BASH_REMATCH[3]}"
notes="$(echo "${BASH_REMATCH[4]}" | sed -n -E '/^## \[?[0-9]+\.[0-9]+\.[0-9]+/,$!p')"
tag="v$version"

if ! grep -q '[^[:space:]]' <<<"$notes"; then
echo "Release notes for $tag are empty. Add notes to CHANGELOG.md." >&2
exit 1
fi

if [[ "$date" != "$(date +"%Y-%m-%d")" ]]; then
echo "$date is not today!"
exit 1
Expand Down Expand Up @@ -95,6 +100,7 @@ message="$version

$notes"

git tag -a -m "$message" "$tag"
# "whitespace" keeps Markdown headings and adds a newline before a signature.
git tag -a --cleanup=whitespace -m "$message" "$tag"

git push --tags
git push origin "refs/tags/$tag"
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/maxmind/mmdbconvert
go 1.27.0

require (
github.com/maxmind/mmdbwriter/v2 v2.0.0-20260928214421-cc514d224474
github.com/oschwald/maxminddb-golang/v2 v2.6.0
github.com/maxmind/mmdbwriter/v2 v2.0.0-20260929214414-aa874fe6bc9e
github.com/oschwald/maxminddb-golang/v2 v2.7.0
github.com/parquet-go/parquet-go v0.32.0
github.com/pelletier/go-toml/v2 v2.4.3
github.com/stretchr/testify v1.12.1
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUq
github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
github.com/klauspost/compress v1.18.2 h1:iiPHWW0YrcFgpBYhsA6D1+fqHssJscY/Tm/y2Uqnapk=
github.com/klauspost/compress v1.18.2/go.mod h1:R0h/fSBs8DE4ENlcrlib3PsXS61voFxhIs2DeRhCvJ4=
github.com/maxmind/mmdbwriter/v2 v2.0.0-20260928214421-cc514d224474 h1:g1xsksNM6TU0WRdd+EexImVGW1ffFy4XFVLI6Rx6LKE=
github.com/maxmind/mmdbwriter/v2 v2.0.0-20260928214421-cc514d224474/go.mod h1:hPQyr0pfn16zAHNQsUS9w4SHjBZ/Y8+Jfmf04SS1K8A=
github.com/oschwald/maxminddb-golang/v2 v2.6.0 h1:pRlHCdJmc+4uxMOSthmKDt5HOw3JTX8TJZlhyP5ew0w=
github.com/oschwald/maxminddb-golang/v2 v2.6.0/go.mod h1:sjqpB3z2BZrMduDp9TAUTCkZDoT3nDhixUc4Dge2qRQ=
github.com/maxmind/mmdbwriter/v2 v2.0.0-20260929214414-aa874fe6bc9e h1:tFFxMqYvIZ6Z4sdOf+KlKHeMQ7Y4PA/bCSOH6s5XWyY=
github.com/maxmind/mmdbwriter/v2 v2.0.0-20260929214414-aa874fe6bc9e/go.mod h1:wgHnsdUYfQeQZI6xWn4Ix7zt1b9/Wi5Q9JJMFa1jZDk=
github.com/oschwald/maxminddb-golang/v2 v2.7.0 h1:ZcAr3GYc2LYC8aec2mCMX9+QOF0EolH3jDFKRV/Z1+U=
github.com/oschwald/maxminddb-golang/v2 v2.7.0/go.mod h1:DuKJLbbug6TXC0yJXgs1MWifvXHmudRWzMobMIUu04g=
github.com/parquet-go/bitpack v1.0.0 h1:AUqzlKzPPXf2bCdjfj4sTeacrUwsT7NlcYDMUQxPcQA=
github.com/parquet-go/bitpack v1.0.0/go.mod h1:XnVk9TH+O40eOOmvpAVZ7K2ocQFrQwysLMnc6M/8lgs=
github.com/parquet-go/jsonlite v1.2.0 h1:vr/BuNlMOiUME/uhsTS2xAQL26B+cnfDJBHSQN0z+qI=
Expand Down
Loading