forked from pbek/QOwnNotes
-
Notifications
You must be signed in to change notification settings - Fork 1
315 lines (296 loc) · 11.1 KB
/
build-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
name: Build and Release QOwnNotes
on:
push:
branches:
- master
# - develop
tags-ignore:
- '*'
defaults:
run:
working-directory: src
jobs:
create_release:
permissions:
contents: write # for actions/create-release to create a release
name: Create release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
release_id: ${{ steps.create_release.outputs.id }}
steps:
- uses: actions/checkout@v3
- name: Set Env
run: |
export VERSION=$(cat version.h | sed 's/[^0-9,.]//g')
#export TAG=v${VERSION}.${GITHUB_RUN_ID}.${GITHUB_RUN_NUMBER}
export TAG=v${VERSION}
export RELEASE_TEXT=$(grep -Pzo "## ${VERSION}\n(\n|.)+?\n##" ../CHANGELOG.md | sed '$ d')
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "TAG=${TAG}" >> $GITHUB_ENV
# add multiline release text
echo "RELEASE_TEXT<<EOF" >> $GITHUB_ENV
echo "${RELEASE_TEXT}" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Printenv
run: |
echo "VERSION=${VERSION}"
echo "TAG=${TAG}"
echo "RELEASE_TEXT=${RELEASE_TEXT}"
printenv
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.TAG }}
release_name: Release v${{ env.VERSION }}
body: ${{ env.RELEASE_TEXT }}
draft: true
prerelease: false
build:
needs: create_release
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# Ubuntu 18.04 because of https://github.com/probonopd/linuxdeployqt/issues/340
# Ubuntu 18.04 because of samuelmeuli/action-snapcraft
os: [ubuntu-18.04, macos-latest, windows-2019]
# Linux: https://download.qt.io/online/qtsdkrepository/linux_x64/desktop/
# macOS: https://download.qt.io/online/qtsdkrepository/mac_x64/desktop/
# Windows: https://download.qt.io/online/qtsdkrepository/windows_x86/desktop/
qt-version: ['5.15.2']
app-image: [true, false]
exclude:
- os: windows-2019
app-image: true
- os: macos-latest
app-image: true
# exclude:
# - os: ubuntu-18.04
# qt-version: '5.13.2'
# - os: ubuntu-18.04
# qt-version: '5.13.2'
# - os: macos-latest
# qt-version: '5.13.2'
# - os: windows-2019
# qt-version: '5.15.2'
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Set Env
shell: bash
run: |
export VERSION=$(cat version.h | sed 's/[^0-9,.]//g')
echo "VERSION=${VERSION}" >> $GITHUB_ENV
#
# Install Snapcraft & Qt
#
- if: contains( matrix.os, 'ubuntu-18') && !matrix.app-image
name: Install Snapcraft
uses: samuelmeuli/action-snapcraft@v1
with:
use_lxd: true
# snapcraft_token: ${{ secrets.SNAP_TOKEN_GH }}
- name: Cache Qt
id: cache-qt
uses: actions/cache@v3
with:
path: ../Qt
key: ${{ runner.os }}-QtCache-${{ matrix.qt-version }}
# https://github.com/marketplace/actions/install-qt
- if: contains( matrix.os, 'windows')
name: Install Qt on Windows
uses: jurplel/install-qt-action@v3
with:
version: ${{ matrix.qt-version }}
arch: win64_mingw81
cache: ${{ steps.cache-qt.outputs.cache-hit }}
- if: false == contains( matrix.os, 'windows')
name: Install Qt on Linux/macOS
uses: jurplel/install-qt-action@v3
with:
version: ${{ matrix.qt-version }}
cache: ${{ steps.cache-qt.outputs.cache-hit }}
- name: Printenv
shell: bash
run: |
echo "VERSION=${VERSION}"
printenv
#
# Build QOwnNotes
#
# - name: Build
# run: |
# echo "#define RELEASE \"GitHub Action\"" > release.h
# qmake
# lrelease QOwnNotes.pro
# make
- if: contains( matrix.os, 'ubuntu-18') && !matrix.app-image
name: Build for Snapcraft
run: cd .. && sg lxd -c 'snapcraft --use-lxd' && ls
- if: contains( matrix.os, 'ubuntu-18') && matrix.app-image
name: Build for Linux
run: |
sudo apt install desktop-file-utils libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-render-util0 libxcb-xinerama0 libxcb-composite0 libxcb-cursor0 libxcb-damage0 libxcb-dpms0 libxcb-dri2-0 libxcb-dri3-0 libxcb-ewmh2 libxcb-glx0 libxcb-present0 libxcb-randr0 libxcb-record0 libxcb-render0 libxcb-res0 libxcb-screensaver0 libxcb-shape0 libxcb-shm0 libxcb-sync1 libxcb-util1
echo "#define RELEASE \"AppImage\"" > release.h
qmake PREFIX=/usr
lrelease QOwnNotes.pro
make -j 8
# Create DEB
#cd ../travis
#dpkg-deb -x QOwnNotes.deb build
#install ../src/QOwnNotes build/opt/QOwnNotes
#mkdir -p build/usr/bin
#ln -s /opt/QOwnNotes/QOwnNotes build/usr/bin
#mv ../src/languages/*.qm build/opt/QOwnNotes/
#mv ../icons/* build/opt/QOwnNotes/
#sed -i 's/VERSION_NUMBER/'"${VERSION}"'/g' build/DEBIAN/control
#dpkg -b build QOwnNotes.deb
#cd ../src
# Create AppImage (needs Ubuntu 18.04)
make INSTALL_ROOT=appdir -j 8 install ; find appdir/
mkdir -p appdir/usr/languages
# mv translations to appdir (where QOwnNotes will find them)
mv ./languages/*.qm appdir/usr/languages
wget -c -nv "https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage"
chmod a+x linuxdeployqt-continuous-x86_64.AppImage
# export VERSION=... # linuxdeployqt uses this for naming the file
./linuxdeployqt-continuous-x86_64.AppImage appdir/usr/share/applications/*.desktop -appimage -verbose=2
mv "QOwnNotes-${VERSION}-x86_64.AppImage" QOwnNotes-x86_64.AppImage
sha256sum QOwnNotes-x86_64.AppImage > QOwnNotes-x86_64.AppImage.sha256sum
- if: contains( matrix.os, 'macos')
name: Build for macOS
run: |
echo "#define RELEASE \"GitHub Actions\"" > release.h
lrelease QOwnNotes.pro
#ls ${Qt5_Dir}/bin
qmake
make -j 8
../build-systems/github/macos/create-dmg.sh
- if: contains( matrix.os, 'windows')
name: Build for Windows
run: '& ..\build-systems\github\windows\build-zip.ps1'
#
# Release QOwnNotes
#
# - if: contains( matrix.os, 'ubuntu-18')
# name: Release DEB package for Linux
# uses: actions/upload-release-asset@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# upload_url: ${{ needs.create_release.outputs.upload_url }}
# asset_path: ./travis/QOwnNotes.deb
# asset_name: QOwnNotes.deb
# asset_content_type: application/vnd.debian.binary-package
- if: contains( matrix.os, 'ubuntu-18') && !matrix.app-image
name: Release Snap for Linux
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ./qownnotes_${{ env.VERSION }}_amd64.snap
asset_name: QOwnNotes-amd64.snap
asset_content_type: application/octet-stream
# - if: contains( matrix.os, 'ubuntu-18') && !matrix.app-image
# shell: bash
# run: |
# snapcraft --version
# cd .. && pwd
- if: contains( matrix.os, 'ubuntu-18') && !matrix.app-image
name: Deploy Snap
uses: snapcore/action-publish@v1
continue-on-error: true
env:
# `snapcraft export-login --snaps=qownnotes --acls package_access,package_push,package_update,package_release -`, token valid for one year
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAP_TOKEN_GH }}
with:
snap: /home/runner/work/QOwnNotes/QOwnNotes/qownnotes_${{ env.VERSION }}_amd64.snap
release: stable
- if: contains( matrix.os, 'ubuntu-18') && !matrix.app-image
uses: actions/upload-artifact@v3
with:
name: snapcraft-logs
path: /home/runner/.cache/snapcraft/log/snapcraft-*.log
# - if: contains( matrix.os, 'ubuntu-18') && !matrix.app-image
# name: Fail
# shell: bash
# run: curl --fail
# - if: contains( matrix.os, 'ubuntu-18') && !matrix.app-image
# name: Deploy Snap
# env:
# # `snapcraft export-login --snaps qownnotes --channels edge,stable -`, token valid for one year
# SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAP_TOKEN_GH }}
# shell: bash
# run: |
# snapcraft --version
# cd .. && ls
# if [ -n "$(ls *.snap 2>/dev/null)" ]; then
# sudo snapcraft upload *.snap --release stable
# fi
- if: contains( matrix.os, 'ubuntu-18') && matrix.app-image
name: Release AppImage for Linux
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ./src/QOwnNotes-x86_64.AppImage
asset_name: QOwnNotes-x86_64.AppImage
asset_content_type: application/vnd.appimage
- if: contains( matrix.os, 'ubuntu-18') && matrix.app-image
name: Release AppImage sha256sum for Linux
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ./src/QOwnNotes-x86_64.AppImage.sha256sum
asset_name: QOwnNotes-x86_64.AppImage.sha256sum
asset_content_type: text/plain
- if: contains( matrix.os, 'macos')
name: Release DMG for macOS
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ./src/QOwnNotes.dmg
asset_name: QOwnNotes.dmg
asset_content_type: application/x-apple-diskimage
- if: contains( matrix.os, 'windows')
name: Upload ZIP for Windows
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ./QOwnNotes.zip
asset_name: QOwnNotes.zip
asset_content_type: application/zip
- if: contains( matrix.os, 'windows')
name: Upload sha256 sum for Windows
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: ./QOwnNotes.zip.sha256
asset_name: QOwnNotes.zip.sha256
asset_content_type: text/plain
publish_release:
name: Publish release
runs-on: ubuntu-latest
needs: [create_release, build]
steps:
- name: Publish draft release
uses: eregon/publish-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ needs.create_release.outputs.release_id }}