Skip to content

Commit c71a712

Browse files
Enhance GitHub Actions workflows for Arch Linux builds:
- Remove unnecessary Docker Buildx setup and caching steps. - Add environment variable for workspace and create cache directories. - Improve container initialization and package installation with error handling. - Update ISO build process to include detailed logging and verification. - Refactor checksum generation and artifact naming for clarity. - Streamline cleanup process and ensure build logs are uploaded on failure.
1 parent e119c99 commit c71a712

File tree

2 files changed

+97
-50
lines changed

2 files changed

+97
-50
lines changed

.github/workflows/build.yaml

Lines changed: 67 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,20 @@ jobs:
2525
- name: Checkout Repository
2626
uses: actions/checkout@v4
2727

28-
- name: Set up Docker Buildx
29-
uses: docker/setup-buildx-action@v3
30-
with:
31-
buildkitd-flags: --debug
32-
33-
- name: Cache Docker layers
34-
uses: actions/cache@v3
35-
with:
36-
path: /tmp/.buildx-cache
37-
key: ${{ runner.os }}-buildx-${{ github.sha }}
38-
restore-keys: |
39-
${{ runner.os }}-buildx-
40-
4128
- name: Set up environment variables
4229
id: env
4330
run: |
4431
echo "DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
4532
echo "VERSION=$(date +'%Y.%m.%d')" >> $GITHUB_ENV
4633
echo "CACHE_KEY=$(date +'%Y-%m')" >> $GITHUB_ENV
34+
echo "WORKSPACE=${GITHUB_WORKSPACE}" >> $GITHUB_ENV
35+
36+
- name: Create Cache Directories
37+
run: |
38+
sudo mkdir -p /tmp/pacman-cache
39+
sudo chmod 777 /tmp/pacman-cache
40+
sudo mkdir -p /tmp/build-cache
41+
sudo chmod 777 /tmp/build-cache
4742
4843
- name: Cache Pacman packages
4944
uses: actions/cache@v3
@@ -55,18 +50,36 @@ jobs:
5550
5651
- name: Set up Arch Linux Container
5752
run: |
58-
mkdir -p /tmp/pacman-cache
5953
docker run --privileged --name arch-container -d \
60-
-v ${{ github.workspace }}:/workdir \
54+
-v ${{ env.WORKSPACE }}:/workdir \
6155
-v /tmp/pacman-cache:/var/cache/pacman/pkg \
56+
-v /tmp/build-cache:/var/cache/pacman/pkg \
6257
archlinux:latest sleep infinity
6358
64-
- name: Update and Install Dependencies
59+
- name: Initialize Container
6560
run: |
6661
docker exec arch-container bash -c "
6762
set -euo pipefail
63+
64+
# Update package database
6865
pacman -Sy --noconfirm
69-
pacman -S --noconfirm --needed git archiso grub curl jq gnupg
66+
67+
# Install required packages
68+
pacman -S --noconfirm --needed \
69+
git \
70+
archiso \
71+
grub \
72+
curl \
73+
jq \
74+
gnupg \
75+
make \
76+
sudo
77+
78+
# Verify installation
79+
command -v mkarchiso >/dev/null 2>&1 || {
80+
echo 'Error: mkarchiso not found'
81+
exit 1
82+
}
7083
"
7184
7285
- name: Build ISO
@@ -75,29 +88,49 @@ jobs:
7588
docker exec arch-container bash -c "
7689
set -euo pipefail
7790
cd /workdir
91+
7892
# Cleanup any previous builds
7993
rm -rf workdir/ out/
94+
mkdir -p out/
95+
8096
# Build the ISO with verbose output
81-
mkarchiso -v -w workdir/ -o out/ . || {
82-
echo 'ISO build failed!'
97+
mkarchiso -v -w workdir/ -o out/ . 2>&1 | tee build.log || {
98+
echo 'Error: ISO build failed!'
99+
tail -n 50 build.log
100+
exit 1
101+
}
102+
103+
# Verify ISO was created
104+
[ -f out/*.iso ] || {
105+
echo 'Error: ISO file not found after build'
83106
exit 1
84107
}
85108
"
86109
87110
- name: Generate Checksums
88111
run: |
89112
docker exec arch-container bash -c "
113+
set -euo pipefail
90114
cd /workdir/out
91-
sha256sum *.iso > sha256sums.txt
92-
sha512sum *.iso > sha512sums.txt
115+
116+
# Generate checksums
117+
for iso in *.iso; do
118+
sha256sum \"\$iso\" > \"\${iso}.sha256sum\"
119+
sha512sum \"\$iso\" > \"\${iso}.sha512sum\"
120+
done
93121
"
94122
95123
- name: Rename and Move ISO
96124
run: |
97125
docker exec arch-container bash -c "
126+
set -euo pipefail
98127
cd /workdir/out
128+
99129
for f in *.iso; do
100-
mv \"\$f\" \"arch-linux-no-beeps-${{ env.VERSION }}.iso\"
130+
newname=\"arch-linux-no-beeps-${{ env.VERSION }}.iso\"
131+
mv \"\$f\" \"\$newname\"
132+
mv \"\$f.sha256sum\" \"\$newname.sha256sum\"
133+
mv \"\$f.sha512sum\" \"\$newname.sha512sum\"
101134
done
102135
"
103136
@@ -106,8 +139,8 @@ jobs:
106139
with:
107140
name: arch-linux-no-beeps-${{ env.VERSION }}
108141
path: |
109-
${{ github.workspace }}/out/*.iso
110-
${{ github.workspace }}/out/sha*sums.txt
142+
${{ env.WORKSPACE }}/out/*.iso
143+
${{ env.WORKSPACE }}/out/*.sha*sum
111144
retention-days: 5
112145

113146
- name: Create Release
@@ -133,17 +166,21 @@ jobs:
133166
draft: false
134167
prerelease: false
135168
files: |
136-
${{ github.workspace }}/out/*.iso
137-
${{ github.workspace }}/out/sha*sums.txt
169+
${{ env.WORKSPACE }}/out/*.iso
170+
${{ env.WORKSPACE }}/out/*.sha*sum
138171
139172
- name: Clean Up
140173
if: always()
141174
run: |
142175
docker stop arch-container || true
143176
docker rm arch-container || true
144-
rm -rf workdir/ out/
177+
sudo rm -rf workdir/ out/ /tmp/build-cache/*
145178
146-
- name: Notify on Failure
179+
- name: Upload Build Logs on Failure
147180
if: failure()
148-
run: |
149-
echo "::error::ISO build failed! Check the logs for more details."
181+
uses: actions/upload-artifact@v3
182+
with:
183+
name: build-logs
184+
path: |
185+
${{ env.WORKSPACE }}/build.log
186+
retention-days: 5

.github/workflows/update-packages.yaml

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,43 +20,53 @@ jobs:
2020

2121
- name: Set up Docker
2222
run: |
23-
docker run --name arch-container -d archlinux:latest sleep infinity
23+
docker run --name arch-container -d \
24+
-v ${{ github.workspace }}:/workdir \
25+
archlinux:latest sleep infinity
26+
27+
- name: Initialize Container
28+
run: |
29+
docker exec arch-container bash -c "
30+
pacman -Sy --noconfirm
31+
pacman -S --noconfirm --needed curl jq
32+
"
2433
2534
- name: Check for Package Updates
2635
id: check-updates
2736
run: |
28-
# Create temporary files
29-
touch new-packages.txt current-packages.txt updates.txt
37+
# Create temporary files in workspace
38+
touch current-packages.txt updates.txt
3039
3140
# Get current packages
32-
cat packages.x86_64 | grep -v '^#' | grep -v '^$' > current-packages.txt
41+
grep -v '^#' packages.x86_64 | grep -v '^$' > current-packages.txt
3342
3443
# Check each package for updates
3544
docker exec arch-container bash -c "
45+
set -euo pipefail
46+
cd /workdir
47+
48+
# Initialize pacman
3649
pacman -Sy
50+
51+
# Process each package
3752
while read -r pkg; do
38-
if pacman -Si \$pkg >/dev/null 2>&1; then
39-
echo \$pkg >> /tmp/new-packages.txt
53+
if pacman -Si \"\$pkg\" >/dev/null 2>&1; then
54+
current_ver=\$(pacman -Si \"\$pkg\" | grep Version | head -n1 | awk '{print \$3}')
55+
echo \"\$pkg \$current_ver\" >> updates.txt
56+
else
57+
echo \"Warning: Package \$pkg not found in repositories\"
4058
fi
41-
done < /workdir/current-packages.txt
59+
done < current-packages.txt
4260
"
4361
44-
# Compare versions and create update list
45-
docker exec arch-container bash -c "
46-
while read -r pkg; do
47-
current_ver=\$(pacman -Si \$pkg | grep Version | head -n1 | awk '{print \$3}')
48-
echo \"\$pkg \$current_ver\" >> /tmp/updates.txt
49-
done < /tmp/new-packages.txt
50-
"
51-
52-
# Copy files back
53-
docker cp arch-container:/tmp/updates.txt .
54-
55-
# Set output
62+
# Check if we have updates
5663
if [ -s updates.txt ]; then
5764
echo "updates_available=true" >> $GITHUB_OUTPUT
65+
echo "Found updates:"
66+
cat updates.txt
5867
else
5968
echo "updates_available=false" >> $GITHUB_OUTPUT
69+
echo "No updates found"
6070
fi
6171
6272
- name: Create Pull Request
@@ -87,4 +97,4 @@ jobs:
8797
run: |
8898
docker stop arch-container || true
8999
docker rm arch-container || true
90-
rm -f updates.txt new-packages.txt current-packages.txt
100+
rm -f current-packages.txt updates.txt

0 commit comments

Comments
 (0)