Skip to content

Commit ad70b5b

Browse files
committed
chore(ci): migrate to GoReleaser for releases and update workflow
1 parent a73db5a commit ad70b5b

File tree

3 files changed

+91
-65
lines changed

3 files changed

+91
-65
lines changed

.github/workflows/binaries.yml

+19-65
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Release Binaries
1+
name: Release
22

33
on:
44
release:
@@ -9,69 +9,23 @@ permissions:
99
packages: write
1010

1111
jobs:
12-
release-linux-amd64:
13-
name: release linux/amd64
12+
goreleaser:
1413
runs-on: ubuntu-latest
1514
steps:
16-
- uses: actions/checkout@v2
17-
- uses: wangyoucao577/[email protected]
18-
with:
19-
github_token: ${{ secrets.GITHUB_TOKEN }}
20-
goos: linux
21-
goarch: amd64
22-
project_path: cmd/envsubst
23-
asset_name: envsubst-Linux-x86_64
24-
compress_assets: OFF
25-
release-linux-arm64:
26-
name: release linux/arm64
27-
runs-on: ubuntu-latest
28-
steps:
29-
- uses: actions/checkout@v2
30-
- uses: wangyoucao577/[email protected]
31-
with:
32-
github_token: ${{ secrets.GITHUB_TOKEN }}
33-
goos: linux
34-
goarch: arm64
35-
project_path: cmd/envsubst
36-
asset_name: envsubst-Linux-arm64
37-
compress_assets: OFF
38-
release-darwin-amd64:
39-
name: release darwin/amd64
40-
runs-on: ubuntu-latest
41-
steps:
42-
- uses: actions/checkout@v2
43-
- uses: wangyoucao577/[email protected]
44-
with:
45-
github_token: ${{ secrets.GITHUB_TOKEN }}
46-
goos: darwin
47-
goarch: amd64
48-
project_path: cmd/envsubst
49-
asset_name: envsubst-Darwin-x86_64
50-
compress_assets: OFF
51-
release-darwin-arm64:
52-
name: release darwin/arm64
53-
runs-on: ubuntu-latest
54-
steps:
55-
- uses: actions/checkout@v2
56-
- uses: wangyoucao577/[email protected]
57-
with:
58-
github_token: ${{ secrets.GITHUB_TOKEN }}
59-
goos: darwin
60-
goarch: arm64
61-
project_path: cmd/envsubst
62-
asset_name: envsubst-Darwin-arm64
63-
compress_assets: OFF
64-
release-windows:
65-
name: release windows
66-
runs-on: ubuntu-latest
67-
steps:
68-
- uses: actions/checkout@v2
69-
- uses: wangyoucao577/[email protected]
70-
with:
71-
github_token: ${{ secrets.GITHUB_TOKEN }}
72-
goos: windows
73-
goarch: amd64
74-
project_path: cmd/envsubst
75-
binary_name: envsubst-windows #release fails if the binary name is the same as the asset name
76-
asset_name: envsubst
77-
compress_assets: OFF
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- uses: actions/setup-go@v5
20+
with:
21+
go-version-file: go.mod
22+
23+
- uses: ko-build/[email protected]
24+
25+
- uses: goreleaser/goreleaser-action@v6
26+
with:
27+
distribution: goreleaser
28+
version: "~> v2"
29+
args: release --clean
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Added by goreleaser init:
2+
dist/

.goreleaser.yaml

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Make sure to check the documentation at https://goreleaser.com
2+
3+
# The lines below are called `modelines`. See `:help modeline`
4+
# Feel free to remove those if you don't want/need to use them.
5+
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
6+
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
7+
8+
version: 2
9+
10+
before:
11+
hooks:
12+
- go mod tidy
13+
14+
builds:
15+
- main: ./cmd/envsubst
16+
env:
17+
- CGO_ENABLED=0
18+
goos:
19+
- linux
20+
- darwin
21+
- windows
22+
goarch:
23+
- amd64
24+
- arm64
25+
- arm
26+
- ppc64le
27+
- s390x
28+
goarm:
29+
- "7"
30+
flags:
31+
- -trimpath
32+
ldflags:
33+
- -s -w
34+
35+
archives:
36+
- formats: binary
37+
# This name template makes the OS and Arch compatible with the results of `uname`.
38+
# Binaries for Windows amd64 are named envsubst.exe as fallback with previous versions.
39+
name_template: >-
40+
{{- if and (eq .Os "windows") (eq .Arch "amd64") -}}
41+
{{- .ProjectName }}
42+
{{- else -}}
43+
{{- .ProjectName }}_{{ title .Os }}_
44+
{{- if eq .Arch "amd64" }}x86_64
45+
{{- else }}{{ .Arch }}{{ end }}
46+
{{- if .Arm }}v{{ .Arm }}{{ end }}
47+
{{- end -}}
48+
49+
kos:
50+
- base_image: gcr.io/distroless/static:nonroot
51+
bare: true
52+
preserve_import_paths: false
53+
labels:
54+
org.opencontainers.image.created: "{{ .Date }}"
55+
org.opencontainers.image.revision: "{{ .ShortCommit }}"
56+
org.opencontainers.image.source: "{{ .GitURL }}"
57+
org.opencontainers.image.version: "{{ .Version }}"
58+
platforms:
59+
- all
60+
repositories:
61+
- "{{ .Env.KO_DOCKER_REPO }}"
62+
tags:
63+
- latest
64+
- "{{ .Version }}"
65+
66+
changelog:
67+
use: github
68+
69+
release:
70+
mode: keep-existing

0 commit comments

Comments
 (0)