-
Notifications
You must be signed in to change notification settings - Fork 13
246 lines (221 loc) · 8.12 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
name: publish release assets
on:
release:
types: [published]
jobs:
checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: verify changelogs
run: |
VERSION=$(awk '/static const char version/ { gsub(/[\";]/, "", $6); print $6; exit }' ttyrec.c)
if ! head -n1 debian/changelog | grep -F "ovh-ttyrec ($VERSION) master"; then
echo "inconsistency between version ($VERSION) and debian changelog:"
head -n1 debian/changelog
exit 1
fi
if ! grep -F " $VERSION" ovh-ttyrec.spec; then
echo "inconsistency between version ($VERSION) and rpm changelog:"
exit 1
fi
- name: install prerequisites
run: sudo apt-get update && sudo apt-get install -y uncrustify make git gcc
- name: check style
run: |
./configure
make style
git diff
if ! git diff --quiet; then
echo "Please make style."
exit 1
fi
- name: compile with zstd autodetection (none)
run: |
sudo apt-get remove --purge -y libzstd-dev
make clean && ./configure && make -j$(nproc) && ./ttyrec -V
if ./ttyrec -V | grep -qF 'zstd'; then
exit 1
fi
- name: compile with zstd autodetection (static)
run: |
sudo apt-get install -y libzstd-dev
make clean && ./configure && make -j$(nproc) && ./ttyrec -V
./ttyrec -V | grep -qF 'zstd[static]'
- name: compile with shared libzstd
run: |
make clean && NO_STATIC_ZSTD=1 ./configure && make -j$(nproc) && ./ttyrec -V
if ./ttyrec -V | grep -qF 'zstd[static]'; then
exit 1
fi
./ttyrec -V | grep -qF 'zstd'
- name: compile without zstd support
run: |
make clean && NO_ZSTD=1 ./configure && make -j$(nproc) && ./ttyrec -V
if ./ttyrec -V | grep -qF 'zstd'; then
exit 1
fi
- name: compile fully static version
run: |
make clean && STATIC=1 ./configure && make -j$(nproc) && ./ttyrec -V
./ttyrec -V | grep -qF 'zstd[static]'
if ldd ttyrec; then
exit 1
fi
multiarch:
needs: checks
runs-on: ubuntu-latest
strategy:
matrix:
cross:
- arm32v5
- arm32v7
- arm64v8
- ppc64le
- mips64le
- s390x
- i386
- amd64
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: prepare qemu
run: docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- name: install prerequisites
run: sudo apt-get update && sudo apt-get install -y rsync zip
- name: create source zip file for rpm build
run: |
curdir=$PWD
tempfolder=$(mktemp -d)
cd $tempfolder
mkdir ovh-ttyrec
rsync -va --exclude=.git $curdir/ ovh-ttyrec/
mkdir -p ~/rpmbuild/SOURCES
zip -9r ~/rpmbuild/SOURCES/master.zip ovh-ttyrec
- name: build for ${{ matrix.cross }}
run: >
mkdir /tmp/pkg &&
docker run --rm -e DEBIAN_FRONTEND=noninteractive
-v $PWD:/pkg/code
-v /tmp/pkg:/pkg
-v $HOME:/root
${{ matrix.cross }}/debian:10
/bin/bash -c '
set -exo pipefail;
apt-get update;
apt-get install -y make gcc libzstd-dev dpkg-dev debhelper unzip rpm binutils;
cd /pkg/code;
dpkg-buildpackage -b -rfakeroot -us -uc;
if [ "${{ matrix.cross }}" = i386 ]; then target="--target=i386"; else target=""; fi
set +o pipefail;
rpm --showrc | head;
set -o pipefail;
if [ $(rpm -E "%{_arch}") != "%{_arch}" ]; then
rpmbuild -bb $target ovh-ttyrec.spec;
else
arch=$(rpm --showrc | grep "^build arch" | awk "{print \$4}");
rpmbuild --define "_arch $arch" -bb $target ovh-ttyrec.spec;
fi;
mv ~/rpmbuild/RPMS/*/*.rpm /pkg;
STATIC=1 ./configure && make clean && make -j$(nproc) && ./ttyrec -V;
./ttyrec -V | grep -qF "zstd[static]";
if ldd ttyrec; then
exit 1;
fi;
version=$(./ttyrec -V | head -n1 | cut -d" " -f2 | grep -Eo "[0-9][A-Za-z0-9._-]+");
mkdir ovh-ttyrec-$version;
strip ttyrec ttyplay ttytime;
install ttyrec ttyplay ttytime ovh-ttyrec-$version;
cp -va docs ovh-ttyrec-$version;
staticname=ovh-ttyrec-${version}_$(dpkg --print-architecture)-linux-static-binary.tar.gz;
tar cvzf /pkg/$staticname ovh-ttyrec-$version;
'
- name: get release vars
id: getvars
run: |
rpmpath=$(find /tmp/pkg -mindepth 1 -maxdepth 1 -type f -name "*.rpm")
rpmname=$(basename "$rpmpath")
echo "RPM package name is $rpmname ($rpmpath)"
echo "::set-output name=rpmname::$rpmname"
echo "::set-output name=rpmpath::$rpmpath"
debpath=$(find /tmp/pkg -mindepth 1 -maxdepth 1 -type f -name "*.deb" ! -name "*dbgsym*")
debname=$(basename "$debpath")
echo "Debian package name is $debname ($debpath)"
echo "::set-output name=debname::$debname"
echo "::set-output name=debpath::$debpath"
staticpath=$(find /tmp/pkg -mindepth 1 -maxdepth 1 -type f -name "*-linux-static-binary.tar.gz" | head -n1)
staticname=$(basename "$staticpath")
echo "Static tar.gz archive name is $staticname ($staticpath)"
echo "::set-output name=staticname::$staticname"
echo "::set-output name=staticpath::$staticpath"
- name: upload rpm package
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ steps.getvars.outputs.rpmpath }}
asset_name: ${{ steps.getvars.outputs.rpmname }}
asset_content_type: application/x-rpm
- name: upload debian package
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ steps.getvars.outputs.debpath }}
asset_name: ${{ steps.getvars.outputs.debname }}
asset_content_type: application/x-debian-package
- name: upload static binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ steps.getvars.outputs.staticpath }}
asset_name: ${{ steps.getvars.outputs.staticname }}
asset_content_type: application/gzip
freebsd:
needs: checks
runs-on: macos-latest
name: FreeBSD
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Build for FreeBSD
id: build
uses: vmactions/freebsd-vm@v0
with:
usesh: true
sync: sshfs
run: |
set -ex
freebsd-version
pkg install -y gmake zstd
STATIC=1 ./configure
gmake
./ttyrec -V
./ttyrec -V | grep -qF "zstd[static]"
file ttyrec | grep -qF "statically"
version=$(./ttyrec -V | head -n1 | cut -d" " -f2 | grep -Eo "[0-9][A-Za-z0-9._-]+")
mkdir ovh-ttyrec-$version
strip ttyrec ttyplay ttytime
install ttyrec ttyplay ttytime ovh-ttyrec-$version
cp -va docs ovh-ttyrec-$version
staticname=ovh-ttyrec-${version}_$(uname -m)-freebsd-static-binary.tar.gz
tar cvzf $staticname ovh-ttyrec-$version
echo "Static tar.gz archive name is $staticname"
echo "::set-output name=staticname::$staticname"
- name: upload static binary
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ steps.build.outputs.staticname }}
asset_name: ${{ steps.build.outputs.staticname }}
asset_content_type: application/gzip