Skip to content

Commit 20a5bcb

Browse files
CI: Fix release workflow (#234)
1 parent ccfc397 commit 20a5bcb

File tree

4 files changed

+298
-33
lines changed

4 files changed

+298
-33
lines changed

.github/workflows/release.yml

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,14 @@ jobs:
2727
uses: actions/checkout@v4
2828
with:
2929
fetch-depth: 0
30-
- run: git tag ${{ github.event.inputs.tag }}
30+
31+
- name: Create and push tag
32+
if: github.event.inputs.tag
33+
run: |
34+
git config user.name "github-actions[bot]"
35+
git config user.email "github-actions[bot]@users.noreply.github.com"
36+
git tag ${{ github.event.inputs.tag }}
37+
git push origin ${{ github.event.inputs.tag }}
3138
3239
- name: Setup pnpm
3340
uses: pnpm/action-setup@v4
@@ -55,11 +62,16 @@ jobs:
5562
- name: Run tests
5663
run: go test ./...
5764

58-
- name: Run GoReleaser
59-
uses: goreleaser/goreleaser-action@v6
60-
with:
61-
distribution: goreleaser
62-
version: latest
63-
args: release --clean
64-
env:
65-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65+
- name: Set up Docker Buildx
66+
uses: docker/setup-buildx-action@v3
67+
68+
- name: Run GoReleaser with goreleaser-cross
69+
run: |
70+
docker run --rm --privileged \
71+
-v ${{ github.workspace }}:/go/src/github.com/kevinanielsen/go-fast-cdn \
72+
-v /var/run/docker.sock:/var/run/docker.sock \
73+
-w /go/src/github.com/kevinanielsen/go-fast-cdn \
74+
-e GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} \
75+
-e CGO_ENABLED=1 \
76+
goreleaser/goreleaser-cross:v1.27.0 \
77+
release --clean

.goreleaser.yaml

Lines changed: 158 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
version: 2
2+
13
project_name: go-fast-cdn
24

35
dist: .dist
@@ -7,24 +9,161 @@ before:
79
- go mod tidy
810

