-
Notifications
You must be signed in to change notification settings - Fork 15
304 lines (249 loc) · 9.43 KB
/
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
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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
name: Release binaries
# This machine tests building the software on a both 32 and 64 Windows architecture.
on: [push]
jobs:
source:
name: Build source release
runs-on: ubuntu-latest
env:
VERSION: 3.0.4
steps:
- name: checkout
uses: actions/checkout@v3
- name: Make source release
run: |
set -e -o pipefail
set -x
mkdir -p artifact/yubihsm-connector
tar --exclude .git --exclude .github --exclude artifact --transform="s/^\./yubihsm-connector-$VERSION/" -czf ../yubihsm-connector-$VERSION.tar.gz .
pwd
ls ..
cp ../yubihsm-connector-$VERSION.tar.gz artifact/yubihsm-connector
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: yubihsm-connector-src
path: artifact
Windowsx-build:
name: Build Windows release binaries
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Build and make MSI installer
run: |
$ErrorActionPreference = "Stop"
Set-PSDebug -Trace 1
mkdir artifact
choco install -y golang
go mod tidy -compat=1.17
go generate ./...
go build -o bin/yubihsm-connector.exe
cp bin/yubihsm-connector.exe artifact\
./bin/yubihsm-connector.exe version
./bin/yubihsm-connector.exe --help
cd resources/win-installer
& cmd /c '"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Tools\VsMSBuildCmd.bat" && msbuild YubiHSMConnectorInstaller.sln /p:Configuration=Release'
cp x64/Release/yubihsm-connector-windows-amd64.msi ../../artifact/
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: yubihsm-connector-windows-amd64
path: artifact
macos-build:
name: Build MacOS release binaries
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: macos-latest
arch: amd
- os: macos-latest-xlarge
arch: arm
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Build and make MSI installer
run: |
set -e -o pipefail
set -x
mkdir artifact
if [[ ${{ matrix.arch }} == "arm" ]]; then
brew install golang
fi
make GB_BUILD_FLAGS="-tags disable_seccomp -ldflags '-s'"
strip -u -r bin/yubihsm-connector*
cp bin/yubihsm-connector artifact
./bin/yubihsm-connector version
./bin/yubihsm-connector --help
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: yubihsm-connector-mac-${{ matrix.arch }}64
path: artifact
debian_based:
strategy:
fail-fast: false
matrix:
environment: [
"ubuntu:23.10",
"ubuntu:23.04",
"ubuntu:22.04",
"ubuntu:20.04",
"ubuntu:18.04",
"ubuntu:16.04",
"ubuntu:14.04",
"debian:12",
"debian:11",
"debian:10"
]
name: build on ${{ matrix.environment }}
runs-on: ubuntu-latest
container: ${{ matrix.environment }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: extract platform name
env:
DOCKER_IMAGE: ${{ matrix.environment }}
run: |
# Remove everything from DOCKER_IMAGE that is not a letter or a number
PLATFORM=$(echo -n "$DOCKER_IMAGE" | sed -E 's/[^a-zA-Z0-9]//g')
echo "PLATFORM=$PLATFORM" >> $GITHUB_ENV
- name: install dependencies from package management
env:
CC: ${{ matrix.cc }}
DEBIAN_FRONTEND: noninteractive
run: |
export DEBIAN_FRONTEND=noninteractive
apt-get update && apt-get dist-upgrade -y
apt-get install -y build-essential libusb-1.0.0-dev pkg-config chrpath git curl
echo "PLATFORM = $PLATFORM"
if [ $PLATFORM = "ubuntu1804" ] || [ "$PLATFORM" = "ubuntu1604" ] || [ $PLATFORM = "ubuntu1404" ] || [ $PLATFORM = "debian10" ]; then
curl -L --max-redirs 2 -o - https://golang.org/dl/go1.13.8.linux-amd64.tar.gz |\
tar -C /usr/local -xzvf -
else
apt-get install -y golang
fi
curl -L -o go-bin-deb.dpkg https://github.com/mh-cbon/go-bin-deb/releases/download/0.0.19/go-bin-deb-amd64.deb
dpkg -i go-bin-deb.dpkg
apt-get install --fix-missing
- name: build release
env:
PLATFORM: ${{ env.PLATFORM }}
run: |
set -x
# Create directory containing all output
OUTPUT=$GITHUB_WORKSPACE/$PLATFORM/yubihsm-connector
mkdir -p $OUTPUT
export PATH=$PATH:/usr/local/go/bin
make
strip --strip-all bin/yubihsm-connector
version=`bin/yubihsm-connector version`
go-bin-deb generate -f deb/deb.json -a amd64 --version=${version}-1
cp *.deb $OUTPUT/
LICESE_DIR="$OUTPUT/share/yubihsm-connector"
mkdir -p $LICESE_DIR
cp -r $GITHUB_WORKSPACE/resources/release/licenses $LICESE_DIR/
for lf in $LICESE_DIR/licenses/*; do
chmod 644 $lf
done
cd $OUTPUT
rm -f yubihsm-connector-$PLATFORM-amd64.tar.gz
tar -C .. -zcvf ../yubihsm-connector-$PLATFORM-amd64.tar.gz yubihsm-connector
rm -f *.deb
rm -rf licenses
rm -rf ../yubihsm-connector
- name: install binaries
run: |
set -x
dpkg -i ./yubihsm-connector_*.deb
- name: upload artifacts
uses: actions/upload-artifact@v3
with:
name: "yubihsm-connector-${{ env.PLATFORM }}-amd64"
path: ${{ env.PLATFORM }}
redhat_based:
strategy:
fail-fast: false
matrix:
environment: [
"fedora:37",
"fedora:38",
"centos:7"
]
cc: [ "gcc" ]
name: build on ${{ matrix.environment }}
runs-on: ubuntu-latest
container: ${{ matrix.environment }}
steps:
- name: checkout repository
uses: actions/checkout@v3
- name: extract platform name
env:
DOCKER_IMAGE: ${{ matrix.environment }}
run: |
# Remove everything from DOCKER_IMAGE that is not a letter or a number
PLATFORM=$(echo -n "$DOCKER_IMAGE" | sed -E 's/[^a-zA-Z0-9]//g')
echo "PLATFORM=$PLATFORM" >> $GITHUB_ENV
- name: install dependencies
env:
PLATFORM: ${{ env.PLATFORM }}
run: |
if [ $PLATFORM = "centos7" ]; then
yum -y install centos-release-scl
yum -y update && yum -y upgrade
yum -y install devtoolset-7-gcc \
devtoolset-7-gcc-c++ \
devtoolset-7-make \
make \
chrpath \
git \
libusbx-devel \
libseccomp-devel \
rpm-build \
redhat-rpm-config
. /opt/rh/devtoolset-7/enable
curl -L --max-redirs 2 -o - https://golang.org/dl/go1.13.8.linux-amd64.tar.gz |\
tar -C /usr/local -xzvf -
else
dnf -y update
dnf -y install gcc binutils git make libusb1-devel rpmdevtools golang
fi
- name: build release binaries
env:
PLATFORM: ${{ env.PLATFORM }}
run: |
export PATH=$PATH:/usr/local/go/bin:/opt/rh/devtoolset-7/root/usr/bin
export INPUT=$GITHUB_WORKSPACE
export OUTPUT=$GITHUB_WORKSPACE/$PLATFORM/yubihsm-connector
rm -rf $OUTPUT
mkdir -p $OUTPUT
mkdir -p $GITHUB_WORKSPACE/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
echo '%_topdir %(echo $HOME)/rpmbuild' > $GITHUB_WORKSPACE/.rpmmacros
RPM_DIR=$GITHUB_WORKSPACE/rpmbuild
cp resources/release/yubihsm-connector.spec $RPM_DIR/SPECS/
rpmbuild -bb $RPM_DIR/SPECS/yubihsm-connector.spec
cp /github/home/rpmbuild/RPMS/x86_64/*.rpm $OUTPUT/
LICENSE_DIR="$OUTPUT/share/yubihsm-connector"
mkdir -p $LICENSE_DIR
cp -r $INPUT/resources/release/licenses $LICENSE_DIR/
for lf in $LICENSE_DIR/licenses/*; do
chmod 644 $lf
done
cd $OUTPUT
rm -f "yubihsm-connector-$PLATFORM-amd64.tar.gz"
tar -C ".." -zcvf "../yubihsm-connector-$PLATFORM-amd64.tar.gz" "yubihsm-connector"
rm -f *.rpm
rm -rf licenses
rm -rf ../yubihsm-connector
- name: install binaries
working-directory: /github/home/rpmbuild/RPMS/x86_64
run: |
yum install -y ./yubihsm-connector-*.rpm
- name: upload artifacts
uses: actions/upload-artifact@v3
with:
name: "yubihsm-connector-${{ env.PLATFORM }}-amd64"
path: ${{ env.PLATFORM }}