Skip to content

Commit 59dd1bc

Browse files
ci: build binaries using goreleaser-cross
1 parent 975f276 commit 59dd1bc

File tree

3 files changed

+73
-5
lines changed

3 files changed

+73
-5
lines changed

.github/workflows/ci.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,24 @@ jobs:
2626
with:
2727
token: ${{ secrets.CODECOV_TOKEN }}
2828
if: matrix.os == 'ubuntu-latest'
29+
30+
test-release:
31+
runs-on: ubuntu-latest
32+
steps:
33+
- name: Checkout
34+
uses: actions/checkout@v4
35+
with:
36+
fetch-depth: 0
37+
- name: Set up Go
38+
uses: actions/setup-go@v5
39+
with:
40+
go-version: 1.24
41+
- name: Install GoReleaser
42+
uses: goreleaser/goreleaser-action@v6
43+
with:
44+
version: latest
45+
install-only: true
46+
- name: Run GoReleaser (Dry Run)
47+
run: make release-dry-run
48+
env:
49+
GITHUB_TOKEN: ${{ secrets.GH_PAT }}

.github/workflows/release.yaml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,19 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Checkout
13-
uses: actions/checkout@v2
13+
uses: actions/checkout@v4
1414
with:
1515
fetch-depth: 0
1616
- name: Set up Go
17-
uses: actions/setup-go@v2
17+
uses: actions/setup-go@v5
1818
with:
1919
go-version: 1.24
20-
- name: Run GoReleaser
21-
uses: goreleaser/goreleaser-action@v2
20+
- name: Install GoReleaser
21+
uses: goreleaser/goreleaser-action@v6
2222
with:
2323
version: latest
24-
args: release --clean
24+
install-only: true
25+
- name: Run GoReleaser
26+
run: make release
2527
env:
2628
GITHUB_TOKEN: ${{ secrets.GH_PAT }}

Makefile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Enable CGO https://github.com/rest-sh/restish/pull/291
2+
# Based on https://github.com/goreleaser/example-cross/blob/c45dc32486e1532f330702104e2fd527891b44b9/Makefile
3+
4+
PACKAGE_NAME := github.com/rest-sh/restish
5+
GOLANG_CROSS_VERSION ?= v1.21.5
6+
7+
SYSROOT_DIR ?= sysroots
8+
SYSROOT_ARCHIVE ?= sysroots.tar.bz2
9+
10+
.PHONY: sysroot-pack
11+
sysroot-pack:
12+
@tar cf - $(SYSROOT_DIR) -P | pv -s $[$(du -sk $(SYSROOT_DIR) | awk '{print $1}') * 1024] | pbzip2 > $(SYSROOT_ARCHIVE)
13+
14+
.PHONY: sysroot-unpack
15+
sysroot-unpack:
16+
@pv $(SYSROOT_ARCHIVE) | pbzip2 -cd | tar -xf -
17+
18+
.PHONY: release-dry-run
19+
release-dry-run:
20+
@docker run \
21+
--rm \
22+
-e CGO_ENABLED=1 \
23+
-v /var/run/docker.sock:/var/run/docker.sock \
24+
-v `pwd`:/go/src/$(PACKAGE_NAME) \
25+
-v `pwd`/sysroot:/sysroot \
26+
-w /go/src/$(PACKAGE_NAME) \
27+
ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
28+
--clean --skip=validate --skip=publish
29+
30+
.PHONY: release
31+
release:
32+
@if [ ! -f ".release-env" ]; then \
33+
echo "\033[91m.release-env is required for release\033[0m";\
34+
exit 1;\
35+
fi
36+
docker run \
37+
--rm \
38+
-e CGO_ENABLED=1 \
39+
--env-file .release-env \
40+
-v /var/run/docker.sock:/var/run/docker.sock \
41+
-v `pwd`:/go/src/$(PACKAGE_NAME) \
42+
-v `pwd`/sysroot:/sysroot \
43+
-w /go/src/$(PACKAGE_NAME) \
44+
ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \
45+
release --clean

0 commit comments

Comments
 (0)