-
Notifications
You must be signed in to change notification settings - Fork 7
343 lines (292 loc) · 10.4 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
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
name: Create-Release
run-name: Create release ${{github.ref_name}}
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
jobs:
Checks:
runs-on: ubuntu-latest
timeout-minutes: 3
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Set version
run: |
echo VERSION="$(echo '${{github.ref_name}}' | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')" >> $GITHUB_ENV
- name: Check app.rc version
run: |
[ $(grep "${{env.VERSION}}" res/win/app.rc | grep -iE '(File|Product)Version' | wc -l) = 4 ]
- name: Check release_notes.md version
run: |
for v in $(grep -oE '[0-9]+\.[0-9]+\.[0-9]+' .github/workflows/resources/release_notes.md); do \
grep -qF "${{env.VERSION}}" <<<"$v"; \
done
Build-and-Test:
uses: ./.github/workflows/build-test.yml
permissions:
contents: write
pull-requests: write
security-events: write
needs: Checks
Linux:
runs-on: ubuntu-latest
timeout-minutes: 20
needs:
- Checks
- Build-and-Test
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Set version
run: |
version="$(echo '${{github.ref_name}}' | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')"
archive="clip_share_server-${version}-linux_x86_64"
echo ARCHIVE_NAME_NO_EXT="${archive}" >> $GITHUB_ENV
echo ARCHIVE_NAME="${archive}.tar.gz" >> $GITHUB_ENV
- name: Build on Ubuntu 18
run: docker build -t clipshare:ubuntu18 -f docker/release/Dockerfile.ubuntu18 .
- name: Build on Ubuntu 20
run: docker build -t clipshare:ubuntu20 -f docker/release/Dockerfile.ubuntu20 .
- name: Build on Ubuntu 22
run: docker build -t clipshare:ubuntu22 -f docker/release/Dockerfile.ubuntu22 .
- name: Build on Ubuntu 24
run: docker build -t clipshare:ubuntu24 -f docker/release/Dockerfile.ubuntu24 .
- name: Build on Arch Linux
run: docker build -t clipshare:arch -f docker/release/Dockerfile.arch .
- name: Build on Fedora
run: docker build -t clipshare:fedora -f docker/release/Dockerfile.fedora .
- name: Copy binaries
run: |
mkdir dist
chmod 777 dist
docker run -v './dist:/home/user/src/dist' clipshare:ubuntu18
docker run -v './dist:/home/user/src/dist' clipshare:ubuntu20
docker run -v './dist:/home/user/src/dist' clipshare:ubuntu22
docker run -v './dist:/home/user/src/dist' clipshare:ubuntu24
docker run -v './dist:/home/user/src/dist' clipshare:arch
docker run -v './dist:/home/user/src/dist' clipshare:fedora
[ -f helper_tools/install-linux.sh ] && cp helper_tools/install-linux.sh dist/
sudo chmod +x dist/*
cd dist
sha256sum -b * >SHA2-256SUM
cd ..
mv dist "${{env.ARCHIVE_NAME_NO_EXT}}"
tar -cf - --sort=name --owner=root:0 --group=root:0 --no-same-owner "${{env.ARCHIVE_NAME_NO_EXT}}" | \
gzip -9 >"${{env.ARCHIVE_NAME}}"
- name: Upload Linux version
uses: actions/upload-artifact@v4
with:
name: "${{env.ARCHIVE_NAME}}"
path: "${{env.ARCHIVE_NAME}}"
retention-days: 3
if-no-files-found: error
compression-level: 0
Windows:
runs-on: windows-latest
timeout-minutes: 10
needs:
- Checks
- Build-and-Test
defaults:
run:
shell: msys2 {0}
steps:
- uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
update: false
install: >-
mingw-w64-x86_64-gcc
mingw-w64-x86_64-make
mingw-w64-x86_64-openssl
mingw-w64-x86_64-libpng
mingw-w64-x86_64-libunistring
zip
- name: Setup make
run: ln -s /mingw64/bin/mingw32-make.exe /mingw64/bin/make.exe
- name: Check out repository code
uses: actions/checkout@v4
- name: Set variables
run: |
version="$(echo '${{github.ref_name}}' | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')"
archive="clip_share_server-${version}-windows64.zip"
echo VERSION="$version" >> $GITHUB_ENV
echo FILE_NAME="clip_share.exe" >> $GITHUB_ENV
echo ARCHIVE_NAME="$archive" >> $GITHUB_ENV
echo INSTALLER_NAME="install-windows.bat" >> $GITHUB_ENV
- name: Build
run: |
make
mkdir dist
mv "clip_share.exe" "dist/${{env.FILE_NAME}}"
[ -f helper_tools/install-windows.bat ] && cp helper_tools/install-windows.bat dist/
cd dist
zip -9 "../${{env.ARCHIVE_NAME}}" *
- name: Create online installer
run: |
cd helper_tools
sed -i "s/VERSION_DEFAULT =$/VERSION_DEFAULT = '${{env.VERSION}}'/" install-online-windows.ps1
powershell -ExecutionPolicy bypass ./ps2bat.ps1
mv install.bat "../${{env.INSTALLER_NAME}}"
- name: Upload Windows version
uses: actions/upload-artifact@v4
with:
name: "${{env.ARCHIVE_NAME}}"
path: "${{env.ARCHIVE_NAME}}"
retention-days: 3
if-no-files-found: error
compression-level: 9
- name: Upload online installer
uses: actions/upload-artifact@v4
with:
name: "${{env.INSTALLER_NAME}}"
path: "${{env.INSTALLER_NAME}}"
retention-days: 3
if-no-files-found: error
compression-level: 6
macOS:
needs:
- Checks
- Build-and-Test
strategy:
matrix:
os:
- macos-latest
- macos-13
runs-on: ${{ matrix.os }}
timeout-minutes: 10
steps:
- name: Install dependencies
run: brew install openssl@3 libpng libunistring
- name: Check out repository code
uses: actions/checkout@v4
- name: Set version
run: |
arch_suffix="$(uname -a | grep -q x86_64 && echo x86_64 || echo arm64)"
filename="clip_share-${arch_suffix}"
echo FILE_NAME="$filename" >> $GITHUB_ENV
- name: Build
run: |
make
mv "clip_share" "${{env.FILE_NAME}}"
- name: Upload macOS binary
uses: actions/upload-artifact@v4
with:
name: "${{env.FILE_NAME}}"
path: "${{env.FILE_NAME}}"
retention-days: 1
if-no-files-found: error
compression-level: 0
macOS_all:
needs: macOS
runs-on: macos-latest
timeout-minutes: 5
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Set version
run: |
version="$(echo '${{github.ref_name}}' | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')"
archive_name="clip_share_server-${version}-macos.zip"
echo ARCHIVE_NAME="$archive_name" >> $GITHUB_ENV
echo FILE_INTEL="clip_share-x86_64" >> $GITHUB_ENV
echo FILE_ARM="clip_share-arm64" >> $GITHUB_ENV
- name: Download macOS x86_64 version
uses: actions/download-artifact@v4
with:
name: "${{env.FILE_INTEL}}"
path: "${{env.FILE_INTEL}}"
- name: Download macOS ARM64 version
uses: actions/download-artifact@v4
with:
name: "${{env.FILE_ARM}}"
path: "${{env.FILE_ARM}}"
- name: Archive
run: |
mkdir dist
mv "${{env.FILE_INTEL}}/${{env.FILE_INTEL}}" "${{env.FILE_ARM}}/${{env.FILE_ARM}}" dist/
[ -f helper_tools/install-mac.sh ] && cp helper_tools/install-mac.sh dist/
chmod +x dist/*
cd dist
rm -f .DS_Store
zip -9 "../${{env.ARCHIVE_NAME}}" *
- name: Upload macOS version
uses: actions/upload-artifact@v4
with:
name: "${{env.ARCHIVE_NAME}}"
path: "${{env.ARCHIVE_NAME}}"
retention-days: 3
if-no-files-found: error
compression-level: 0
Create_Release:
needs:
- Linux
- Windows
- macOS_all
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: write
id-token: write
attestations: write
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Set variables
run: |
version="$(echo '${{github.ref_name}}' | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')"
echo VERSION="$version" >> $GITHUB_ENV
echo TAG="v${version}" >> $GITHUB_ENV
echo TITLE="Version ${version}" >> $GITHUB_ENV
echo FILE_LINUX="clip_share_server-${version}-linux_x86_64.tar.gz" >> $GITHUB_ENV
echo FILE_WINDOWS="clip_share_server-${version}-windows64.zip" >> $GITHUB_ENV
echo INSTALLER_WINDOWS="install-windows.bat" >> $GITHUB_ENV
echo FILE_MACOS="clip_share_server-${version}-macos.zip" >> $GITHUB_ENV
- name: Download Linux version
uses: actions/download-artifact@v4
with:
name: "${{env.FILE_LINUX}}"
path: "${{env.FILE_LINUX}}"
- name: Download Windows version
uses: actions/download-artifact@v4
with:
name: "${{env.FILE_WINDOWS}}"
path: "${{env.FILE_WINDOWS}}"
- name: Download Windows installer
uses: actions/download-artifact@v4
with:
name: "${{env.INSTALLER_WINDOWS}}"
path: "${{env.INSTALLER_WINDOWS}}"
- name: Download macOS version
uses: actions/download-artifact@v4
with:
name: "${{env.FILE_MACOS}}"
path: "${{env.FILE_MACOS}}"
- name: Prepare assets
run: |
mkdir release
mv "${{env.FILE_LINUX}}/${{env.FILE_LINUX}}" release/
mv "${{env.FILE_WINDOWS}}/${{env.FILE_WINDOWS}}" release/
mv "${{env.INSTALLER_WINDOWS}}/${{env.INSTALLER_WINDOWS}}" release/
mv "${{env.FILE_MACOS}}/${{env.FILE_MACOS}}" release/
mv .github/workflows/resources/clipshare.conf release/
mv helper_tools/install-online-linux-mac.sh release/install-linux-mac.sh
cd release
sed -i "s/^VERSION_DEFAULT=$/VERSION_DEFAULT=${{env.VERSION}}/" install-linux-mac.sh
sha256sum -b * >SHA2-256SUM
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-path: "release/SHA2-256SUM"
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
sed -i "s/<VERSION>/${{env.VERSION}}/g" .github/workflows/resources/release_notes.md
sed -i "s/<FILE_LINUX>/${{env.FILE_LINUX}}/g" .github/workflows/resources/release_notes.md
sed -i "s/<FILE_MACOS>/${{env.FILE_MACOS}}/g" .github/workflows/resources/release_notes.md
cd release
gh release create "${{env.TAG}}" --latest --verify-tag \
--notes-file ../.github/workflows/resources/release_notes.md \
--title "${{env.TITLE}}" *