From 9cd219ac880e6219cf167a854ceb7bcb2ac62916 Mon Sep 17 00:00:00 2001 From: Hironori Takahashi Date: Tue, 1 Dec 2026 19:31:42 +0900 Subject: [PATCH] ci: release every main push with an auto-derived semver tag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Consumers pin workflows/actions by SHA, but without tags the version comments had nothing stable to name — zizmor's ref-version-mismatch fired in consumer repos whenever main moved, and renovate had no versions to bump the pins against (renovate-config#76). The bump is derived from conventional commit types since the last tag (breaking -> major, feat -> minor, otherwise patch); the first run tags v1.0.0. Closes #249 --- .github/workflows/release.yml | 50 +++++++++++++++++++++++++++++++++++ README.md | 7 +++-- 2 files changed, 55 insertions(+), 2 deletions(-) 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..f6e7eee --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,50 @@ +name: Release + +permissions: + contents: read + +on: + push: + branches: [main] + +concurrency: + group: release + cancel-in-progress: false + +jobs: + tag: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + # Full history and tags, to compute the next version. + fetch-depth: 0 + + - name: Create the next semver tag and release + env: + GH_TOKEN: ${{ github.token }} + run: | + set -euo pipefail + last=$(git tag --list 'v[0-9]*.[0-9]*.[0-9]*' --sort=-v:refname | head -1) + if [ -z "$last" ]; then + next="v1.0.0" + else + if [ "$(git rev-parse "${last}^{commit}")" = "$GITHUB_SHA" ]; then + echo "HEAD is already released as $last" + exit 0 + fi + IFS=. read -r maj min pat <<<"${last#v}" + git log --format=%s "${last}..HEAD" >/tmp/subjects.txt + git log --format=%b "${last}..HEAD" >/tmp/bodies.txt + if grep -qE '^[a-z]+(\([^)]*\))?!:' /tmp/subjects.txt || grep -q '^BREAKING CHANGE:' /tmp/bodies.txt; then + next="v$((maj + 1)).0.0" + elif grep -qE '^feat(\([^)]*\))?:' /tmp/subjects.txt; then + next="v${maj}.$((min + 1)).0" + else + next="v${maj}.${min}.$((pat + 1))" + fi + fi + gh release create "$next" --target "$GITHUB_SHA" --generate-notes diff --git a/README.md b/README.md index e7361a6..86b21e6 100644 --- a/README.md +++ b/README.md @@ -34,8 +34,11 @@ jobs: ## Versioning -- All workflow references use **SHA pinning** (no `@v1` tags) -- SHA pins are auto-updated by **Renovate** (Dependabot is not used) +- Every push to `main` is tagged and released automatically + ([release.yml](.github/workflows/release.yml)); the semver bump is derived + from the conventional commit types since the last tag +- Consumers reference workflows/actions as `@ # vX.Y.Z`; Renovate bumps + the pins against the tags (Dependabot is not used) ## Composite Actions