forked from svarogg/kaspaper
-
Notifications
You must be signed in to change notification settings - Fork 2
109 lines (97 loc) · 4.29 KB
/
build-release.yaml
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
name: Build and upload assets
on:
release:
types: [ published ]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
TARGET: linux/x86_64
- os: ubuntu-latest
TARGET: linux/aarch64
- os: ubuntu-latest
TARGET: windows/x64
- os: macos-latest
TARGET: macos/x64
name: Building, ${{ matrix.TARGET }}
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.20.12
- name: Update sources
if: matrix.TARGET == 'linux/aarch64' || matrix.TARGET == 'windows/x64'
run: sudo apt-get update -y
- name: Install compilers
if: matrix.TARGET == 'linux/aarch64' || matrix.TARGET == 'windows/x64'
run: sudo apt-get install gcc-aarch64-linux-gnu gcc-mingw-w64-x86-64-win32 -y
- name: Build on Linux for ${{ matrix.TARGET }}
if: matrix.TARGET == 'linux/x86_64'
run: |
# `-extldflags=-static` - means static link everything,
# `-tags netgo,osusergo` means use pure go replacements for "os/user" and "net"
# `-s -w` strips the binary to produce smaller size binaries
go build -v -ldflags="-s -w -extldflags=-static" -tags netgo,osusergo -o ./bin/ .
archive="bin/karlsen-paper-${{ github.event.release.tag_name }}-linux-x86_64.zip"
asset_name="karlsen-paper-${{ github.event.release.tag_name }}-linux-x86_64.zip"
zip -r "${archive}" ./bin/*
echo "archive=${archive}" >> $GITHUB_ENV
echo "asset_name=${asset_name}" >> $GITHUB_ENV
- name: Build on Linux for ${{ matrix.TARGET }}
if: matrix.TARGET == 'linux/aarch64'
env:
CGO_ENABLED: 1
CC: aarch64-linux-gnu-gcc
GOOS: linux
GOARCH: arm64
run: |
# `-extldflags=-static` - means static link everything,
# `-tags netgo,osusergo` means use pure go replacements for "os/user" and "net"
# `-s -w` strips the binary to produce smaller size binaries
go build -v -ldflags="-s -w -extldflags=-static" -tags netgo,osusergo -o ./bin/ .
archive="bin/karlsen-paper-${{ github.event.release.tag_name }}-linux-aarch64.zip"
asset_name="karlsen-paper-${{ github.event.release.tag_name }}-linux-aarch64.zip"
zip -r "${archive}" ./bin/*
echo "archive=${archive}" >> $GITHUB_ENV
echo "asset_name=${asset_name}" >> $GITHUB_ENV
- name: Build on Linux for ${{ matrix.TARGET }}
if: matrix.TARGET == 'windows/x64'
env:
CGO_ENABLED: 1
CC: x86_64-w64-mingw32-gcc
GOOS: windows
GOARCH: amd64
run: |
# `-extldflags=-static` - means static link everything,
# `-tags netgo,osusergo` means use pure go replacements for "os/user" and "net"
# `-s -w` strips the binary to produce smaller size binaries
go build -v -ldflags="-s -w -extldflags=-static" -tags netgo,osusergo -o ./bin/ .
archive="bin/karlsen-paper-${{ github.event.release.tag_name }}-windows-x64.zip"
asset_name="karlsen-paper-${{ github.event.release.tag_name }}-windows-x64.zip"
zip -r "${archive}" ./bin/*
echo "archive=${archive}" >> $GITHUB_ENV
echo "asset_name=${asset_name}" >> $GITHUB_ENV
- name: Build on Linux for ${{ matrix.TARGET }}
if: matrix.TARGET == 'macos/x64'
run: |
go build -v -ldflags="-s -w" -o ./bin/ .
archive="bin/karlsen-paper-${{ github.event.release.tag_name }}-macos-x64.zip"
asset_name="karlsen-paper-${{ github.event.release.tag_name }}-macos-x64.zip"
zip -r "${archive}" ./bin/*
echo "archive=${archive}" >> $GITHUB_ENV
echo "asset_name=${asset_name}" >> $GITHUB_ENV
- name: Upload release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: "./${{ env.archive }}"
asset_name: "${{ env.asset_name }}"
asset_content_type: application/zip