diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml index eee8ca1..d7b8d23 100644 --- a/.gitea/workflows/release.yaml +++ b/.gitea/workflows/release.yaml @@ -1,7 +1,8 @@ name: release -# Runs for release tags, which `make release` creates. The image of a tag -# is built by the ci workflow. +# Runs for release tags, which `make release` creates. Only the Owners team +# may push v* tags (tag protection), and only tags on main are released. +# The image of a tag is built by the ci workflow. on: push: tags: ["v*"] @@ -20,7 +21,16 @@ jobs: curl -fsSL "https://go.dev/dl/go${v}.linux-amd64.tar.gz" | tar -C /usr/local -xz echo /usr/local/go/bin >> "$GITHUB_PATH" - name: Check tag - run: go run ./tools/release check "$GITHUB_REF_NAME" + run: | + go run ./tools/release check "$GITHUB_REF_NAME" + # Only code that reached main through a protected merge is + # released, this workflow included: a tag on any other commit, + # e.g. one with a changed workflow, publishes nothing. + git fetch -q origin main + if ! git merge-base --is-ancestor "$GITHUB_SHA" origin/main; then + echo "::error::$GITHUB_REF_NAME does not point to a commit on main; not releasing." + exit 1 + fi - name: Build frontend run: npm ci --no-audit --no-fund && npm run build - name: Build binaries