Skip to content

Commit 9abd075

Browse files
Some rewriting...
1 parent 66b9728 commit 9abd075

File tree

4 files changed

+433
-139
lines changed

4 files changed

+433
-139
lines changed
Lines changed: 114 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,128 @@
1-
name: Build Arch Linux ISO
1+
name: Build and Save ISO
22

33
on:
44
schedule:
5-
- cron: '0 0 * * *' # Run the workflow every day at midnight
6-
workflow_dispatch: # Manual trigger option
5+
- cron: '0 0 * * *' # Run daily at midnight UTC
6+
workflow_dispatch:
7+
workflow_run:
8+
workflows: ["Create/Update Release", "Update Packages"]
9+
types:
10+
- completed
11+
12+
env:
13+
ISO_FILENAME: archlinux-custom.iso
14+
MAX_RETRIES: 3
15+
RETRY_DELAY: 30
716

817
jobs:
9-
build:
18+
build-iso:
1019
runs-on: ubuntu-latest
11-
container:
12-
image: archlinux:latest
13-
20+
permissions:
21+
contents: write
22+
1423
steps:
15-
- name: Checkout code
16-
uses: actions/checkout@v3
24+
- name: Checkout Repository
25+
uses: actions/checkout@v4
1726

18-
- name: Install dependencies
27+
- name: Set up environment variables
28+
id: env
1929
run: |
20-
pacman -Syu --noconfirm
21-
pacman -S --noconfirm archiso git
22-
30+
echo "VERSION=$(date +'%Y.%m.%d')" >> $GITHUB_ENV
31+
echo "BUILD_ID=$(date +'%Y%m%d_%H%M%S')" >> $GITHUB_ENV
32+
echo "WORKSPACE=${GITHUB_WORKSPACE}" >> $GITHUB_ENV
33+
34+
- name: Set up Docker
35+
run: |
36+
docker build -t arch-iso-builder .
37+
2338
- name: Build ISO
2439
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/
40+
mkdir -p workdir out
41+
42+
# Build ISO with retry logic
43+
for i in $(seq 1 ${{ env.MAX_RETRIES }}); do
44+
if docker run --rm --privileged \
45+
-v ${{ env.WORKSPACE }}:/workdir \
46+
arch-iso-builder \
47+
bash -c "mkarchiso -v -w /workdir/work/ -o /workdir/out/ /workdir/"; then
48+
echo "ISO build successful"
49+
break
50+
fi
51+
52+
if [ $i -eq ${{ env.MAX_RETRIES }} ]; then
53+
echo "Failed to build ISO after ${{ env.MAX_RETRIES }} attempts"
54+
exit 1
55+
fi
56+
57+
echo "Attempt $i failed. Retrying in ${{ env.RETRY_DELAY }} seconds..."
58+
sleep ${{ env.RETRY_DELAY }}
59+
done
2960
30-
- name: Upload ISO
61+
- name: Generate ISO Checksum
62+
run: |
63+
cd out
64+
sha256sum ${{ env.ISO_FILENAME }} > ${{ env.ISO_FILENAME }}.sha256
65+
cat ${{ env.ISO_FILENAME }}.sha256
66+
67+
- name: Update Release with ISO
68+
env:
69+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70+
run: |
71+
# Check if release exists
72+
if ! gh release view "${{ env.VERSION }}" &>/dev/null; then
73+
# Create release if it doesn't exist
74+
gh release create "${{ env.VERSION }}" \
75+
--title "Release ${{ env.VERSION }}" \
76+
--notes "Arch Linux Custom ISO Build ${{ env.VERSION }}"
77+
fi
78+
79+
# Upload ISO and checksum to the release
80+
gh release upload "${{ env.VERSION }}" \
81+
"out/${{ env.ISO_FILENAME }}" \
82+
"out/${{ env.ISO_FILENAME }}.sha256" \
83+
--clobber
84+
85+
- name: Update Release Notes
86+
env:
87+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
88+
run: |
89+
# Generate ISO information
90+
{
91+
echo "## 💿 ISO Information"
92+
echo "- Filename: \`${{ env.ISO_FILENAME }}\`"
93+
echo "- Size: \`$(ls -lh out/${{ env.ISO_FILENAME }} | awk '{print $5}')\`"
94+
echo "- SHA256: \`$(cat out/${{ env.ISO_FILENAME }}.sha256 | awk '{print $1}')\`"
95+
echo "- Build ID: \`${{ env.BUILD_ID }}\`"
96+
echo "- Build Date: \`$(date -u '+%Y-%m-%d %H:%M:%S UTC')\`"
97+
} > iso_info.md
98+
99+
# Append ISO information to existing release notes
100+
gh release edit "${{ env.VERSION }}" \
101+
--notes-file <(cat <(gh release view "${{ env.VERSION }}" --json body --jq .body) iso_info.md)
102+
103+
- name: Upload Build Artifacts
104+
if: always()
31105
uses: actions/upload-artifact@v3
32106
with:
33-
name: arch-linux-iso
34-
path: out/*.iso
35-
retention-days: 5
107+
name: iso-build-${{ env.BUILD_ID }}
108+
path: |
109+
out/${{ env.ISO_FILENAME }}
110+
out/${{ env.ISO_FILENAME }}.sha256
111+
retention-days: 7
112+
113+
- name: Clean Up
114+
if: always()
115+
run: |
116+
rm -rf workdir out
117+
118+
- name: Notify on Failure
119+
if: failure()
120+
uses: actions/github-script@v6
121+
with:
122+
script: |
123+
const issue = await github.rest.issues.create({
124+
owner: context.repo.owner,
125+
repo: context.repo.repo,
126+
title: '❌ ISO Build Failed',
127+
body: `The ISO build workflow failed on ${new Date().toISOString()}\n\nBuild ID: ${process.env.BUILD_ID}\n\nPlease check the workflow logs for details.`
128+
});
Lines changed: 88 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,104 @@
1-
name: Create Release
1+
name: Create/Update Release
22

33
on:
4+
push:
5+
branches:
6+
- main
7+
- dev
48
workflow_dispatch:
59

10+
env:
11+
MAX_RETRIES: 3
12+
RETRY_DELAY: 30
13+
614
jobs:
7-
release:
15+
update-release:
816
runs-on: ubuntu-latest
9-
17+
permissions:
18+
contents: write
19+
1020
steps:
11-
- name: Checkout code
12-
uses: actions/checkout@v3
21+
- name: Checkout Repository
22+
uses: actions/checkout@v4
1323
with:
1424
fetch-depth: 0
1525

16-
- name: Download ISO
17-
uses: actions/download-artifact@v3
18-
with:
19-
name: arch-linux-iso
20-
path: dist
26+
- name: Set up environment variables
27+
id: env
28+
run: |
29+
echo "VERSION=$(date +'%Y.%m.%d')" >> $GITHUB_ENV
30+
echo "BUILD_ID=$(date +'%Y%m%d_%H%M%S')" >> $GITHUB_ENV
2131
22-
- name: Generate release notes
23-
id: changelog
32+
- name: Generate Release Notes
2433
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
34+
# Create release notes header
35+
echo "# 🚀 Release ${{ env.VERSION }}" > release_notes.md
36+
echo "" >> release_notes.md
37+
38+
# Add recent changes
39+
echo "## 📝 Recent Changes" >> release_notes.md
40+
echo "" >> release_notes.md
41+
git log --pretty=format:"- %s" -n 10 >> release_notes.md
42+
echo "" >> release_notes.md
43+
echo "" >> release_notes.md
44+
45+
# Add package information if available
46+
if [ -f "updates.txt" ]; then
47+
echo "## 📦 Updated Packages" >> release_notes.md
48+
echo "\`\`\`" >> release_notes.md
49+
cat updates.txt >> release_notes.md
50+
echo "\`\`\`" >> release_notes.md
51+
echo "" >> release_notes.md
52+
fi
53+
54+
# Add changelog if available
55+
if [ -f "changelog.txt" ]; then
56+
echo "## 📋 Package Changelog" >> release_notes.md
57+
cat changelog.txt >> release_notes.md
58+
fi
59+
60+
# Add build information
61+
echo "" >> release_notes.md
62+
echo "## 🔧 Build Information" >> release_notes.md
63+
echo "- Build ID: \`${{ env.BUILD_ID }}\`" >> release_notes.md
64+
echo "- Commit: \`$(git rev-parse HEAD)\`" >> release_notes.md
65+
echo "- Branch: \`${GITHUB_REF#refs/heads/}\`" >> release_notes.md
66+
echo "- Build Date: \`$(date -u '+%Y-%m-%d %H:%M:%S UTC')\`" >> release_notes.md
2867
29-
- name: Create Release
30-
uses: softprops/action-gh-release@v1
68+
- name: Update Release
3169
env:
3270
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
run: |
72+
# Check if release exists
73+
if gh release view "${{ env.VERSION }}" &>/dev/null; then
74+
# Update existing release
75+
gh release edit "${{ env.VERSION }}" \
76+
--title "Release ${{ env.VERSION }}" \
77+
--notes-file release_notes.md
78+
else
79+
# Create new release
80+
gh release create "${{ env.VERSION }}" \
81+
--title "Release ${{ env.VERSION }}" \
82+
--notes-file release_notes.md \
83+
--target ${GITHUB_REF#refs/heads/}
84+
fi
85+
86+
- name: Upload Build Logs
87+
if: always()
88+
uses: actions/upload-artifact@v3
89+
with:
90+
name: release-logs-${{ env.BUILD_ID }}
91+
path: release_notes.md
92+
retention-days: 7
93+
94+
- name: Notify on Failure
95+
if: failure()
96+
uses: actions/github-script@v6
3397
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
98+
script: |
99+
const issue = await github.rest.issues.create({
100+
owner: context.repo.owner,
101+
repo: context.repo.repo,
102+
title: '❌ Release Update Failed',
103+
body: `The release update workflow failed on ${new Date().toISOString()}\n\nBuild ID: ${process.env.BUILD_ID}\n\nPlease check the workflow logs for details.`
104+
});

0 commit comments

Comments
 (0)