From 3ed53c9480c5aa0dba60f7d557dd0a66a9920a71 Mon Sep 17 00:00:00 2001 From: darxnet Date: Fri, 13 Nov 2026 14:35:27 +0100 Subject: [PATCH] ci: release from commit subjects only, without svu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit svu v2 matched feat:, fix: and BREAKING CHANGE: anywhere in the log, bodies included, and Dependabot puts the changelogs of its updates in the body: chore and ci merges released versions, minor ones among them (gogram v0.13.0 and v0.14.5, gocopy v1.1.0, goreset v1.4.0). A feat!: in such a changelog would have tagged v2.0.0 on a v1 module. The version now comes from the subjects since the last tag: feat → minor, fix → patch, type!: → minor while on v0, nothing else releases. A breaking change on v1+ fails the job, as it needs a /vN module path. The release is created on the commit that passed CI, and the workflow is the same in every repository. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release.yml | 39 +++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 08bc929..4862448 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,27 +24,40 @@ jobs: name: Release needs: ci runs-on: ubuntu-latest + timeout-minutes: 10 steps: - uses: actions/checkout@v7 with: fetch-depth: 0 - - uses: actions/setup-go@v7 - with: - go-version-file: go.mod - cache: true - - - name: Install svu - run: go install github.com/caarlos0/svu/v2@latest - - name: Create Release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - NEXT=$(svu next) - if [ "$(svu current)" == "$NEXT" ]; then - echo "Version $NEXT already exists, skipping release." + # The version comes from the Conventional Commit subjects since the + # last tag, never from bodies: Dependabot puts the changelogs of its + # updates there, "fix:" and "BREAKING CHANGE:" lines included. + # feat → minor, fix → patch, "type!:" → minor while on v0; nothing + # else releases. The first tag is created by hand. + TAG=$(git describe --tags --abbrev=0 --match 'v[0-9]*.[0-9]*.[0-9]*') || { + echo "No release tag yet, skipping release." + exit 0 + } + SUBJECTS=$(git log --format=%s "$TAG..HEAD") + IFS=. read -r MAJOR MINOR PATCH <<<"${TAG#v}" + if grep -qE '^[a-z]+(\([^)]*\))?!:' <<<"$SUBJECTS"; then + if [ "$MAJOR" -ne 0 ]; then + echo "::error::A breaking change after $TAG needs a /v$((MAJOR + 1)) module path; release it by hand." + exit 1 + fi + NEXT="v0.$((MINOR + 1)).0" + elif grep -qE '^feat(\([^)]*\))?:' <<<"$SUBJECTS"; then + NEXT="v$MAJOR.$((MINOR + 1)).0" + elif grep -qE '^fix(\([^)]*\))?:' <<<"$SUBJECTS"; then + NEXT="v$MAJOR.$MINOR.$((PATCH + 1))" else - echo "Releasing $NEXT..." - gh release create "$NEXT" --generate-notes + echo "No feat, fix or breaking change since $TAG, skipping release." + exit 0 fi + echo "Releasing $NEXT..." + gh release create "$NEXT" --target "$GITHUB_SHA" --generate-notes