-
-
Notifications
You must be signed in to change notification settings - Fork 17
227 lines (196 loc) · 8.4 KB
/
Copy pathbuild_base.yml
File metadata and controls
227 lines (196 loc) · 8.4 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
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
name: VIIPER Build Base
on:
workflow_call:
inputs:
artifact_suffix:
required: false
type: string
default: ""
description: "Suffix to add to artifact names"
upload_artifacts:
required: false
type: boolean
default: false
description: "Whether to upload build artifacts"
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v6.4.0
with:
go-version: stable
cache: true
cache-dependency-path: |
go.sum
- name: Setup just
uses: extractions/setup-just@v3
- name: Install goversioninfo (Windows)
if: ${{ matrix.target.goos == 'windows' }}
shell: pwsh
run: |
go install github.com/josephspurrier/goversioninfo/cmd/goversioninfo@v1.7.0
- name: Show Go version
run: go version
- name: Lint
uses: golangci/golangci-lint-action@v9.2.0
with:
version: latest
install-mode: goinstall
- name: Run tests
run: just test-coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v6
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: .
fail_ci_if_error: false
build:
name: Build binaries (${{ matrix.target.goos }}/${{ matrix.target.goarch }})
runs-on: ${{ matrix.target.runner }}
needs: test
strategy:
fail-fast: false
matrix:
target:
- { goos: linux, goarch: amd64, ext: "", runner: ubuntu-latest }
- { goos: linux, goarch: arm64, ext: "", runner: ubuntu-latest }
- { goos: windows, goarch: amd64, ext: ".exe", runner: windows-latest }
- { goos: windows, goarch: arm64, ext: ".exe", runner: windows-latest }
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v6.4.0
with:
go-version: 1.26
cache: true
cache-dependency-path: |
go.sum
- name: Setup just
uses: extractions/setup-just@v3
- name: Install goversioninfo
shell: pwsh
run: |
go install github.com/josephspurrier/goversioninfo/cmd/goversioninfo@v1.7.0
- name: Build
env:
GOOS: ${{ matrix.target.goos }}
GOARCH: ${{ matrix.target.goarch }}
CGO_ENABLED: 0
BUILD_TYPE: Release
OUTPUT_NAME: viiper-${{ matrix.target.goos }}-${{ matrix.target.goarch }}${{ matrix.target.ext }}
run: |
just build Release
- name: Package (Linux)
if: ${{ matrix.target.goos == 'linux' }}
shell: bash
run: |
set -euo pipefail
rm -rf dist/package
mkdir -p dist/package
cp dist/viiper-${{ matrix.target.goos }}-${{ matrix.target.goarch }} dist/package/viiper
cp dist/licenses.txt dist/package/licenses.txt
tar -czf dist/viiper-${{ matrix.target.goos }}-${{ matrix.target.goarch }}.tar.gz -C dist/package viiper licenses.txt
- name: Package (Windows)
if: ${{ matrix.target.goos == 'windows' }}
shell: pwsh
run: |
Remove-Item -Recurse -Force dist/package -ErrorAction SilentlyContinue
New-Item -ItemType Directory -Force -Path dist/package | Out-Null
Copy-Item dist/viiper-${{ matrix.target.goos }}-${{ matrix.target.goarch }}${{ matrix.target.ext }} dist/package/viiper.exe -Force
Copy-Item dist/licenses.txt dist/package/licenses.txt -Force
Compress-Archive -Path dist/package/viiper.exe, dist/package/licenses.txt -DestinationPath dist/viiper-${{ matrix.target.goos }}-${{ matrix.target.goarch }}.zip -Force
- name: Upload artifact (Linux)
if: ${{ inputs.upload_artifacts && matrix.target.goos == 'linux' }}
uses: actions/upload-artifact@v7
with:
name: VIIPER-${{ matrix.target.goos }}-${{ matrix.target.goarch }}${{ inputs.artifact_suffix }}
path: dist/viiper-${{ matrix.target.goos }}-${{ matrix.target.goarch }}.tar.gz
if-no-files-found: error
- name: Upload artifact (Windows)
if: ${{ inputs.upload_artifacts && matrix.target.goos == 'windows' }}
uses: actions/upload-artifact@v7
with:
name: VIIPER-${{ matrix.target.goos }}-${{ matrix.target.goarch }}${{ inputs.artifact_suffix }}
path: dist/viiper-${{ matrix.target.goos }}-${{ matrix.target.goarch }}.zip
if-no-files-found: error
libviiper-linux:
name: Build libVIIPER (linux/amd64)
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v6.4.0
with:
go-version: 1.26
cache: true
cache-dependency-path: |
go.sum
- name: Setup just
uses: extractions/setup-just@v3
- name: Build
run: |
just build-libVIIPER Release
- name: Package
run: cd dist/libVIIPER && zip libVIIPER-linux-amd64.zip libVIIPER.so libVIIPER.h licenses.txt
- name: Upload artifact
if: ${{ inputs.upload_artifacts }}
uses: actions/upload-artifact@v7
with:
name: libVIIPER-linux-amd64${{ inputs.artifact_suffix }}
path: dist/libVIIPER/libVIIPER-linux-amd64.zip
if-no-files-found: error
libviiper-windows:
name: Build libVIIPER (windows/amd64)
runs-on: windows-latest
needs: test
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v6.4.0
with:
go-version: 1.26
cache: true
cache-dependency-path: |
go.sum
- name: Setup just
uses: extractions/setup-just@v3
- name: Install build tools
shell: pwsh
run: |
winget install -e --id MartinStorsjo.LLVM-MinGW.UCRT --accept-package-agreements --accept-source-agreements
winget install -e --id Kitware.CMake --accept-package-agreements --accept-source-agreements
if (Test-Path "C:\Program Files\LLVM-MinGW\bin") {
"C:\Program Files\LLVM-MinGW\bin" | Out-File -FilePath $env:GITHUB_PATH -Append
}
exit 0
- name: Build
shell: bash
run: |
just build-libVIIPER Release
- name: Package
shell: pwsh
run: |
Compress-Archive -Path dist/libVIIPER/libVIIPER.dll, dist/libVIIPER/libVIIPER.def, dist/libVIIPER/libVIIPER.h, dist/libVIIPER/licenses.txt -DestinationPath dist/libVIIPER/libVIIPER-windows-amd64.zip -Force
- name: Upload artifact
if: ${{ inputs.upload_artifacts }}
uses: actions/upload-artifact@v7
with:
name: libVIIPER-windows-amd64${{ inputs.artifact_suffix }}
path: dist/libVIIPER/libVIIPER-windows-amd64.zip
if-no-files-found: error