Skip to content

Commit 2b6879d

Browse files
authored
Add goreleaser to publish binaries (#579)
1 parent de4fbc0 commit 2b6879d

File tree

4 files changed

+51
-16
lines changed

4 files changed

+51
-16
lines changed

.github/workflows/push_container.yaml renamed to .github/workflows/release.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Push Tagged Container
1+
name: Push Tagged Container And Release
22
on:
33
push:
44
tags:
@@ -27,7 +27,7 @@ jobs:
2727
- name: test build
2828
run: make build
2929

30-
container-image:
30+
release:
3131
runs-on: ubuntu-latest
3232
needs: [unit-test]
3333

@@ -64,3 +64,11 @@ jobs:
6464
push: true
6565
tags: ${{ steps.meta.outputs.tags }}
6666
labels: ${{ steps.meta.outputs.labels }}
67+
68+
- name: Run GoReleaser
69+
uses: goreleaser/goreleaser-action@v6
70+
with:
71+
version: latest
72+
args: release --clean
73+
env:
74+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 2 additions & 0 deletions
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

Lines changed: 39 additions & 0 deletions
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

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,5 @@ update-static: build ## Updates the static assets in the repository.
3333
fmt: ## Ensures consistent formatting on policy tests.
3434
conftest fmt examples
3535

36-
#
37-
##@ Releases
38-
#
39-
40-
.PHONY: release
41-
release: ## Builds the binaries for each OS and creates the checksums.
42-
@test $(version)
43-
GOOS=darwin GOARCH=amd64 go build -o build/konstraint-darwin-amd64 -ldflags="-s -w -X 'github.com/plexsystems/konstraint/internal/commands.version=$(version)'"
44-
GOOS=darwin GOARCH=arm64 go build -o build/konstraint-darwin-arm64 -ldflags="-s -w -X 'github.com/plexsystems/konstraint/internal/commands.version=$(version)'"
45-
GOOS=windows GOARCH=amd64 go build -o build/konstraint-windows-amd64.exe -ldflags="-s -w -X 'github.com/plexsystems/konstraint/internal/commands.version=$(version)'"
46-
GOOS=linux GOARCH=amd64 go build -o build/konstraint-linux-amd64 -ldflags="-s -w -X 'github.com/plexsystems/konstraint/internal/commands.version=$(version)'"
47-
GOOS=linux GOARCH=arm64 go build -o build/konstraint-linux-arm64 -ldflags="-s -w -X 'github.com/plexsystems/konstraint/internal/commands.version=$(version)'"
48-
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'
49-
5036
help:
5137
@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)