911
builds:
10-
- env:
11-
- CGO_ENABLED=0
12+
- id: linux-amd64
1213
binary: go-fast-cdn
14+
env:
15+
- CGO_ENABLED=1
16+
- CC=x86_64-linux-gnu-gcc
17+
- CXX=x86_64-linux-gnu-g++
1318
goos:
1419
- linux
15-
- windows
16-
- darwin
1720
goarch:
1821
- amd64
22+
mod_timestamp: '{{ .CommitTimestamp }}'
23+
flags:
24+
- -trimpath
25+
ldflags:
26+
- -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} -X main.builtBy=goreleaser
27+
28+
- id: linux-arm64
29+
binary: go-fast-cdn
30+
env:
31+
- CGO_ENABLED=1
32+
- CC=aarch64-linux-gnu-gcc
33+
- CXX=aarch64-linux-gnu-g++
34+
goos:
35+
- linux
36+
goarch:
1937
- arm64
38+
mod_timestamp: '{{ .CommitTimestamp }}'
39+
flags:
40+
- -trimpath
41+
ldflags:
42+
- -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} -X main.builtBy=goreleaser
43+
44+
- id: linux-armv7
45+
binary: go-fast-cdn
46+
env:
47+
- CGO_ENABLED=1
48+
- CC=arm-linux-gnueabihf-gcc
49+
- CXX=arm-linux-gnueabihf-g++
50+
goos:
51+
- linux
52+
goarch:
2053
- arm
2154
goarm:
2255
- 7
23-
ignore:
24-
- goos: windows
25-
goarch: arm
26-
- goos: darwin
27-
goarch: arm
56+
mod_timestamp: '{{ .CommitTimestamp }}'
57+
flags:
58+
- -trimpath
59+
ldflags:
60+
- -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} -X main.builtBy=goreleaser
61+
62+
- id: darwin-amd64
63+
binary: go-fast-cdn
64+
env:
65+
- CGO_ENABLED=1
66+
- CC=o64-clang
67+
- CXX=o64-clang++
68+
goos:
69+
- darwin
70+
goarch:
71+
- amd64
72+
mod_timestamp: '{{ .CommitTimestamp }}'
73+
flags:
74+
- -trimpath
75+
ldflags:
76+
- -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} -X main.builtBy=goreleaser
77+
78+
- id: darwin-arm64
79+
binary: go-fast-cdn
80+
env:
81+
- CGO_ENABLED=1
82+
- CC=oa64-clang
83+
- CXX=oa64-clang++
84+
goos:
85+
- darwin
86+
goarch:
87+
- arm64
88+
mod_timestamp: '{{ .CommitTimestamp }}'
89+
flags:
90+
- -trimpath
91+
ldflags:
92+
- -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} -X main.builtBy=goreleaser
93+
94+
- id: windows-amd64
95+
binary: go-fast-cdn
96+
env:
97+
- CGO_ENABLED=1
98+
- CC=x86_64-w64-mingw32-gcc
99+
- CXX=x86_64-w64-mingw32-g++
100+
goos:
101+
- windows
102+
goarch:
103+
- amd64
104+
mod_timestamp: '{{ .CommitTimestamp }}'
105+
flags:
106+
- -trimpath
107+
ldflags:
108+
- -s -w -X main.version={{.Version}} -X main.commit={{.Commit}} -X main.date={{.Date}} -X main.builtBy=goreleaser
109+
110+
archives:
111+
- id: linux-amd64
112+
builds:
113+
- linux-amd64
114+
name_template: "{{ .ProjectName }}_{{ .Version }}_linux_amd64"
115+
format: zip
116+
files:
117+
- LICENSE*
118+
- README*
119+
120+
- id: linux-arm64
121+
builds:
122+
- linux-arm64
123+
name_template: "{{ .ProjectName }}_{{ .Version }}_linux_arm64"
124+
format: zip
125+
files:
126+
- LICENSE*
127+
- README*
128+
129+
- id: linux-armv7
130+
builds:
131+
- linux-armv7
132+
name_template: "{{ .ProjectName }}_{{ .Version }}_linux_armv7"
133+
format: zip
134+
files:
135+
- LICENSE*
136+
- README*
137+
138+
- id: darwin-amd64
139+
builds:
140+
- darwin-amd64
141+
name_template: "{{ .ProjectName }}_{{ .Version }}_darwin_amd64"
142+
format: zip
143+
files:
144+
- LICENSE*
145+
- README*
146+
147+
- id: darwin-arm64
148+
builds:
149+
- darwin-arm64
150+
name_template: "{{ .ProjectName }}_{{ .Version }}_darwin_arm64"
151+
format: zip
152+
files:
153+
- LICENSE*
154+
- README*
155+
156+
- id: windows-amd64
157+
builds:
158+
- windows-amd64
159+
name_template: "{{ .ProjectName }}_{{ .Version }}_windows_amd64"
160+
format: zip
161+
files:
162+
- LICENSE*
163+
- README*
164+
165+
checksum:
166+
name_template: "{{ .ProjectName }}_{{ .Version }}_checksums.txt"
28167

29168
release:
30169
target_commitish: '{{ .Commit }}'
@@ -33,15 +172,19 @@ release:
33172
owner: kevinanielsen
34173
name: go-fast-cdn
35174

36-
archives:
37-
- format: zip
38-
files:
39-
- LICENSE*
40-
- CHANGELOG*
41-
42175
changelog:
43176
sort: asc
177+
use: git
44178
filters:
45179
exclude:
46180
- "^docs:"
47181
- "^test:"
182+
- "^chore"
183+
- "merge conflict"
184+
- Merge pull request
185+
- Merge remote-tracking branch
186+
- Merge branch
187+
- go mod tidy
188+
189+
metadata:
190+
mod_timestamp: '{{ .CommitTimestamp }}'

Makefile

Lines changed: 70 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,30 @@ BINARY_NAME=go-fast-cdn
22
OS_NAME := $(shell uname -s | tr A-Z a-z)
33
ARCH := $(shell uname -m | tr A-Z a-z | sed 's/^aarch/arm/' | sed 's/^x86_64/amd64/')
44

5-
prep:
5+
.PHONY: help prep build build_ui build_bin run dev clean vet test release release-dry-run
6+
7+
help: ## Show this help message
8+
@echo "Available commands:"
9+
@echo ""
10+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
11+
@echo ""
12+
@echo "Release commands require GITHUB_TOKEN environment variable:"
13+
@echo " export GITHUB_TOKEN=your_github_token"
14+
@echo " make release # Create and publish a new release"
15+
@echo " make release-dry-run # Test release without publishing"
16+
17+
prep: ## Install dependencies and prepare development environment
618
go mod tidy
719
go mod download
820
cd ui && pnpm i
921
go install github.com/air-verse/air@latest
1022

