From c30546785fcdf877bcf7bbc19644ef6c1962e756 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Wed, 22 Apr 2026 23:18:21 -0700 Subject: [PATCH] fix(release): publish release drafter notes --- .github/release-drafter.yml | 20 +++++++++++--- .github/workflows/release-drafter.yml | 6 ++++- .github/workflows/release.yml | 39 ++++++++++++++++++++++++--- docs/distribution.md | 17 +++++------- 4 files changed, 62 insertions(+), 20 deletions(-) diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index 5b514b2..bf6828d 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -66,6 +66,12 @@ autolabeler: - label: "feat" title: - '/^feat(\(.+\))?:/i' + - label: "feature" + title: + - '/^feature(\(.+\))?:/i' + - label: "enhancement" + title: + - '/^enhancement(\(.+\))?:/i' - label: "fix" title: - '/^fix(\(.+\))?:/i' @@ -90,15 +96,21 @@ autolabeler: - label: "test" title: - '/^test(\(.+\))?:/i' + - label: "tests" + title: + - '/^tests(\(.+\))?:/i' - label: "chore" title: - '/^chore(\(.+\))?:/i' + - label: "dep" + title: + - '/^dep(\(.+\))?:/i' + - label: "deps" + title: + - '/^deps(\(.+\))?:/i' - label: "dependencies" title: - - '/^(dep|deps|dependencies)(\(.+\))?:/i' - - label: "other" - title: - - '/.*/' + - '/^dependencies(\(.+\))?:/i' template: | ## notcrawl v$RESOLVED_VERSION diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index bc3a400..3220e8b 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -1,6 +1,9 @@ name: Release Drafter on: + push: + branches: + - main workflow_dispatch: pull_request_target: types: @@ -28,7 +31,8 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} update_release_draft: - if: github.event_name == 'workflow_dispatch' + name: Update Release Draft + if: github.event_name != 'pull_request_target' runs-on: ubuntu-latest steps: - name: Draft release notes diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b9b064a..55c5fd9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,6 +12,7 @@ on: type: string permissions: + actions: write contents: write env: @@ -36,20 +37,50 @@ jobs: - name: Run tests run: go test ./... - - name: Build release notes + - name: Resolve release metadata env: TAG: ${{ inputs.tag_name || github.ref_name }} - run: scripts/release-notes.sh "${TAG}" > /tmp/release-notes.md + run: | + set -euo pipefail + if [[ ! "${TAG}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+([.-][0-9A-Za-z]+)*$ ]]; then + echo "Invalid release tag: ${TAG}" + exit 1 + fi + echo "RELEASE_TAG=${TAG}" >> "$GITHUB_ENV" + echo "RELEASE_VERSION=${TAG#v}" >> "$GITHUB_ENV" - - name: Run GoReleaser + - name: Build release artifacts uses: goreleaser/goreleaser-action@v6 with: distribution: goreleaser version: "~> v2" - args: release --clean --release-notes=/tmp/release-notes.md + args: release --clean --skip=publish env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Publish release from Release Drafter + uses: release-drafter/release-drafter@v7 + with: + publish: true + tag: ${{ env.RELEASE_TAG }} + version: ${{ env.RELEASE_VERSION }} + name: "notcrawl ${{ env.RELEASE_TAG }}" + prerelease: ${{ contains(env.RELEASE_TAG, 'beta') || contains(env.RELEASE_TAG, 'alpha') || contains(env.RELEASE_TAG, 'rc') }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Upload release assets + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + set -euo pipefail + gh release upload "${RELEASE_TAG}" \ + dist/*.tar.gz \ + dist/*.deb \ + dist/*.rpm \ + dist/sha256sums.txt \ + --clobber + - name: Evaluate Cloudsmith configuration env: CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }} diff --git a/docs/distribution.md b/docs/distribution.md index cfc1b4c..0ccbb02 100644 --- a/docs/distribution.md +++ b/docs/distribution.md @@ -8,7 +8,6 @@ Cloudsmith APT/RPM repositories. ```bash go test ./... go build ./cmd/notcrawl -make release-notes TAG=v0.1.0 ``` If GoReleaser is installed: @@ -22,13 +21,9 @@ under `dist/` without publishing. ## Release Notes -Generate local notes from conventional commits: - -```bash -scripts/release-notes.sh v0.1.0 -``` - -GitHub also uses Release Drafter to label PRs and maintain draft release notes. +GitHub uses Release Drafter to auto-label PRs and generate release notes from +merged pull requests. The release workflow publishes the Release Drafter output +for the pushed tag, then uploads the GoReleaser artifacts to that release. ## Tagged Release @@ -42,9 +37,9 @@ git push origin v0.1.0 The release workflow: 1. runs tests -2. generates release notes -3. builds GoReleaser artifacts -4. publishes GitHub release assets +2. builds GoReleaser artifacts +3. publishes Release Drafter notes for the tag +4. uploads GitHub release assets 5. optionally publishes APT/RPM packages to Cloudsmith 6. updates the Homebrew tap