From 2a19a886a9433e5c23aa84ca6932ec28aa22f0d7 Mon Sep 17 00:00:00 2001 From: Monty Guilhaus Date: Wed, 6 May 2026 04:08:59 +0000 Subject: [PATCH] Add reusable goreleaser-release workflow Adds a workflow_call-only workflow that runs GoReleaser against a caller repo. Generalises the standalone goreleaser.yml currently used in seictl into a maintained, versioned uci primitive that any sei-protocol repo can call. Inputs cover the variation we already see across consumers: - go-version / go-version-file (mutually exclusive) - goreleaser-version, args, working-directory - ref, checkout-latest-tag (workflow_run pattern) - submodules, fetch-depth, runs-on - prebuild-script for repo-specific system deps Token defaults to github.token; an UCI_GITHUB_TOKEN secret may override. --- .github/workflows/goreleaser-release.yml | 108 +++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 .github/workflows/goreleaser-release.yml diff --git a/.github/workflows/goreleaser-release.yml b/.github/workflows/goreleaser-release.yml new file mode 100644 index 0000000..0b78be3 --- /dev/null +++ b/.github/workflows/goreleaser-release.yml @@ -0,0 +1,108 @@ +name: GoReleaser +run-name: UCI / GoReleaser Release +on: + workflow_call: + inputs: + go-version: + description: "Go version. Mutually exclusive with go-version-file." + required: false + type: string + default: '' + go-version-file: + description: "Path to go.mod (or other) for Go version detection. Mutually exclusive with go-version." + required: false + type: string + default: '' + goreleaser-version: + description: "GoReleaser version expression (e.g. '~> v2', 'v2.4.4', 'latest', 'nightly')." + required: false + type: string + default: '~> v2' + args: + description: "Arguments passed to goreleaser." + required: false + type: string + default: 'release --clean' + working-directory: + description: "Repo subdirectory containing .goreleaser.yaml." + required: false + type: string + default: '.' + ref: + description: "Git ref to checkout. Empty checks out the triggering ref." + required: false + type: string + default: '' + checkout-latest-tag: + description: "After checkout, switch to the latest tag (sorted by v:refname). Useful when triggered by workflow_run." + required: false + type: boolean + default: false + submodules: + description: "Submodule checkout option, passed to actions/checkout (false | true | recursive)." + required: false + type: string + default: 'false' + fetch-depth: + description: "Fetch depth for actions/checkout. 0 = full history (required by GoReleaser to compute changelog)." + required: false + type: number + default: 0 + runs-on: + description: "Runner label." + required: false + type: string + default: 'ubuntu-latest' + prebuild-script: + description: "Inline shell run after checkout, before goreleaser. Use for system deps or per-repo prep." + required: false + type: string + default: '' + secrets: + UCI_GITHUB_TOKEN: + description: "Optional override for the token used to create the GitHub Release. Defaults to github.token." + required: false + +permissions: + contents: write + +jobs: + goreleaser: + name: Publish + runs-on: ${{ inputs.runs-on }} + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + fetch-depth: ${{ inputs.fetch-depth }} + ref: ${{ inputs.ref }} + submodules: ${{ inputs.submodules }} + - name: Checkout latest tag + if: inputs.checkout-latest-tag + run: | + git fetch origin --tags --force + LATEST_TAG=$(git tag --sort=-v:refname | head -n 1) + if [[ -z "${LATEST_TAG}" ]]; then + echo "::error::no tags present in repo" + exit 1 + fi + echo "Checking out latest tag: ${LATEST_TAG}" + git checkout "${LATEST_TAG}" + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version: ${{ inputs.go-version }} + go-version-file: ${{ inputs.go-version-file }} + - name: Run prebuild script + if: inputs.prebuild-script != '' + working-directory: ${{ inputs.working-directory }} + run: ${{ inputs.prebuild-script }} + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v6 + with: + distribution: goreleaser + version: ${{ inputs.goreleaser-version }} + args: ${{ inputs.args }} + workdir: ${{ inputs.working-directory }} + env: + GITHUB_TOKEN: ${{ secrets.UCI_GITHUB_TOKEN || github.token }}