Skip to content

Commit 7ee4f86

Browse files
Add GoReleaser config and GitHub Actions release workflow
Adds a backup release path using GoReleaser v2 alongside the existing Makefile targets. Builds 6 binary targets (linux/darwin/windows × amd64/arm64) with SHA256 checksums and draft GitHub releases. New Makefile targets: - goreleaser-release: triggers GitHub Actions workflow via gh CLI - goreleaser-snapshot: local dry run without publishing
1 parent 50f741a commit 7ee4f86

3 files changed

Lines changed: 110 additions & 1 deletion

File tree

.github/workflows/release.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag:
7+
description: 'Git tag to release (e.g., v2.2.0)'
8+
required: true
9+
type: string
10+
push:
11+
tags:
12+
- "v*"
13+
14+
permissions:
15+
contents: write
16+
17+
jobs:
18+
release:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
26+
- name: Set up Go
27+
uses: actions/setup-go@v5
28+
with:
29+
go-version: 'stable'
30+
31+
- name: Determine version
32+
run: |
33+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
34+
echo "GORELEASER_CURRENT_TAG=${{ inputs.tag }}" >> "$GITHUB_ENV"
35+
fi
36+
37+
- name: Run GoReleaser
38+
uses: goreleaser/goreleaser-action@v7
39+
with:
40+
distribution: goreleaser
41+
version: "~> v2"
42+
args: release --clean
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.goreleaser.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
version: 2
2+
project_name: cf-targets-plugin
3+
4+
before:
5+
hooks:
6+
- go mod tidy
7+
- gofmt -l -e .
8+
- go vet ./...
9+
- go test -race ./...
10+
11+
builds:
12+
- main: .
13+
binary: cf-targets-plugin
14+
env:
15+
- CGO_ENABLED=0
16+
goos:
17+
- linux
18+
- darwin
19+
- windows
20+
goarch:
21+
- amd64
22+
- arm64
23+
ldflags:
24+
- -X 'main.SemVerMajor={{ .Major }}'
25+
- -X 'main.SemVerMinor={{ .Minor }}'
26+
- -X 'main.SemVerPatch={{ .Patch }}'
27+
- -X 'main.SemVerPrerelease={{ .Prerelease }}'
28+
- -X 'main.SemVerBuild='
29+
- -X 'main.BuildDate={{ .Date }}'
30+
- -X 'main.BuildVcsUrl={{ .GitURL }}'
31+
- -X 'main.BuildVcsId={{ .ShortCommit }}'
32+
- -X 'main.BuildVcsIdDate={{ .CommitDate }}'
33+
- -X 'main.GoOs={{ .Os }}'
34+
- -X 'main.GoArch={{ .Arch }}'
35+
36+
archives:
37+
- formats: [binary]
38+
name_template: >-
39+
{{ .ProjectName }}-{{ .Version }}+{{ .Os }}.{{ .Arch }}
40+
41+
checksum:
42+
name_template: "checksums.txt"
43+
algorithm: sha256
44+
45+
release:
46+
github:
47+
owner: cloudfoundry-community
48+
name: cf-targets-plugin
49+
draft: true
50+
prerelease: auto
51+
name_template: "v{{ .Version }}"
52+
53+
changelog:
54+
sort: asc
55+
filters:
56+
exclude:
57+
- "^docs:"
58+
- "^test:"
59+
- "^chore:"

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ verify: tidy check test security ## Run all checks before commit
179179

180180
##@ Release
181181

182-
.PHONY: ci-release release-all release-clean show-releases create-repo-index
182+
.PHONY: ci-release release-all release-clean show-releases create-repo-index goreleaser-release goreleaser-snapshot
183183

184184
require-%:
185185
@ if [ "${${*}}" = "" ]; then \
@@ -202,6 +202,12 @@ create-repo-index: $(RELEASE_ROOT)/repo-index.yml
202202
$(RELEASE_ROOT)/repo-index.yml: $(RELEASES) generate-repo-index
203203
./generate-repo-index "$(RELEASE_ROOT)" "$(PROJECT)" "$(SEMVER_VERSION)" "$(BUILD_DATE)"
204204

205+
goreleaser-release: require-VERSION ## Trigger GitHub Actions release workflow (requires VERSION=x.y.z)
206+
gh workflow run release.yml -f tag=v$(VERSION)
207+
208+
goreleaser-snapshot: ## Local GoReleaser dry run (no publish)
209+
goreleaser release --snapshot --clean
210+
205211
distbuild:
206212
@mkdir -p $(RELEASE_ROOT)
207213

0 commit comments

Comments
 (0)