TExcelTAD
Home › Release Engineering & CI/CD › A Tag-Driven Release Workflow

A Tag-Driven Release Workflow

This lesson puts the previous ones together into the workflow most projects need: push a tag → build every platform → generate the notes → checksums → publish a GitHub Release. The YAML is non-run; the logic inside it is rehearsed for real against a local repository, and the GitHub CLI's own help confirms the flags used.

The workflow

yaml
# .github/workflows/release.yml
name: release
on:
  push:
    tags: ['v[0-9]+.[0-9]+.[0-9]+*']

permissions:
  contents: read

concurrency:
  group: release-${{ github.ref }}
  cancel-in-progress: false            # never interrupt a release halfway

jobs:
  build:
    strategy:
      fail-fast: true                  # one broken platform = no release
      matrix:
        include:
          - { target: linux-x86_64,   runner: ubuntu-24.04,     ext: tar.gz }
          - { target: linux-aarch64,  runner: ubuntu-24.04-arm, ext: tar.gz }
          - { target: macos-arm64,    runner: macos-15,         ext: zip }
          - { target: windows-x86_64, runner: windows-2025,     ext: zip }
    runs-on: ${{ matrix.runner }}
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1          # v7.0.1
        with:
          persist-credentials: false
      - name: Build and package
        shell: bash
        env:
          VERSION: ${{ github.ref_name }}
          TARGET: ${{ matrix.target }}
          EXT: ${{ matrix.ext }}
        run: ./scripts/package.sh "${VERSION#v}" "$TARGET" "$EXT"    # -> dist/tad-<version>-<target>.<ext>
      - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9   # v7.0.2
        with:
          name: dist-${{ matrix.target }}
          path: dist/*
          if-no-files-found: error

  release:
    needs: build
    runs-on: ubuntu-24.04
    environment: release               # optional approval gate
    permissions:
      contents: write                  # create the release and upload assets
      id-token: write                  # artifact attestations (Sigstore)
      attestations: write
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1          # v7.0.1
        with:
          fetch-depth: 0               # git-cliff needs history and tags
          persist-credentials: false
      - uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
        with:
          pattern: dist-*
          merge-multiple: true
          path: dist
      - name: Checksums
        run: cd dist && sha256sum * > SHA256SUMS
      - uses: actions/attest-build-provenance@v4      # pin by SHA like the others in real use
        with:
          subject-path: dist/*
      - name: Release notes
        run: |
          git-cliff --latest --strip all > NOTES.md   # install git-cliff first, e.g. with its official action
          test -s NOTES.md                            # fail on empty notes
      - name: Publish
        env:
          GH_TOKEN: ${{ github.token }}
          TAG: ${{ github.ref_name }}
        run: |
          prerelease=""
          case "$TAG" in *-*) prerelease="--prerelease";; esac
          gh release create "$TAG" dist/* --verify-tag --title "$TAG" --notes-file NOTES.md $prerelease

Design decisions, each from an earlier lesson:

Decision Why Lesson
trigger on tags only, with a strict pattern the tag is the release; v1.2.3-rc.1 matches too and becomes a pre-release Workflows & Triggers
fail-fast: true in the build matrix a missing platform should stop the release, not produce a partial one Matrix Builds
build jobs have read-only tokens; only release can write build scripts and dependencies never see a write token Permissions, OIDC & Pinning
$VERSION/$TARGET passed through env: no expression interpolation inside scripts same
artifacts, not caches the release consumes exactly what this run built Caching & Artifacts
--verify-tag gh release create would otherwise create a missing tag from the default branch below
concurrency without cancel a running release finishes Environments, Approvals & Concurrency

Checking the gh flags

gh needs the network and a token for API calls, but its help is offline, and it is the authoritative list of flags for the installed version (2.103.1):

bash · try it yourself
gh --version | head -1
gh release create --help | grep -E -- '^ +(-[a-zA-Z], )? *--(verify-tag|notes-file|generate-notes|prerelease|draft|latest|target|title|fail-on-no-commits) '
echo "---"
gh release create --help | sed -n '/^If a matching git tag/,/^Use `--verify-tag`/p'
echo "--- without credentials"
gh release create v1.4.2 --repo acme/tad --notes "test"; echo "exit code: $?"
gh version 2.103.1 (2026-10-23)
  -d, --draft                        Save the release as a draft instead of publishing it
      --fail-on-no-commits           Fail if there are no commits since the last release (no impact on the first release)
      --generate-notes               Automatically generate title and notes for the release via GitHub Release Notes API
      --latest                       Mark this release as "Latest" (default [automatic based on date and version]). --latest=false to explicitly NOT set as latest
  -F, --notes-file file              Read release notes from file (use "-" to read from standard input)
  -p, --prerelease                   Mark the release as a prerelease
      --target branch                Target branch or full commit SHA (default [main branch])
  -t, --title string                 Release title
      --verify-tag                   Abort in case the git tag doesn't already exist in the remote repository
---
If a matching git tag does not yet exist, one will automatically get created
from the latest state of the default branch.
Use `--target` to point to a different branch or commit for the automatic tag creation.
Use `--verify-tag` to abort the release if the tag doesn't already exist.
--- without credentials
To get started with GitHub CLI, please run:  gh auth login
Alternatively, populate the GH_TOKEN environment variable with a GitHub API authentication token.
exit code: 4

The help text states the trap that --verify-tag avoids: without it, a typo in the tag name silently creates a new tag from the default branch. The last command shows that no API call happens without credentials (exit code 4); in Actions, GH_TOKEN: ${{ github.token }} provides them.

Rehearsing the release job locally

Everything in the release job except the upload can run on any machine. Rehearsing it against a local repository with a bare "remote" catches most mistakes before they cost a broken release. The four platform archives stand in for the build jobs' artifacts:

bash · try it yourself
git init -q --bare remote.git
git clone -q remote.git tad 2>/dev/null && cd tad
git-cliff --init >/dev/null 2>&1 && git add cliff.toml
git commit -q -m "feat: first public version" && git tag -a v1.3.0 -m "v1.3.0"
git commit -q --allow-empty -m "fix(io): close files on error"
git commit -q --allow-empty -m "feat(cli): add --json output"
git tag -a v1.4.0 -m "v1.4.0" && git push -q origin main v1.3.0 v1.4.0

# ---- the release job, as CI would run it on the tag ----
TAG=v1.4.0
git ls-remote --exit-code origin "refs/tags/$TAG" >/dev/null && echo "tag $TAG exists on the remote"
mkdir -p dist
for target in linux-x86_64 linux-aarch64 macos-arm64 windows-x86_64; do   # stand-ins for the build artifacts
  ext=tar.gz; [[ $target == windows-* || $target == macos-* ]] && ext=zip
  git archive --prefix="tad-${TAG#v}/" -o "dist/tad-${TAG#v}-$target.$ext" "$TAG"
done
(cd dist && sha256sum * > SHA256SUMS)
git-cliff --latest --strip all > NOTES.md
test -s NOTES.md && echo "notes: $(grep -c '^- ' NOTES.md) entries"
prerelease=""; case "$TAG" in *-*) prerelease="--prerelease";; esac
echo "would run: gh release create $TAG $(cd dist && echo *) --verify-tag --title $TAG --notes-file NOTES.md $prerelease"
echo "--- NOTES.md"
cat NOTES.md
echo "--- SHA256SUMS lines: $(wc -l < dist/SHA256SUMS)"
(cd dist && sha256sum -c --quiet SHA256SUMS) && echo "all checksums verify"
tag v1.4.0 exists on the remote
notes: 2 entries
would run: gh release create v1.4.0 SHA256SUMS tad-1.4.0-linux-aarch64.tar.gz tad-1.4.0-linux-x86_64.tar.gz tad-1.4.0-macos-arm64.zip tad-1.4.0-windows-x86_64.zip --verify-tag --title v1.4.0 --notes-file NOTES.md
--- NOTES.md
## [1.4.0] - 2026-01-15

### 🚀 Features

- *(cli)* Add --json output

### 🐛 Bug Fixes

- *(io)* Close files on error
--- SHA256SUMS lines: 4
all checksums verify

git archive can write .zip as well as .tar.gz (it picks the format from the file extension), so the stand-ins have the right formats.

Variations

  • Draft first: gh release create … --draft, upload, verify (download and sha256sum -c), then gh release edit "$TAG" --draft=false. With immutable releases enabled for the repository, publishing locks the tag and assets, so verifying the draft before publishing becomes the natural flow.
  • Release tools instead of the notes step: semantic-release (with @semantic-release/github) or changesets' action can create the tag and the release; then the build matrix runs on release: published or as a needs job in the same workflow, not on the tag push (semantic-release, Changesets).
  • Containers: add a job that builds and pushes ghcr.io/acme/tad:1.4.0 with docker/build-push-action@v7 and the same version; see Docker in CI/CD.
  • Game stores: replace the publish step with butler push or steamcmd; see GitHub Actions & GameCI.

Test yourself

What does --verify-tag protect against in gh release create?

  1. Unsigned tags
  2. Creating a brand-new tag from the default branch when the given tag doesn't exist
  3. Duplicate assets
  4. Missing notes

Why does only the final release job get contents: write?

  1. Build jobs don't need tokens
  2. So build scripts and third-party dependencies never run with a write token
  3. GitHub allows only one writer
  4. It is faster

How does the workflow decide to mark v2.0.0-rc.1 as a pre-release?

  1. GitHub detects it
  2. A shell case on the tag: anything with a - gets --prerelease
  3. From the changelog
  4. It doesn't