Repository navigation
59 lines (53 loc) · 1.77 KB
/
Copy pathrelease.yml
File metadata and controls
59 lines (53 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
name: Release
# Builds the fmsg binary for each platform and attaches the archives to the
# GitHub release. Runs when a release is published; run it by hand with a tag
# to (re)build an existing release's binaries.
on:
release:
types: [published]
workflow_dispatch:
inputs:
tag:
description: Release tag to build, e.g. v0.3.0
required: true
permissions:
contents: write
jobs:
binaries:
runs-on: ubuntu-latest
env:
TAG: ${{ github.event.release.tag_name || inputs.tag }}
steps:
- uses: actions/checkout@v7
with:
ref: ${{ env.TAG }}
- name: Set up Go
uses: actions/setup-go@v7
with:
go-version: "1.27.x"
- name: Build
run: |
set -euo pipefail
mkdir -p dist
for target in linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 windows/amd64 windows/arm64; do
os=${target%/*}
arch=${target#*/}
bin=fmsg
[ "$os" = windows ] && bin=fmsg.exe
out="build/${os}_${arch}"
mkdir -p "$out"
CGO_ENABLED=0 GOOS=$os GOARCH=$arch go build -trimpath \
-ldflags "-s -w -X github.com/markmnl/fmsg-cli/cmd.version=$TAG" \
-o "$out/$bin" .
cp LICENSE README.md "$out/"
if [ "$os" = windows ]; then
(cd "$out" && zip -q "$GITHUB_WORKSPACE/dist/fmsg_${os}_${arch}.zip" "$bin" LICENSE README.md)
else
tar -C "$out" -czf "dist/fmsg_${os}_${arch}.tar.gz" "$bin" LICENSE README.md
fi
done
(cd dist && sha256sum * > checksums.txt)
- name: Upload to the release
env:
GH_TOKEN: ${{ github.token }}
run: gh release upload "$TAG" dist/* --clobber