Skip to content

Commit b806798

Browse files
committed
ci(build): Add retry logic to desktop build workflow
This commit introduces a retry mechanism to the Gradle build commands in the `build-desktop-platforms.yml` GitHub Actions workflow. This is intended to improve the reliability of the build process by automatically retrying failed packaging tasks up to three times with an exponential backoff. Key changes: - A `retry` shell function has been added to the Windows, macOS, and Linux build jobs. - The `packageExe`, `packageMsi`, `packageDmg`, `packagePkg`, `packageDeb`, and `packageRpm` Gradle tasks now use this retry logic. - The `--no-daemon` flag has been added to the Gradle commands to prevent potential build conflicts. - The `AppImage` packaging and upload steps have been removed from the Linux build job.
1 parent 3146bd0 commit b806798

1 file changed

Lines changed: 77 additions & 11 deletions

File tree

.github/workflows/build-desktop-platforms.yml

Lines changed: 77 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,32 @@ jobs:
2424
run: chmod +x gradlew
2525
shell: bash
2626

27-
- name: Build Windows installers (EXE & MSI)
27+
- name: Build Windows installers (EXE & MSI) with retries
2828
run: |
29-
./gradlew :composeApp:packageExe
30-
./gradlew :composeApp:packageMsi
29+
set -euo pipefail
30+
31+
retry() {
32+
local n=1
33+
local max=3
34+
local delay=5
35+
while true; do
36+
echo "Attempt #$n: $*"
37+
if "$@"; then
38+
break
39+
fi
40+
if [ $n -ge $max ]; then
41+
echo "Command failed after $n attempts."
42+
return 1
43+
fi
44+
n=$((n+1))
45+
echo "Command failed — retrying in $delay seconds..."
46+
sleep $delay
47+
delay=$((delay*2))
48+
done
49+
}
50+
51+
retry ./gradlew :composeApp:packageExe --no-daemon
52+
retry ./gradlew :composeApp:packageMsi --no-daemon
3153
shell: bash
3254

3355
- name: Upload Windows installers
@@ -56,10 +78,33 @@ jobs:
5678
- name: Grant execute permission for gradlew
5779
run: chmod +x gradlew
5880

59-
- name: Build macOS installers (DMG & PKG)
81+
- name: Build macOS installers (DMG & PKG) with retries
6082
run: |
61-
./gradlew :composeApp:packageDmg
62-
./gradlew :composeApp:packagePkg
83+
set -euo pipefail
84+
85+
retry() {
86+
local n=1
87+
local max=3
88+
local delay=5
89+
while true; do
90+
echo "Attempt #$n: $*"
91+
if "$@"; then
92+
break
93+
fi
94+
if [ $n -ge $max ]; then
95+
echo "Command failed after $n attempts."
96+
return 1
97+
fi
98+
n=$((n+1))
99+
echo "Command failed — retrying in $delay seconds..."
100+
sleep $delay
101+
delay=$((delay*2))
102+
done
103+
}
104+
105+
retry ./gradlew :composeApp:packageDmg --no-daemon
106+
retry ./gradlew :composeApp:packagePkg --no-daemon
107+
shell: bash
63108

64109
- name: Upload macOS installers
65110
uses: actions/upload-artifact@v4
@@ -87,11 +132,33 @@ jobs:
87132
- name: Grant execute permission for gradlew
88133
run: chmod +x gradlew
89134

90-
- name: Build Linux installers (DEB, RPM & AppImage)
135+
- name: Build Linux installers (DEB & RPM) with retries
91136
run: |
92-
./gradlew :composeApp:packageDeb
93-
./gradlew :composeApp:packageRpm
94-
./gradlew :composeApp:packageAppImage
137+
set -euo pipefail
138+
139+
retry() {
140+
local n=1
141+
local max=3
142+
local delay=5
143+
while true; do
144+
echo "Attempt #$n: $*"
145+
if "$@"; then
146+
break
147+
fi
148+
if [ $n -ge $max ]; then
149+
echo "Command failed after $n attempts."
150+
return 1
151+
fi
152+
n=$((n+1))
153+
echo "Command failed — retrying in $delay seconds..."
154+
sleep $delay
155+
delay=$((delay*2))
156+
done
157+
}
158+
159+
retry ./gradlew :composeApp:packageDeb --no-daemon
160+
retry ./gradlew :composeApp:packageRpm --no-daemon
161+
shell: bash
95162

96163
- name: Upload Linux installers
97164
uses: actions/upload-artifact@v4
@@ -100,5 +167,4 @@ jobs:
100167
path: |
101168
composeApp/build/compose/binaries/main/deb/*.deb
102169
composeApp/build/compose/binaries/main/rpm/*.rpm
103-
composeApp/build/compose/binaries/main/app-image/*.AppImage
104170
retention-days: 30

0 commit comments

Comments
 (0)