-
Notifications
You must be signed in to change notification settings - Fork 0
61 lines (49 loc) · 2.29 KB
/
compile-release.yml
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
60
61
# This GitHub Actions workflow compiles the code for several architectures and
# generates a release on GitHub
name: Compile and Release
on:
push:
branches: [master]
workflow_dispatch:
jobs:
build:
name: Compile for different operating systems and release
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
# Dudu requires Go version 1.16+
- uses: actions/setup-go@v2
with:
go-version: '^1.16.0'
- name: Setup
run: |
mkdir -p bin
- name: Compile for Windows
run: |
GOOS=windows GOARCH=386 go build -o bin/dudu-windows_x86.exe -ldflags="-X 'main.Version=$(git describe --tags)'" github.com/lsnow99/dudu/cmd/dudu
GOOS=windows GOARCH=amd64 go build -o bin/dudu-windows_x64.exe -ldflags="-X 'main.Version=$(git describe --tags)'" github.com/lsnow99/dudu/cmd/dudu
- name: Compile for OS X
run: |
GOOS=darwin GOARCH=amd64 go build -o bin/dudu-osx_amd64 -ldflags="-X 'main.Version=$(git describe --tags)'" github.com/lsnow99/dudu/cmd/dudu
GOOS=darwin GOARCH=arm64 go build -o bin/dudu-osx_arm64 -ldflags="-X 'main.Version=$(git describe --tags)'" github.com/lsnow99/dudu/cmd/dudu
- name: Compile for Linux
run: |
GOOS=linux GOARCH=386 go build -o bin/dudu-linux_x86 -ldflags="-X 'main.Version=$(git describe --tags)'" github.com/lsnow99/dudu/cmd/dudu
GOOS=linux GOARCH=amd64 go build -o bin/dudu-linux_x64 -ldflags="-X 'main.Version=$(git describe --tags)'" github.com/lsnow99/dudu/cmd/dudu
GOOS=linux GOARCH=arm go build -o bin/dudu-linux_arm -ldflags="-X 'main.Version=$(git describe --tags)'" github.com/lsnow99/dudu/cmd/dudu
GOOS=linux GOARCH=arm64 go build -o bin/dudu-linux_arm64 -ldflags="-X 'main.Version=$(git describe --tags)'" github.com/lsnow99/dudu/cmd/dudu
# Requires adding a GITHUB_TOKEN secret
- name: Create GitHub release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd bin
TAG="$(git describe --tags)"
ASSETS=()
for ASSET in *; do
ASSETS+=("--attach" "$ASSET")
done
hub release create \
"${ASSETS[@]}" \
--message "Compiled binaries for dudu $TAG" \
"$TAG"