From b99c3c0bea01357611007f2a888e2c6e3172f855 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oswaldo=20Monta=C3=B1o?= Date: Wed, 5 Aug 2026 18:00:55 +0200 Subject: [PATCH] ci: publish a GitHub Release automatically on version tags Pushing a tag created the module version but never the Release, so the repo front page kept advertising the previous version while proxy.golang.org already served the new one. v0.2.0 hit exactly that gap. Triggers on tags matching v*, takes the release notes from the matching CHANGELOG section, and fails loudly if that section is missing rather than publishing an empty release. Tags containing a hyphen are marked prerelease so a release candidate never steals the Latest badge. Uses the preinstalled gh CLI with the job token, no third-party action. --- .github/workflows/release.yml | 48 +++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..dc85f9e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,48 @@ +name: Release + +on: + push: + tags: ['v*'] + +permissions: + contents: write + +jobs: + release: + name: Publish GitHub Release + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Extract release notes from CHANGELOG + run: | + version="${GITHUB_REF_NAME#v}" + awk -v v="$version" ' + $0 == "## [" v "]" || index($0, "## [" v "] ") == 1 { found = 1; next } + found && /^## \[/ { exit } + found && /^\[[^]]+\]: / { exit } + found { print } + ' CHANGELOG.md > release-notes.md + + if [ ! -s release-notes.md ]; then + echo "::error::CHANGELOG.md has no section for [$version]. Add it before tagging." + exit 1 + fi + + - name: Publish release + env: + GH_TOKEN: ${{ github.token }} + run: | + prerelease="" + case "$GITHUB_REF_NAME" in + *-*) prerelease="--prerelease" ;; + *) prerelease="--latest" ;; + esac + + gh release create "$GITHUB_REF_NAME" \ + --verify-tag \ + --title "rhttp $GITHUB_REF_NAME" \ + --notes-file release-notes.md \ + $prerelease