Skip to content

Commit 6d1c724

Browse files
committed
Add goreleaser to publish binaries
1 parent 4eddcf9 commit 6d1c724

File tree

4 files changed

+66
-10
lines changed

4 files changed

+66
-10
lines changed
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: publish-binaries
2+
3+
on:
4+
release:
5+
types:
6+
- created
7+
8+
jobs:
9+
build-and-push-binaries:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v4
14+
15+
- name: Set up Go
16+
uses: actions/setup-go@v5
17+
with:
18+
go-version-file: go.mod
19+
- name: Run GoReleaser
20+
uses: goreleaser/goreleaser-action@v6
21+
with:
22+
version: latest
23+
args: release --clean
24+
env:
25+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,5 @@ konstraint*
2424
## File-based project format:
2525
*.iws
2626
*.iml
27+
# Added by goreleaser init:
28+
dist/

.goreleaser.yaml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
version: 2
2+
3+
before:
4+
hooks:
5+
- go mod tidy
6+
7+
builds:
8+
- env:
9+
- CGO_ENABLED=0
10+
goos:
11+
- linux
12+
- windows
13+
- darwin
14+
ldflags:
15+
- -s
16+
- -w
17+
- -X 'github.com/plexsystems/konstraint/internal/commands.version={( .Version })'
18+
19+
archives:
20+
- format: tar.gz
21+
# this name template makes the OS and Arch compatible with the results of `uname`.
22+
name_template: >-
23+
{{ .ProjectName }}_
24+
{{- title .Os }}_
25+
{{- if eq .Arch "amd64" }}x86_64
26+
{{- else if eq .Arch "386" }}i386
27+
{{- else }}{{ .Arch }}{{ end }}
28+
{{- if .Arm }}v{{ .Arm }}{{ end }}
29+
# use zip for windows archives
30+
format_overrides:
31+
- goos: windows
32+
format: zip
33+
34+
changelog:
35+
sort: asc
36+
filters:
37+
exclude:
38+
- "^docs:"
39+
- "^test:"

Makefile

-10
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,5 @@ docker-push: ## Pushes the docker image to the container registry.
7575
docker push $(IMAGE):$(version)
7676
docker push $(IMAGE):latest
7777

78-
.PHONY: release
79-
release: ## Builds the binaries for each OS and creates the checksums.
80-
@test $(version)
81-
GOOS=darwin GOARCH=amd64 go build -o build/konstraint-darwin-amd64 -ldflags="-s -w -X 'github.com/plexsystems/konstraint/internal/commands.version=$(version)'"
82-
GOOS=darwin GOARCH=arm64 go build -o build/konstraint-darwin-arm64 -ldflags="-s -w -X 'github.com/plexsystems/konstraint/internal/commands.version=$(version)'"
83-
GOOS=windows GOARCH=amd64 go build -o build/konstraint-windows-amd64.exe -ldflags="-s -w -X 'github.com/plexsystems/konstraint/internal/commands.version=$(version)'"
84-
GOOS=linux GOARCH=amd64 go build -o build/konstraint-linux-amd64 -ldflags="-s -w -X 'github.com/plexsystems/konstraint/internal/commands.version=$(version)'"
85-
GOOS=linux GOARCH=arm64 go build -o build/konstraint-linux-arm64 -ldflags="-s -w -X 'github.com/plexsystems/konstraint/internal/commands.version=$(version)'"
86-
docker run --user $(shell id -u):$(shell id -g) --rm -v $(shell pwd):/konstraint alpine:3 /bin/ash -c 'cd /konstraint/build && sha256sum konstraint-* > checksums.txt'
87-
8878
help:
8979
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[$$()% a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

0 commit comments

Comments
 (0)