mirror of
https://github.com/lukaszraczylo/shared-actions.git
synced 2026-06-08 22:59:26 +00:00
a4cf065ea1
Before tagging, fold any working-tree changes left by a repo-local workflow-prepare.sh (e.g. version stamping) into the tagged commit. Without this the tag captured the unstamped source AND GoReleaser's 'release --clean' failed on the dirty tree. The commit is reachable only via the tag (the branch is not pushed), so a 0.0.0-dev placeholder on main is preserved. No-op when the tree is clean, so repos that do not stamp are unaffected.
90 lines
3.0 KiB
YAML
90 lines
3.0 KiB
YAML
name: "GoReleaser"
|
|
description: "Run GoReleaser with optional split/merge for CGO builds"
|
|
|
|
inputs:
|
|
version-tag:
|
|
description: "Version tag to release"
|
|
required: true
|
|
mode:
|
|
description: "Mode: 'full' (single runner), 'split' (matrix build), 'merge' (combine split builds)"
|
|
required: false
|
|
default: "full"
|
|
cgo-enabled:
|
|
description: "Enable CGO"
|
|
required: false
|
|
default: "0"
|
|
github-token:
|
|
description: "GitHub token"
|
|
required: true
|
|
goreleaser-key:
|
|
description: "GoReleaser Pro license key (for split/merge)"
|
|
required: false
|
|
default: ""
|
|
homebrew-tap-token:
|
|
description: "Homebrew tap token (optional)"
|
|
required: false
|
|
default: ""
|
|
|
|
runs:
|
|
using: "composite"
|
|
steps:
|
|
- name: Create tag
|
|
shell: bash
|
|
run: |
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
# Fold any build-time source changes (e.g. version stamping by a
|
|
# repo-local workflow-prepare.sh) into the tagged commit. This is needed
|
|
# so consumers that fetch the tag's SOURCE — e.g. Yaegi-interpreted
|
|
# Traefik plugins, which Traefik never compiles — see the stamped value,
|
|
# and so GoReleaser's `release --clean` sees a clean working tree. The
|
|
# commit is reachable only via the tag; the branch is NOT advanced, so a
|
|
# source-tree placeholder (e.g. 0.0.0-dev on main) is preserved. No-op
|
|
# when the tree is already clean → unchanged for repos that don't stamp.
|
|
if ! git diff --quiet || ! git diff --cached --quiet; then
|
|
git add -A
|
|
git commit -m "chore(release): ${{ inputs.version-tag }}"
|
|
fi
|
|
git tag -a ${{ inputs.version-tag }} -m "Release ${{ inputs.version-tag }}" || true
|
|
if [[ "${{ inputs.mode }}" != "split" ]]; then
|
|
git push origin ${{ inputs.version-tag }} || true
|
|
fi
|
|
|
|
- name: Install cosign
|
|
uses: sigstore/cosign-installer@v4.1.2
|
|
|
|
- name: Run GoReleaser (full)
|
|
if: inputs.mode == 'full'
|
|
uses: goreleaser/goreleaser-action@v7
|
|
with:
|
|
distribution: goreleaser
|
|
version: "~> v2"
|
|
args: release --clean
|
|
env:
|
|
GITHUB_TOKEN: ${{ inputs.github-token }}
|
|
HOMEBREW_TAP_TOKEN: ${{ inputs.homebrew-tap-token }}
|
|
CGO_ENABLED: ${{ inputs.cgo-enabled }}
|
|
|
|
- name: Run GoReleaser Pro (split)
|
|
if: inputs.mode == 'split'
|
|
uses: goreleaser/goreleaser-action@v7
|
|
with:
|
|
distribution: goreleaser-pro
|
|
version: "~> v2"
|
|
args: release --clean --split
|
|
env:
|
|
GITHUB_TOKEN: ${{ inputs.github-token }}
|
|
GORELEASER_KEY: ${{ inputs.goreleaser-key }}
|
|
CGO_ENABLED: ${{ inputs.cgo-enabled }}
|
|
|
|
- name: Run GoReleaser Pro (merge)
|
|
if: inputs.mode == 'merge'
|
|
uses: goreleaser/goreleaser-action@v7
|
|
with:
|
|
distribution: goreleaser-pro
|
|
version: "~> v2"
|
|
args: continue --merge
|
|
env:
|
|
GITHUB_TOKEN: ${{ inputs.github-token }}
|
|
GORELEASER_KEY: ${{ inputs.goreleaser-key }}
|