Skip to content

Commit 3041236

Browse files
committed
Create the release github actions
1 parent 10cdeb4 commit 3041236

File tree

4 files changed

+255
-3
lines changed

4 files changed

+255
-3
lines changed

.github/workflows/build_tests_linux.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ on:
88
- gha
99
- Qt4
1010
- Qt4-dev
11-
tags-ignore:
11+
tags-ignore: '*'
12+
paths-ignore: '/.github/workflows/release.yml'
1213
pull_request:
1314

1415
env:

.github/workflows/build_tests_macos.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ on:
88
- gha
99
- Qt4
1010
- Qt4-dev
11-
tags-ignore:
11+
tags-ignore: '*'
12+
paths-ignore: '/.github/workflows/release.yml'
1213
pull_request:
1314

1415
env:

.github/workflows/build_tests_windows.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ on:
88
- gha
99
- Qt4
1010
- Qt4-dev
11-
tags-ignore:
11+
tags-ignore: '*'
12+
paths-ignore: '/.github/workflows/release.yml'
1213
pull_request:
1314

1415
env:

.github/workflows/release.yml

Lines changed: 249 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
name: release
2+
# Based on https://github.com/ra3xdh/qucs_s/.github/workflows/deploy.yml
3+
4+
on:
5+
push:
6+
tags:
7+
- '*'
8+
9+
env:
10+
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
11+
# Problems with Debian 9, Ubuntu 18 and older:
12+
# - Repositories are not available for Debian 9 and it is not possible
13+
# to install the required packages.
14+
# - Both Debian 9 and Ubuntu 18 (and older) do not work with Node20.
15+
# It is possible to rollback to Node16 using
16+
# env:ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true, but in this case
17+
# the unloading of received artefacts does not work.
18+
# Errors while actions/checkout@v3 or actions/upload-artifact@v4:
19+
# /__e/node20/bin/node: /lib/x86_64-linux-gnu/libm.so.6: version `GLIBC_2.27' not found (required by /__e/node20/bin/node)
20+
# /__e/node20/bin/node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by /__e/node20/bin/node)
21+
# /__e/node20/bin/node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.25' not found (required by /__e/node20/bin/node)
22+
# https://github.com/actions/checkout/issues/1590
23+
# https://github.blog/changelog/2024-03-07-github-actions-all-actions-will-run-on-node20-instead-of-node16-by-default/
24+
25+
jobs:
26+
setup:
27+
runs-on: ubuntu-22.04
28+
outputs:
29+
version: ${{ steps.get_version.outputs.version }}
30+
steps:
31+
- name: Checkout repository
32+
uses: actions/checkout@v4
33+
34+
- name: Extract version
35+
id: get_version
36+
run: |
37+
if [ "${{github.ref_type}}" = "tag" ]; then
38+
VERSION="$(echo ${{ github.ref_name }} | grep -Eo '[[:digit:]]+.*')"
39+
else
40+
VERSION="$(git rev-parse --short HEAD)"
41+
fi
42+
43+
echo "VERSION=$VERSION" >> $GITHUB_ENV
44+
echo "version=$VERSION" >> $GITHUB_OUTPUT
45+
46+
- name: Print version
47+
run: echo "Version is \"${{ env.VERSION }}\""
48+
49+
# https://en.wikipedia.org/wiki/Debian_version_history
50+
# https://hub.docker.com/_/debian
51+
build-debian-packages:
52+
runs-on: ubuntu-22.04
53+
needs: setup
54+
strategy:
55+
fail-fast: false
56+
matrix:
57+
distr:
58+
- name: trixie
59+
version: 13
60+
extra_pack: ""
61+
- name: bookworm
62+
version: 12
63+
extra_pack: ""
64+
- name: bullseye
65+
version: 11
66+
extra_pack: ""
67+
- name: buster
68+
version: 10
69+
extra_pack: "qt5-default"
70+
arch:
71+
- name: amd64
72+
id: linux/amd64
73+
container:
74+
image: debian:${{matrix.distr.name}}
75+
options: --platform ${{matrix.arch.id}}
76+
steps:
77+
- name: Checkout repository
78+
uses: actions/checkout@v4
79+
80+
- name: Install dependencies
81+
run: |
82+
apt-get update
83+
# https://serverfault.com/a/992421
84+
DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install -y build-essential qtbase5-dev libqt5webkit5-dev gettext libzip-dev libchm-dev ${{matrix.distr.extra_pack}}
85+
86+
- name: Build
87+
run: packages/build-deb.sh -s debian-${{matrix.distr.name}} -v ${{ needs.setup.outputs.version }}
88+
89+
- name: Upload debian packages
90+
uses: actions/upload-artifact@v4
91+
with:
92+
name: debian-${{matrix.distr.name}}-${{matrix.arch.name}}
93+
path: '*.deb'
94+
95+
# https://en.wikipedia.org/wiki/Ubuntu_version_history
96+
# https://hub.docker.com/_/ubuntu
97+
build-ubuntu-packages:
98+
runs-on: ubuntu-22.04
99+
needs: setup
100+
strategy:
101+
fail-fast: false
102+
matrix:
103+
distr:
104+
- name: noble
105+
version: 24.04
106+
extra_pack: ""
107+
- name: jammy
108+
version: 22.04
109+
extra_pack: ""
110+
- name: focal
111+
version: 20.04
112+
extra_pack: "qt5-default"
113+
arch:
114+
- name: amd64
115+
id: linux/amd64
116+
container:
117+
image: ubuntu:${{matrix.distr.name}}
118+
options: --platform ${{matrix.arch.id}}
119+
steps:
120+
- name: Checkout repository
121+
uses: actions/checkout@v4
122+
123+
- name: Install Dependencies
124+
run: |
125+
apt-get update
126+
DEBIAN_FRONTEND=noninteractive TZ=Etc/UTC apt-get install -y build-essential qtbase5-dev libqt5webkit5-dev gettext libzip-dev libchm-dev ${{matrix.distr.extra_pack}}
127+
128+
- name: Build
129+
run: packages/build-deb.sh -s ubuntu-${{matrix.distr.name}} -v ${{ needs.setup.outputs.version }}
130+
131+
- name: Upload ubuntu packages
132+
uses: actions/upload-artifact@v4
133+
with:
134+
name: ubuntu-${{matrix.distr.name}}-${{matrix.arch.name}}
135+
path: '*.deb'
136+
137+
build-windows-installer:
138+
runs-on: windows-2022
139+
needs: setup
140+
strategy:
141+
fail-fast: false
142+
matrix:
143+
msystem:
144+
- mingw64
145+
- mingw32
146+
defaults:
147+
run:
148+
shell: msys2 {0}
149+
steps:
150+
- name: Disable autocrlf in Git
151+
shell: pwsh
152+
# https://github.com/msys2/setup-msys2?tab=readme-ov-file#actionscheckout-and-line-endings
153+
run: |
154+
git config --global core.autocrlf false
155+
git config --global core.eol lf
156+
157+
- name: Checkout repository
158+
uses: actions/checkout@v4
159+
with:
160+
submodules: true
161+
162+
- name: Set up MSYS2 environment
163+
uses: msys2/setup-msys2@v2
164+
with:
165+
msystem: ${{matrix.msystem}}
166+
cache: true
167+
update: true
168+
install: >-
169+
make
170+
zip
171+
pacboy: >-
172+
gcc:p
173+
nsis:p
174+
ntldd:p
175+
libzip:p
176+
qt5-base:p
177+
qt5-translations:p
178+
qtwebkit:p
179+
180+
- name: Build
181+
run: packages/build-win-msys2.sh -s windows -v ${{ needs.setup.outputs.version }}
182+
183+
- name: Upload windows installers
184+
uses: actions/upload-artifact@v4
185+
with:
186+
name: windows-${{matrix.msystem}}
187+
path: |
188+
*.exe
189+
*.zip
190+
191+
create-release:
192+
runs-on: ubuntu-22.04
193+
needs: [build-debian-packages, build-ubuntu-packages, build-windows-installer]
194+
steps:
195+
- name: Download build artifacts
196+
uses: actions/download-artifact@v4
197+
with:
198+
path: ~/artifacts
199+
merge-multiple: true
200+
201+
- name: Calculate SHA-256 checksums
202+
run: |
203+
cd ~/artifacts
204+
echo 'SHA-256 checksums' > notes.txt
205+
echo '-----------------' >> notes.txt
206+
echo -e '\n```' >> notes.txt
207+
for file in $(find . -type f \( -name "*.exe" -o -name "*.zip" -o -name "*.deb" -o -name "*.rpm" \) | sort); do
208+
filename=$(basename "$file")
209+
checksum=$(sha256sum "$file" | awk '{print $1}')
210+
echo "$checksum $filename" >> notes.txt
211+
#echo $checksum > "$filename".sha256
212+
done
213+
echo -e '```\n' >> notes.txt
214+
cd ..
215+
tree ~/artifacts
216+
217+
- name: Setup Release Information
218+
run: |
219+
echo "RELEASE_NAME=${{ github.ref_name }}" >> $GITHUB_ENV
220+
echo "TAG_NAME=${{ github.ref_name }}" >> $GITHUB_ENV
221+
222+
- name: Create GitHub Release
223+
continue-on-error: false
224+
env:
225+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
226+
run: |
227+
# Find existing artifact files
228+
hash_files=$(find ~/artifacts -name "*.sha256" -print0 | xargs -0 echo)
229+
exe_files=$(find ~/artifacts -name "*.exe" -print0 | xargs -0 echo)
230+
zip_files=$(find ~/artifacts -name "*.zip" -print0 | xargs -0 echo)
231+
deb_files=$(find ~/artifacts -name "*.deb" -print0 | xargs -0 echo)
232+
rpm_files=$(find ~/artifacts -name "*.rpm" -print0 | xargs -0 echo)
233+
234+
# Check existing release and delete if it's exist
235+
if gh release view ${{ env.TAG_NAME }} --repo $GITHUB_REPOSITORY &> /dev/null; then
236+
gh release delete ${{ env.TAG_NAME }} --repo $GITHUB_REPOSITORY
237+
echo "${{ env.TAG_NAME }} deleted!"
238+
fi
239+
240+
gh release create ${{ env.TAG_NAME }} \
241+
--repo $GITHUB_REPOSITORY \
242+
--draft \
243+
--title "${{ env.RELEASE_NAME }}" \
244+
--notes-file ~/artifacts/notes.txt \
245+
$hash_files \
246+
$exe_files \
247+
$zip_files \
248+
$deb_files \
249+
$rpm_files

0 commit comments

Comments
 (0)