11-
build: build_ui build_bin
23+
build: build_ui build_bin ## Build the complete application (UI + binary)
1224

13-
build_ui:
25+
build_ui: ## Build the UI dashboard
1426
pnpm --dir ./ui build
1527

16-
build_bin:
28+
build_bin: ## Build the binary for current platform with CGO enabled
1729
ifeq ($(OS_NAME),darwin)
1830
GOARCH=${ARCH} GOOS=darwin CGO_ENABLED=1 go build -o bin/${BINARY_NAME}-darwin
1931
else ifeq ($(OS_NAME),linux)
@@ -22,23 +34,72 @@ else ifeq ($(OS_NAME),windows)
2234
CC="x86_64-w64-mingw32-gcc" GOARCH=${ARCH} GOOS=windows CGO_ENABLED=1 go build -o bin/${BINARY_NAME}-windows
2335
endif
2436

25-
run: build
37+
run: build ## Build and run the application
2638
ifeq ($(OS_NAME),)
2739
bin/${BINARY_NAME}-windows
2840
else
2941
bin/${BINARY_NAME}-${OS_NAME}
3042
endif
3143

32-
dev:
44+
dev: ## Start development server with hot reload
3345
air
3446

35-
clean:
47+
clean: ## Clean build artifacts
3648
go clean
3749
rm -rf bin/*
3850
rm -rf ui/build/*
3951

40-
vet:
52+
vet: ## Run go vet
4153
go vet
4254

43-
test:
55+
test: ## Run tests
4456
go test ./...
57+
58+
release: ## Create and publish a new release using goreleaser-cross (requires GITHUB_TOKEN)
59+
@echo "Building and releasing with goreleaser-cross for CGO and WEBP support..."
60+
@if [ -z "$(GITHUB_TOKEN)" ]; then \
61+
echo "Error: GITHUB_TOKEN is not set"; \
62+
exit 1; \
63+
fi
64+
docker run --rm --privileged \
65+
-v $(PWD):/go/src/github.com/kevinanielsen/go-fast-cdn \
66+
-v /var/run/docker.sock:/var/run/docker.sock \
67+
-w /go/src/github.com/kevinanielsen/go-fast-cdn \
68+
-e GITHUB_TOKEN=$(GITHUB_TOKEN) \
69+
-e CGO_ENABLED=1 \
70+
goreleaser/goreleaser-cross:v1.27.0 \
71+
release --clean
72+
73+
release-dry-run: ## Test release process without publishing using goreleaser-cross
74+
@echo "Running goreleaser-cross snapshot build with CGO and WEBP support..."
75+
docker run --rm --privileged \
76+
-v $(PWD):/go/src/github.com/kevinanielsen/go-fast-cdn \
77+
-v /var/run/docker.sock:/var/run/docker.sock \
78+
-w /go/src/github.com/kevinanielsen/go-fast-cdn \
79+
-e CGO_ENABLED=1 \
80+
goreleaser/goreleaser-cross:v1.27.0 \
81+
release --snapshot --clean
82+
83+
test-release: ## Test goreleaser-cross configuration and CGO compilation
84+
@echo "Testing goreleaser-cross setup for CGO and WEBP support..."
85+
@echo "Pulling latest goreleaser-cross image..."
86+
docker pull goreleaser/goreleaser-cross:v1.27.0
87+
@echo "Testing configuration..."
88+
docker run --rm --privileged \
89+
-v $(PWD):/go/src/github.com/kevinanielsen/go-fast-cdn \
90+
-w /go/src/github.com/kevinanielsen/go-fast-cdn \
91+
-e CGO_ENABLED=1 \
92+
goreleaser/goreleaser-cross:v1.27.0 \
93+
check
94+
@echo "Testing build for linux/amd64 with CGO..."
95+
docker run --rm --privileged \
96+
-v $(PWD):/go/src/github.com/kevinanielsen/go-fast-cdn \
97+
-w /go/src/github.com/kevinanielsen/go-fast-cdn \
98+
-e CGO_ENABLED=1 \
99+
-e GOOS=linux \
100+
-e GOARCH=amd64 \
101+
-e CC=x86_64-linux-gnu-gcc \
102+
--entrypoint sh \
103+
goreleaser/goreleaser-cross:v1.27.0 \
104+
-c "go build -v -x -o test-binary ./main.go && ldd test-binary || true && rm -f test-binary"
105+
@echo "✅ goreleaser-cross setup test completed successfully!"

0 commit comments

Comments
 (0)