-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (45 loc) · 1.42 KB
/
Copy pathrelease.yml
File metadata and controls
52 lines (45 loc) · 1.42 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
name: Release
# v1.0.0 형식의 태그를 push 하면 실행파일을 빌드해 GitHub Release 에 업로드한다.
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Test
run: go test ./...
- name: Build binaries
env:
VERSION: ${{ github.ref_name }}
run: |
mkdir -p dist
targets="linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 windows/amd64"
for t in $targets; do
os=${t%/*}; arch=${t#*/}
bin=wanted
[ "$os" = "windows" ] && bin=wanted.exe
echo "==> $os/$arch"
GOOS=$os GOARCH=$arch CGO_ENABLED=0 \
go build -trimpath -ldflags "-s -w -X main.Version=${VERSION}" -o "$bin" ./cmd
name="wanted_${VERSION}_${os}_${arch}"
if [ "$os" = "windows" ]; then
zip "dist/${name}.zip" "$bin"
else
tar czf "dist/${name}.tar.gz" "$bin"
fi
rm -f "$bin"
done
ls -l dist
- name: Create release and upload assets
env:
GH_TOKEN: ${{ github.token }}
run: gh release create "${{ github.ref_name }}" dist/* --title "${{ github.ref_name }}" --generate-notes