Skip to content

Commit 5b8bc69

Browse files
Voeg workflows toe voor het bouwen, opslaan en creëren van releases van Arch Linux ISO's
1 parent 974e17f commit 5b8bc69

File tree

3 files changed

+291
-0
lines changed

3 files changed

+291
-0
lines changed
Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
name: Build ISO
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '0 0 * * *' # Run the workflow every day at midnight
7+
push:
8+
branches:
9+
- main
10+
paths-ignore:
11+
- '**.md'
12+
- '.gitignore'
13+
14+
env:
15+
DOCKER_BUILDKIT: 1
16+
ISO_FILENAME: Arch.iso
17+
18+
jobs:
19+
build:
20+
runs-on: ubuntu-latest
21+
timeout-minutes: 120 # Set a timeout to prevent hung builds
22+
23+
steps:
24+
- name: Checkout Repository
25+
uses: actions/checkout@v4
26+
27+
- name: Set up environment variables
28+
id: env
29+
run: |
30+
echo "DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
31+
echo "VERSION=$(date +'%Y.%m.%d')" >> $GITHUB_ENV
32+
echo "CACHE_KEY=$(date +'%Y-%m')" >> $GITHUB_ENV
33+
echo "WORKSPACE=${GITHUB_WORKSPACE}" >> $GITHUB_ENV
34+
35+
- name: Create Cache Directories
36+
run: |
37+
sudo mkdir -p /tmp/pacman-cache
38+
sudo chmod 777 /tmp/pacman-cache
39+
# Ensure the directory is empty to prevent tar errors
40+
sudo rm -rf /tmp/pacman-cache/*
41+
42+
- name: Cache Pacman packages
43+
uses: actions/cache@v3
44+
with:
45+
path: /tmp/pacman-cache
46+
key: pacman-${{ runner.os }}-${{ env.CACHE_KEY }}
47+
restore-keys: |
48+
pacman-${{ runner.os }}-
49+
50+
- name: Set up Arch Linux Container
51+
run: |
52+
docker run --privileged --name arch-container -d \
53+
-v ${{ env.WORKSPACE }}:/workdir \
54+
-v /tmp/pacman-cache:/var/cache/pacman/pkg \
55+
archlinux:latest sleep infinity
56+
57+
- name: Initialize Container
58+
run: |
59+
docker exec arch-container bash -c "
60+
set -euo pipefail
61+
62+
# Update package database and system
63+
pacman -Syu --noconfirm
64+
65+
# Install required packages
66+
pacman -S --noconfirm --needed \
67+
git \
68+
archiso \
69+
grub \
70+
curl \
71+
jq \
72+
gnupg \
73+
make \
74+
sudo
75+
76+
# Verify installation
77+
command -v mkarchiso >/dev/null 2>&1 || {
78+
echo '::error::mkarchiso not found'
79+
exit 1
80+
}
81+
"
82+
83+
- name: Build ISO
84+
id: build
85+
run: |
86+
docker exec arch-container bash -c "
87+
set -euo pipefail
88+
cd /workdir
89+
90+
# Cleanup any previous builds
91+
rm -rf workdir/ out/
92+
mkdir -p out/
93+
94+
# Build the ISO with verbose output
95+
mkarchiso -v -w workdir/ -o out/ . 2>&1 | tee build.log || {
96+
echo '::error::ISO build failed!'
97+
tail -n 50 build.log
98+
exit 1
99+
}
100+
101+
# Verify ISO was created
102+
[ -f out/*.iso ] || {
103+
echo '::error::ISO file not found after build'
104+
exit 1
105+
}
106+
"
107+
108+
- name: Generate Checksums
109+
run: |
110+
docker exec arch-container bash -c "
111+
set -euo pipefail
112+
cd /workdir/out
113+
114+
# Generate checksums
115+
for iso in *.iso; do
116+
sha256sum \"\$iso\" > \"\${iso}.sha256sum\"
117+
sha512sum \"\$iso\" > \"\${iso}.sha512sum\"
118+
done
119+
"
120+
121+
- name: Rename and Move ISO
122+
run: |
123+
docker exec arch-container bash -c "
124+
set -euo pipefail
125+
cd /workdir/out
126+
127+
for f in *.iso; do
128+
newname=\"arch-linux-no-beeps-${{ env.VERSION }}.iso\"
129+
mv \"\$f\" \"\$newname\"
130+
mv \"\$f.sha256sum\" \"\$newname.sha256sum\"
131+
mv \"\$f.sha512sum\" \"\$newname.sha512sum\"
132+
done
133+
"
134+
135+
- name: Generate Release Notes
136+
id: release_notes
137+
run: |
138+
# Create a temporary file for release notes
139+
TEMP_RELEASE_NOTES=$(mktemp)
140+
141+
docker exec arch-container bash -c "
142+
set -euo pipefail
143+
cd /workdir
144+
145+
# Initialize release notes
146+
{
147+
echo '🚀 Arch Linux ISO without system beeps (build ${{ env.DATE }})'
148+
echo ''
149+
echo '### Changes'
150+
151+
# Get changes since last release
152+
if git tag | grep -q .; then
153+
LAST_TAG=\$(git describe --tags --abbrev=0 2>/dev/null || echo '')
154+
if [ ! -z \"\$LAST_TAG\" ]; then
155+
echo '#### Commits since last release:'
156+
git log \"\$LAST_TAG\"..HEAD --pretty=format:'- %s' | grep -v 'Merge'
157+
echo ''
158+
fi
159+
fi
160+
161+
# Add standard information
162+
echo '### Features'
163+
echo '- Automatic daily build'
164+
echo '- System beeps disabled'
165+
echo '- ISO SHA256 and SHA512 checksums included'
166+
echo ''
167+
echo '### Download'
168+
echo '- Download the ISO and verify checksums before use'
169+
echo ''
170+
echo '### Checksums'
171+
echo 'SHA256 and SHA512 checksums are available in the uploaded files.'
172+
} > /tmp/release_notes
173+
"
174+
175+
# Copy release notes from container to host
176+
docker cp arch-container:/tmp/release_notes $TEMP_RELEASE_NOTES
177+
178+
# Set the release notes in GITHUB_ENV
179+
echo 'RELEASE_NOTES<<EOF' >> $GITHUB_ENV
180+
cat $TEMP_RELEASE_NOTES >> $GITHUB_ENV
181+
echo 'EOF' >> $GITHUB_ENV
182+
183+
# Cleanup
184+
rm -f $TEMP_RELEASE_NOTES
185+
186+
- name: Create Release
187+
id: create_release
188+
uses: softprops/action-gh-release@v1
189+
if: github.ref == 'refs/heads/main'
190+
with:
191+
tag_name: v${{ env.VERSION }}
192+
name: "Arch Linux No Beeps v${{ env.VERSION }}"
193+
body: ${{ env.RELEASE_NOTES }}
194+
draft: false
195+
prerelease: false
196+
files: |
197+
${{ env.WORKSPACE }}/out/*.iso
198+
${{ env.WORKSPACE }}/out/*.sha*sum
199+
200+
- name: Clean Up
201+
if: always()
202+
run: |
203+
if docker ps -a | grep -q arch-container; then
204+
docker stop arch-container || true
205+
docker rm -f arch-container || true
206+
fi
207+
sudo rm -rf workdir/ out/ /tmp/pacman-cache/*
208+
209+
- name: Upload Build Logs on Failure
210+
if: failure()
211+
uses: actions/upload-artifact@v4 # Upgrade to v4
212+
with:
213+
name: build-logs
214+
path: |
215+
${{ env.WORKSPACE }}/build.log
216+
retention-days: 5
217+
compression-level: 9 # Maximum compression for logs
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Build Arch Linux ISO
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * *' # Run the workflow every day at midnight
6+
workflow_dispatch: # Manual trigger option
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
container:
12+
image: archlinux:latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v3
17+
18+
- name: Install dependencies
19+
run: |
20+
pacman -Syu --noconfirm
21+
pacman -S --noconfirm archiso git
22+
23+
- name: Build ISO
24+
run: |
25+
mkdir -p work out
26+
cp -r /usr/share/archiso/configs/releng/* work/
27+
cp -r * work/airootfs/ || true
28+
mkarchiso -v -w work/ -o out/ work/
29+
30+
- name: Upload ISO
31+
uses: actions/upload-artifact@v3
32+
with:
33+
name: arch-linux-iso
34+
path: out/*.iso
35+
retention-days: 5
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Create Release
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
release:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v3
13+
with:
14+
fetch-depth: 0
15+
16+
- name: Download ISO
17+
uses: actions/download-artifact@v3
18+
with:
19+
name: arch-linux-iso
20+
path: dist
21+
22+
- name: Generate release notes
23+
id: changelog
24+
run: |
25+
echo "## " > CHANGELOG.md
26+
echo "" >> CHANGELOG.md
27+
git log --pretty=format:"* %s (%h) - %ad" --date=short --since="5 days ago" >> CHANGELOG.md
28+
29+
- name: Create Release
30+
uses: softprops/action-gh-release@v1
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
with:
34+
files: dist/*.iso
35+
body_path: CHANGELOG.md
36+
tag_name: Pre-release ${{ github.run_number }}
37+
name: Pre-release ${{ github.run_number }}
38+
draft: false
39+
prerelease: true

0 commit comments

Comments
 (0)