Skip to content

Commit 09b4333

Browse files
committed
Add release workflow
1 parent 3024984 commit 09b4333

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed

.github/workflows/release.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Release
2+
3+
# This GitHub action creates a release when a tag that matches the pattern
4+
# "v*" (e.g. v0.1.0) is created.
5+
on:
6+
push:
7+
tags:
8+
- "v*"
9+
10+
# Releases need permissions to read and write the repository contents.
11+
# GitHub considers creating releases and uploading assets as writing contents.
12+
permissions:
13+
contents: write
14+
15+
jobs:
16+
goreleaser:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
20+
with:
21+
# Allow goreleaser to access older tag information.
22+
fetch-depth: 0
23+
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
24+
with:
25+
go-version-file: "go.mod"
26+
cache: true
27+
- name: Import GPG key
28+
uses: crazy-max/ghaction-import-gpg@01dd5d3ca463c7f10f7f4f7b4f177225ac661ee4 # v6.1.0
29+
id: import_gpg
30+
with:
31+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
32+
passphrase: ${{ secrets.GPG_PASSPHRASE }}
33+
- name: Run GoReleaser
34+
uses: goreleaser/goreleaser-action@5742e2a039330cbb23ebf35f046f814d4c6ff811 # v5.1.0
35+
with:
36+
args: release --clean
37+
env:
38+
# GitHub sets the GITHUB_TOKEN secret automatically.
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40+
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}

.goreleaser.yaml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
builds:
2+
- env:
3+
- CGO_ENABLED=0
4+
mod_timestamp: "{{ .CommitTimestamp }}"
5+
flags:
6+
- -trimpath
7+
ldflags:
8+
- "-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}"
9+
goos:
10+
- freebsd
11+
- windows
12+
- linux
13+
- darwin
14+
goarch:
15+
- amd64
16+
- "386"
17+
- arm
18+
- arm64
19+
ignore:
20+
- goos: darwin
21+
goarch: "386"
22+
binary: "{{ .ProjectName }}_v{{ .Version }}"
23+
archives:
24+
- format: zip
25+
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
26+
- format: tar.gz
27+
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
28+
checksum:
29+
name_template: "{{ .ProjectName }}_{{ .Version }}_SHA256SUMS"
30+
algorithm: sha256
31+
signs:
32+
- artifacts: checksum
33+
args:
34+
# if you are using this in a GitHub action or some other automated pipeline, you
35+
# need to pass the batch flag to indicate its not interactive.
36+
- "--batch"
37+
- "--local-user"
38+
- "{{ .Env.GPG_FINGERPRINT }}" # set this environment variable for your signing key
39+
- "--output"
40+
- "${signature}"
41+
- "--detach-sign"
42+
- "${artifact}"
43+
# release:
44+
# draft: true
45+
changelog:
46+
skip: true

0 commit comments

Comments
 (0)