-
Notifications
You must be signed in to change notification settings - Fork 66
181 lines (178 loc) · 5.95 KB
/
build.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
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
name: Build
on:
push:
branches: [master]
tags: [v*]
permissions:
contents: write
jobs:
goreleaser:
name: Goreleaser
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Fetch all tags
run: git fetch --force --tags
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.22"
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
if: ${{ contains(github.ref, 'v') }}
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Test GoReleaser
uses: goreleaser/goreleaser-action@v5
if: ${{ ! contains(github.ref, 'v') }}
with:
# either 'goreleaser' (default) or 'goreleaser-pro'
distribution: goreleaser
version: latest
args: release --snapshot --clean
build:
name: Build-${{ matrix.os }}-${{ matrix.GOARCH }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- windows-latest
- ubuntu-latest
- macos-latest
GOARCH:
- amd64
include:
- os: ubuntu-latest
GOARCH: "386"
- os: ubuntu-latest
GOARCH: "arm"
- os: ubuntu-latest
GOARCH: "arm64"
- os: ubuntu-latest
GOARCH: "riscv64"
- os: macos-latest
GOARCH: "arm64"
steps:
- name: Check out
uses: actions/checkout@v4
- name: Set up Go 1.22
uses: actions/setup-go@v5
with:
go-version: "1.22"
- name: Get git tag ref
run: git fetch --prune --unshallow --tags
- name: Download dependencies
run: go mod download
- name: Generate version
run: go generate ./cmd/go-judge/version
- name: Build on Linux
if: ${{ matrix.os == 'ubuntu-latest' }}
env:
GOARCH: ${{ matrix.GOARCH }}
CGO_ENABLE: 0
run: |
go build -v -tags grpcnotrace,nomsgpack -o go-judge ./cmd/go-judge
go build -v -o go-judge-shell ./cmd/go-judge-shell
go build -o go-judge-init ./cmd/go-judge-init
- name: Build shared objects on Linux
if: ${{ matrix.os == 'ubuntu-latest' && matrix.GOARCH == 'amd64' }}
env:
GOARCH: ${{ matrix.GOARCH }}
run: |
go build -buildmode=c-shared -o go-judge.so ./cmd/go-judge-ffi
- name: Upload go-judge on linux
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: actions/upload-artifact@v4
with:
name: go-judge-${{ matrix.GOARCH }}
path: go-judge
- name: Upload go-judge-shell on linux
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: actions/upload-artifact@v4
with:
name: go-judge-shell-${{ matrix.GOARCH }}
path: go-judge-shell
- name: Upload go-judge-init on linux
if: ${{ matrix.os == 'ubuntu-latest' }}
uses: actions/upload-artifact@v4
with:
name: go-judge-init-${{ matrix.GOARCH }}
path: go-judge-init
- name: Upload go-judge.so on linux
if: ${{ matrix.os == 'ubuntu-latest' && matrix.GOARCH == 'amd64' }}
uses: actions/upload-artifact@v4
with:
name: go-judge-${{ matrix.GOARCH }}.so
path: go-judge.so
- name: Build on Windows
if: ${{ matrix.os == 'windows-latest' }}
env:
GOARCH: ${{ matrix.GOARCH }}
run: |
go build -tags grpcnotrace,nomsgpack -o go-judge.exe ./cmd/go-judge
- name: Build shared object on Windows
if: ${{ matrix.os == 'windows-latest' }}
env:
GOARCH: ${{ matrix.GOARCH }}
run: |
go build -buildmode=c-shared -o go-judge.dll ./cmd/go-judge-ffi
- name: Upload go-judge.exe on Windows
if: ${{ matrix.os == 'windows-latest' }}
uses: actions/upload-artifact@v4
with:
name: go-judge-${{ matrix.GOARCH }}.exe
path: go-judge.exe
- name: Upload go-judge.dll on Windows
if: ${{ matrix.os == 'windows-latest' }}
uses: actions/upload-artifact@v4
with:
name: go-judge-${{ matrix.GOARCH }}.dll
path: go-judge.dll
- name: Build on macOS
if: ${{ matrix.os == 'macos-latest' }}
env:
GOARCH: ${{ matrix.GOARCH }}
run: |
go build -tags grpcnotrace,nomsgpack -o go-judge ./cmd/go-judge
go build -o go-judge-shell ./cmd/go-judge-shell
- name: Build shared object on macOS
if: ${{ matrix.os == 'macos-latest' && matrix.GOARCH == 'amd64' }}
env:
GOARCH: ${{ matrix.GOARCH }}
run: |
go build -buildmode=c-shared -o go-judge.dylib ./cmd/go-judge-ffi
- name: Upload go-judge on macOS
if: ${{ matrix.os == 'macos-latest' }}
uses: actions/upload-artifact@v4
with:
name: go-judge-MacOS-${{ matrix.GOARCH }}
path: go-judge
- name: Upload go-judge-shell on macOS
if: ${{ matrix.os == 'macos-latest' }}
uses: actions/upload-artifact@v4
with:
name: go-judge-shell-MacOS-${{ matrix.GOARCH }}
path: go-judge-shell
- name: Upload go-judge.dylib on macOS
if: ${{ matrix.os == 'macos-latest' && matrix.GOARCH == 'amd64' }}
uses: actions/upload-artifact@v4
with:
name: go-judge-${{ matrix.GOARCH }}.dylib
path: go-judge.dylib