Skip to content

Commit 319e43d

Browse files
authored
.github/workflows: add release.yaml (#45)
Add a github action that will publish a release artifact on tag. Updates #41 Signed-off-by: Benson Wong <[email protected]>
1 parent 21038be commit 319e43d

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed

.github/workflows/release.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: release-on-tag
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
# Allows manual triggering of the workflow
9+
workflow_dispatch:
10+
inputs:
11+
tag:
12+
description: 'Tag release (e.g. v1.2.3)'
13+
required: true
14+
15+
# allow for testing of PR updating this file
16+
pull_request:
17+
paths:
18+
- ".github/workflows/release.yaml"
19+
20+
permissions:
21+
contents: write
22+
23+
jobs:
24+
goreleaser:
25+
runs-on: ubuntu-latest
26+
steps:
27+
-
28+
name: Checkout
29+
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # 4.3.0
30+
with:
31+
fetch-depth: 0
32+
ref: ${{ github.event.inputs.tag || github.ref }}
33+
-
34+
name: Set up Go
35+
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
36+
-
37+
name: Set GoReleaser args for PR dry run
38+
id: goreleaser-args
39+
run: |
40+
if [ "${GITHUB_EVENT_NAME}" = "pull_request" ]; then
41+
echo "args=release --clean --skip=publish --snapshot" >> $GITHUB_OUTPUT
42+
else
43+
echo "args=release --clean" >> $GITHUB_OUTPUT
44+
fi
45+
-
46+
name: Run GoReleaser
47+
uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a #v6.4.0
48+
with:
49+
distribution: goreleaser
50+
version: '~> v2'
51+
args: ${{ steps.goreleaser-args.outputs.args }}
52+
env:
53+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.goreleaser.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
version: 2
2+
3+
builds:
4+
- env:
5+
- CGO_ENABLED=0
6+
goos:
7+
- linux
8+
- darwin
9+
- freebsd
10+
- windows
11+
goarch:
12+
- amd64
13+
- arm64
14+
ignore:
15+
- goos: freebsd
16+
goarch: arm64
17+
- goos: windows
18+
goarch: arm64
19+
20+
archives:
21+
- id: default
22+
formats:
23+
- tar.gz
24+
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
25+
builds_info:
26+
group: root
27+
owner: root
28+
format_overrides:
29+
# use zip format for windows
30+
- goos: windows
31+
formats:
32+
- zip

0 commit comments

Comments
 (0)