From 14319ada80e083bc1d95125d16b5376f4aee8c9d Mon Sep 17 00:00:00 2001 From: Nathan Oyler Date: Wed, 29 Apr 2026 07:13:00 -0700 Subject: [PATCH] Automate releases with GoReleaser --- .github/workflows/release.yaml | 34 +++++++++++++++++++++++++++++++++ .goreleaser.yaml | 35 +++++++++++++++------------------- 2 files changed, 49 insertions(+), 20 deletions(-) create mode 100644 .github/workflows/release.yaml diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 00000000..e9b8205e --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,34 @@ +# SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company +# +# SPDX-License-Identifier: Apache-2.0 + +name: Release +"on": + push: + tags: + - "v[0-9]+.[0-9]+.[0-9]+" + workflow_dispatch: {} +permissions: + contents: write +jobs: + goreleaser: + name: GoReleaser + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v6 + with: + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v6 + with: + check-latest: true + go-version: 1.26.2 + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v7 + with: + distribution: goreleaser + version: "~> v2" + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 674b11f8..2ad85f71 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -6,34 +6,29 @@ version: 2 archives: - - name_template: '{{ .ProjectName }}-{{ replace .Version "v" "" }}-{{ .Os }}-{{ .Arch }}' - format_overrides: - - goos: windows - format: zip - files: - - CHANGELOG.md - - LICENSE - - README.md + - formats: + - binary + name_template: '{{ if eq .Os "darwin" }}hermescli_darwin{{ else }}hermescli{{ end }}' checksum: - name_template: "checksums.txt" + disable: true builds: - - binary: 'hermescli' + - id: hermescli + # Keep internal build artifact names distinct from the uploaded legacy names + # below, otherwise GoReleaser records duplicate artifact names. + binary: 'hermescli_{{ .Target }}' env: - CGO_ENABLED=0 - goos: - - linux - - windows - - darwin - goarch: - - amd64 - - arm64 - ignore: - - goos: windows - goarch: arm64 + targets: + - linux_amd64_v1 + - windows_amd64_v1 + - darwin_amd64_v1 + flags: + - -mod=vendor ldflags: - -s -w + - -X github.com/sapcc/hermescli/client.Version={{ .Version }} - -X github.com/sapcc/go-api-declarations/bininfo.binName=hermescli - -X github.com/sapcc/go-api-declarations/bininfo.version={{ .Version }} - -X github.com/sapcc/go-api-declarations/bininfo.commit={{ .FullCommit }}