Skip to content

Commit 2a28882

Browse files
committed
Trying out Github workflow
1 parent b34f7d5 commit 2a28882

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

.github/workflows/release.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
12+
concurrency:
13+
group: release-${{ github.ref }}
14+
cancel-in-progress: false
15+
16+
env:
17+
APP_NAME: ${{ github.event.repository.name }}
18+
VERSION: ${{ github.ref_name }}
19+
20+
jobs:
21+
build:
22+
name: Build (${{ matrix.goos }}/${{ matrix.goarch }})
23+
runs-on: ubuntu-latest
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
goos: [linux, darwin]
28+
goarch: [amd64, arm64]
29+
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v4
33+
34+
- name: Set up Go
35+
uses: actions/setup-go@v5
36+
with:
37+
go-version: '>=1.22'
38+
cache: true
39+
40+
- name: Test
41+
run: go test ./...
42+
43+
- name: Build
44+
shell: bash
45+
run: |
46+
set -euxo pipefail
47+
mkdir -p dist
48+
OUT="dist/${APP_NAME}_${VERSION}_${{ matrix.goos }}_${{ matrix.goarch }}"
49+
CGO_ENABLED=0 GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} \
50+
go build -trimpath -ldflags="-s -w -X main.version=${VERSION}" -o "$OUT" .
51+
(cd dist && sha256sum "$(basename "$OUT")" > "$(basename "$OUT").sha256")
52+
53+
- name: Upload artifact
54+
uses: actions/upload-artifact@v4
55+
with:
56+
name: binaries-${{ matrix.goos }}-${{ matrix.goarch }}
57+
path: dist/*
58+
overwrite: true
59+
60+
release:
61+
name: Create GitHub Release
62+
runs-on: ubuntu-latest
63+
needs: build
64+
steps:
65+
- name: Download all artifacts
66+
uses: actions/download-artifact@v4
67+
with:
68+
pattern: binaries-*
69+
path: dist
70+
merge-multiple: true
71+
72+
- name: Create/Update Release and Upload Assets
73+
uses: softprops/action-gh-release@v2
74+
with:
75+
files: dist/*
76+
prerelease: ${{ contains(github.ref_name, '-') }}
77+
generate_release_notes: true
78+
env:
79+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)