Skip to content

Commit 7540124

Browse files
Enhance GitHub Actions workflow for Arch Linux ISO builds:
- Ensure the Pacman cache directory is emptied before use to prevent errors. - Update caching key to include the runner OS for better cache management. - Modify package update command to perform a full system upgrade. - Improve error messages for missing tools and failed builds with standardized output. - Refactor cleanup steps to check for container existence before stopping and removing. - Upgrade artifact upload action to v4 and increase log compression level.
1 parent c2a77c0 commit 7540124

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

.github/workflows/build.yaml

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,16 @@ jobs:
3737
run: |
3838
sudo mkdir -p /tmp/pacman-cache
3939
sudo chmod 777 /tmp/pacman-cache
40+
# Ensure the directory is empty to prevent tar errors
41+
sudo rm -rf /tmp/pacman-cache/*
4042
4143
- name: Cache Pacman packages
4244
uses: actions/cache@v3
4345
with:
4446
path: /tmp/pacman-cache
45-
key: pacman-${{ env.CACHE_KEY }}
47+
key: pacman-${{ runner.os }}-${{ env.CACHE_KEY }}
4648
restore-keys: |
47-
pacman-
49+
pacman-${{ runner.os }}-
4850
4951
- name: Set up Arch Linux Container
5052
run: |
@@ -58,8 +60,8 @@ jobs:
5860
docker exec arch-container bash -c "
5961
set -euo pipefail
6062
61-
# Update package database
62-
pacman -Sy --noconfirm
63+
# Update package database and system
64+
pacman -Syu --noconfirm
6365
6466
# Install required packages
6567
pacman -S --noconfirm --needed \
@@ -74,7 +76,7 @@ jobs:
7476
7577
# Verify installation
7678
command -v mkarchiso >/dev/null 2>&1 || {
77-
echo 'Error: mkarchiso not found'
79+
echo '::error::mkarchiso not found'
7880
exit 1
7981
}
8082
"
@@ -92,14 +94,14 @@ jobs:
9294
9395
# Build the ISO with verbose output
9496
mkarchiso -v -w workdir/ -o out/ . 2>&1 | tee build.log || {
95-
echo 'Error: ISO build failed!'
97+
echo '::error::ISO build failed!'
9698
tail -n 50 build.log
9799
exit 1
98100
}
99101
100102
# Verify ISO was created
101103
[ -f out/*.iso ] || {
102-
echo 'Error: ISO file not found after build'
104+
echo '::error::ISO file not found after build'
103105
exit 1
104106
}
105107
"
@@ -131,14 +133,6 @@ jobs:
131133
done
132134
"
133135
134-
- name: Upload ISO Artifact
135-
uses: actions/upload-artifact@v3
136-
with:
137-
name: arch-linux-no-beeps-${{ env.VERSION }}
138-
path: |
139-
${{ env.WORKSPACE }}/out/*.iso
140-
${{ env.WORKSPACE }}/out/*.sha*sum
141-
retention-days: 5
142136
143137
- name: Create Release
144138
id: create_release
@@ -169,15 +163,18 @@ jobs:
169163
- name: Clean Up
170164
if: always()
171165
run: |
172-
docker stop arch-container || true
173-
docker rm arch-container || true
166+
if docker ps -a | grep -q arch-container; then
167+
docker stop arch-container || true
168+
docker rm -f arch-container || true
169+
fi
174170
sudo rm -rf workdir/ out/ /tmp/pacman-cache/*
175171
176172
- name: Upload Build Logs on Failure
177173
if: failure()
178-
uses: actions/upload-artifact@v3
174+
uses: actions/upload-artifact@v4 # Upgrade to v4
179175
with:
180176
name: build-logs
181177
path: |
182178
${{ env.WORKSPACE }}/build.log
183-
retention-days: 5
179+
retention-days: 5
180+
compression-level: 9 # Maximum compression for logs

0 commit comments

Comments
 (0)