Skip to content

Commit 44e5e00

Browse files
authored
Merge pull request #41 from scratchcpp/release_workflow
Add release workflow
2 parents de5656e + 4d669d3 commit 44e5e00

File tree

1 file changed

+238
-0
lines changed

1 file changed

+238
-0
lines changed

.github/workflows/release.yml

Lines changed: 238 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,238 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags: '*'
6+
7+
jobs:
8+
build-linux-release:
9+
runs-on: ubuntu-20.04
10+
strategy:
11+
matrix:
12+
qt-version: ['6.6']
13+
qt-target: ['desktop']
14+
qt-modules: ['']
15+
arch: ['amd64']
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
submodules: 'recursive'
21+
- name: Setup environment
22+
run: |
23+
sed -i -e '/^#/d' .github/config.env
24+
sed -i -e '/^$/d' .github/config.env
25+
cat .github/config.env >> "${GITHUB_ENV}"
26+
shell: bash
27+
- name: Set up node.js
28+
uses: actions/setup-node@v3
29+
- if: env.build_on_new_tags != 1
30+
name: Cancel if build on new tags is disabled
31+
uses: andymckay/cancel-action@0.2
32+
- if: contains(matrix.arch, 'amd64')
33+
name: Install dependencies
34+
run: |
35+
sudo apt-get update
36+
sudo apt-get install -y libxkbcommon-x11-0
37+
shell: bash
38+
- name: Get version
39+
run: |
40+
version=$(LC_ALL=en_US.utf8 grep -oP 'project\([^)]*\s+VERSION\s+\K[0-9]+\.[0-9]+\.[0-9]+' CMakeLists.txt)
41+
echo "Project version: $version"
42+
echo previous_tag=$version >> "${GITHUB_ENV}"
43+
shell: bash
44+
- if: contains(github.ref, '-')
45+
name: Check if this is a pre-release
46+
run: echo is_prerelease=1 >> "${GITHUB_ENV}"
47+
shell: bash
48+
# Install Qt
49+
- if: contains(matrix.arch, 'amd64')
50+
name: Install Qt
51+
uses: jurplel/install-qt-action@v3
52+
with:
53+
version: ${{ matrix.qt-version }}
54+
host: 'linux'
55+
target: ${{ matrix.qt-target }}
56+
modules: ${{ matrix.qt-modules }}
57+
- if: "!contains(matrix.arch, 'amd64')"
58+
name: Restore cross-compiled Qt from cache
59+
id: cache-qt-cross
60+
uses: actions/cache@v3
61+
with:
62+
path: |
63+
./qt-host/
64+
./qt-cross/
65+
./sysroot/
66+
key: qt-cross-${{ runner.os }}-${{ matrix.qt-version }}-${{ matrix.qt-target }}-${{ matrix.qt-modules }}-${{ matrix.arch }}
67+
restore-keys:
68+
qt-cross-${{ runner.os }}-${{ matrix.qt-version }}-${{ matrix.qt-target }}-${{ matrix.qt-modules }}-${{ matrix.arch }}
69+
- if: "!contains(matrix.arch, 'amd64') && steps.cache-qt-cross.outputs.cache-hit != 'true'"
70+
name: Cross-compile Qt
71+
shell: bash
72+
run: .ci/build_qt6.sh "${{ matrix.qt-version }}" "${{ matrix.qt-modules }}" "${{ matrix.arch }}"
73+
# Build
74+
- if: "!contains(matrix.arch, 'amd64')"
75+
name: Prepare cross-compilation environment
76+
run: .ci/prepare_cross_build.sh "${{ matrix.arch }}"
77+
shell: bash
78+
- name: Build AppImage
79+
run: .ci/build_appimage.sh
80+
shell: 'script -q -e -c "bash {0}"'
81+
# Upload artifacts
82+
- name: Upload artifacts
83+
uses: actions/upload-artifact@v3
84+
with:
85+
name: build-linux-${{ matrix.arch }}
86+
path: |
87+
*.AppImage
88+
*.zsync
89+
90+
build-windows-release:
91+
runs-on: windows-latest
92+
strategy:
93+
matrix:
94+
qt-version: ['6.6']
95+
qt-target: ['desktop']
96+
qt-modules: ['']
97+
mingw-version: ['11.2.0']
98+
steps:
99+
- uses: actions/checkout@v4
100+
with:
101+
fetch-depth: 0
102+
submodules: 'recursive'
103+
- name: Setup environment
104+
run: |
105+
sed -i -e '/^#/d' .github/config.env
106+
sed -i -e '/^$/d' .github/config.env
107+
cat .github/config.env >> "${GITHUB_ENV}"
108+
shell: bash
109+
- name: Set up node.js
110+
uses: actions/setup-node@v3
111+
- if: env.build_on_new_tags != 1
112+
name: Cancel if build on new tags is disabled
113+
uses: andymckay/cancel-action@0.2
114+
- name: Get version
115+
run: |
116+
version=$(LC_ALL=en_US.utf8 grep -oP 'project\([^)]*\s+VERSION\s+\K[0-9]+\.[0-9]+\.[0-9]+' CMakeLists.txt)
117+
echo "Project version: $version"
118+
echo previous_tag=$version >> "${GITHUB_ENV}"
119+
shell: bash
120+
- if: contains(github.ref, '-')
121+
name: Check if this is a pre-release
122+
run: echo is_prerelease=1 >> "${GITHUB_ENV}"
123+
shell: bash
124+
# Install Qt
125+
- name: Install Qt
126+
uses: jurplel/install-qt-action@v3
127+
with:
128+
version: ${{ matrix.qt-version }}
129+
host: 'windows'
130+
arch: 'win64_mingw'
131+
target: ${{ matrix.qt-target }}
132+
modules: ${{ matrix.qt-modules }}
133+
- name: Install Qt IFW
134+
run: |
135+
curl -o aqt.exe -L https://github.com/miurahr/aqtinstall/releases/download/v2.2.1/aqt.exe
136+
./aqt.exe install-tool windows desktop tools_ifw
137+
mv Tools ..
138+
echo ${pwd}/../Tools/QtInstallerFramework/*/bin >> "${GITHUB_PATH}"
139+
shell: bash
140+
- name: Install MinGW
141+
uses: egor-tensin/setup-mingw@v2
142+
with:
143+
platform: x64
144+
static: 0
145+
version: ${{ matrix.mingw-version }}
146+
# Build
147+
- name: Build
148+
run: .ci/common/build.sh win_build win64
149+
shell: bash
150+
- name: Deploy
151+
run: |
152+
mkdir win_release
153+
for /r win_build %%f in (${{ env.executable_name }}.exe) do @move "%%f" win_release
154+
for /r win_build %%f in (*.dll) do @move "%%f" win_release
155+
cd win_release
156+
windeployqt ${{ env.executable_name }}.exe --qmldir ..\win_build\src || exit 5
157+
shell: cmd
158+
# Update Windows repository
159+
- if: env.create_windows_installer == 1 && env.is_prerelease == 1
160+
name: Do not update Windows repo if this is a pre-release
161+
run: |
162+
echo update_windows_installer=0 >> "${GITHUB_ENV}"
163+
echo update_windows_repository=0 >> "${GITHUB_ENV}"
164+
shell: bash
165+
- if: env.create_windows_installer == 1
166+
name: Get installer repository
167+
uses: actions/checkout@v4
168+
with:
169+
repository: ${{ env.installer_repo_github }}/${{ env.installer_repo_name }}
170+
fetch-depth: 0
171+
path: win_repo
172+
token: ${{ secrets.PUSH_TOKEN }}
173+
- if: env.create_windows_installer == 1
174+
name: Build installer
175+
run: .ci/windows_installer.sh "${GITHUB_WORKSPACE}/win_repo"
176+
shell: bash
177+
# Upload artifacts
178+
- name: Upload artifacts
179+
uses: actions/upload-artifact@v3
180+
with:
181+
name: build-windows
182+
path: '*installer.exe'
183+
184+
# Release
185+
release:
186+
runs-on: ubuntu-latest
187+
needs: [build-linux-release, build-windows-release]
188+
steps:
189+
- uses: actions/checkout@v3
190+
with:
191+
fetch-depth: 0
192+
submodules: 'recursive'
193+
- name: Setup environment
194+
run: |
195+
sed -i -e '/^#/d' .github/config.env
196+
sed -i -e '/^$/d' .github/config.env
197+
cat .github/config.env >> "${GITHUB_ENV}"
198+
GITHUB_REF_NAME="${{ github.ref_name }}"
199+
echo "version=${GITHUB_REF_NAME//v/}" >> $GITHUB_ENV
200+
shell: bash
201+
#- uses: actions/checkout@v4
202+
# with:
203+
# repository: ${{ github.repository_owner }}/${{ env.online_app_repo }}
204+
# fetch-depth: 0
205+
# token: ${{ secrets.PUSH_TOKEN }}
206+
# path: online-app
207+
- if: contains(github.ref, '-')
208+
name: Check if this is a pre-release
209+
run: echo is_prerelease=1 >> "${GITHUB_ENV}"
210+
shell: bash
211+
- name: Download artifacts
212+
uses: actions/download-artifact@v3
213+
#- if: env.upload_online_app == 1
214+
# name: Upload online app
215+
# run: |
216+
# cd online-app
217+
# git checkout --orphan new-branch
218+
# mv ../build-wasm/* ./
219+
# rm -f index.html
220+
# ln -s ${{ env.executable_name }}.html index.html
221+
# git config user.name "GitHub Actions Bot"
222+
# git config user.email "<>"
223+
# git add -A
224+
# git commit -m "Add new release files"
225+
# git branch -D master
226+
# git branch -m master
227+
# git push -f origin master
228+
# shell: bash
229+
- if: env.create_release == 1
230+
name: Create release
231+
uses: ncipollo/release-action@v1
232+
with:
233+
#artifacts: "build-windows/*.exe,build-linux-*/*.AppImage,build-linux-*/*.zsync,build-macos/*.dmg"
234+
artifacts: "build-windows/*.exe,build-linux-*/*.AppImage,build-linux-*/*.zsync"
235+
name: "${{ env.app_name }} ${{ env.version }}"
236+
owner: ${{ github.event.pusher.name }}
237+
draft: true
238+
token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)