Skip to content

Commit 6285e5f

Browse files
committed
ci: build and release iso
1 parent de87a03 commit 6285e5f

File tree

1 file changed

+157
-0
lines changed

1 file changed

+157
-0
lines changed
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
name: Build and Release Preview
2+
3+
on:
4+
push:
5+
# branches:
6+
# - main
7+
# pull_request:
8+
# branches:
9+
# - main
10+
workflow_dispatch:
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
container:
16+
image: archlinux:latest
17+
options: --privileged
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
23+
- name: Update system and install dependencies
24+
run: |
25+
pacman -Syu --noconfirm
26+
pacman -S --noconfirm archiso git base-devel
27+
28+
- name: Configure pacman for parallel downloads
29+
run: |
30+
sed -i 's/^#ParallelDownloads/ParallelDownloads/' /etc/pacman.conf
31+
32+
- name: Validate profile
33+
run: |
34+
if [ ! -f profiledef.sh ]; then
35+
echo "Error: profiledef.sh not found"
36+
exit 1
37+
fi
38+
source profiledef.sh
39+
echo "Building ISO: ${iso_name} version ${iso_version}"
40+
41+
- name: Build ISO
42+
run: |
43+
mkdir -p /tmp/archiso-work
44+
mkdir -p /tmp/archiso-out
45+
mkarchiso -v -w /tmp/archiso-work -o /tmp/archiso-out .
46+
47+
- name: Get ISO information
48+
id: iso_info
49+
run: |
50+
ISO_PATH=$(find /tmp/archiso-out -name "*.iso" -type f | head -n 1)
51+
ISO_NAME=$(basename "$ISO_PATH")
52+
ISO_SIZE=$(du -h "$ISO_PATH" | cut -f1)
53+
ISO_SHA256=$(sha256sum "$ISO_PATH" | cut -d' ' -f1)
54+
55+
# Get version from profiledef.sh (format: yyyy.mm)
56+
source profiledef.sh
57+
RELEASE_VERSION="${iso_version}"
58+
RELEASE_TAG="alg-xfce-${RELEASE_VERSION}"
59+
60+
# Sanitize artifact name (replace / with -)
61+
ARTIFACT_NAME="${RELEASE_TAG//\//-}"
62+
63+
echo "iso_path=$ISO_PATH" >> $GITHUB_OUTPUT
64+
echo "iso_name=$ISO_NAME" >> $GITHUB_OUTPUT
65+
echo "iso_size=$ISO_SIZE" >> $GITHUB_OUTPUT
66+
echo "iso_sha256=$ISO_SHA256" >> $GITHUB_OUTPUT
67+
echo "release_tag=$RELEASE_TAG" >> $GITHUB_OUTPUT
68+
echo "artifact_name=$ARTIFACT_NAME" >> $GITHUB_OUTPUT
69+
70+
# Create checksums file
71+
cd /tmp/archiso-out
72+
sha256sum *.iso > SHA256SUMS
73+
74+
- name: Upload ISO artifact
75+
uses: actions/upload-artifact@v4
76+
with:
77+
name: ${{ steps.iso_info.outputs.artifact_name }}
78+
path: |
79+
/tmp/archiso-out/*.iso
80+
/tmp/archiso-out/SHA256SUMS
81+
retention-days: 30
82+
83+
- name: Create release notes
84+
id: release_notes
85+
run: |
86+
BUILD_DATE=$(date -u +"%Y-%m-%d %H:%M:%S UTC")
87+
cat > /tmp/release-notes.md << EOF
88+
## ALG XFCE Release
89+
90+
**Build Date:** ${BUILD_DATE}
91+
**Commit:** ${{ github.sha }}
92+
**Branch:** ${{ github.ref_name }}
93+
94+
### ISO Information
95+
- **Filename:** ${{ steps.iso_info.outputs.iso_name }}
96+
- **Size:** ${{ steps.iso_info.outputs.iso_size }}
97+
- **SHA256:** \`${{ steps.iso_info.outputs.iso_sha256 }}\`
98+
99+
### Installation
100+
1. Download the ISO file
101+
2. Verify the checksum using SHA256SUMS
102+
3. Write to USB using dd, Ventoy, or similar tools:
103+
\`\`\`bash
104+
dd if=${{ steps.iso_info.outputs.iso_name }} of=/dev/sdX bs=4M status=progress
105+
\`\`\`
106+
4. Boot from the USB drive
107+
108+
### Verification
109+
\`\`\`bash
110+
sha256sum -c SHA256SUMS
111+
\`\`\`
112+
113+
EOF
114+
cat /tmp/release-notes.md
115+
116+
- name: Create release
117+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
118+
uses: softprops/action-gh-release@v1
119+
with:
120+
tag_name: ${{ steps.iso_info.outputs.release_tag }}
121+
name: ${{ steps.iso_info.outputs.release_tag }}
122+
body_path: /tmp/release-notes.md
123+
draft: false
124+
prerelease: true
125+
files: |
126+
/tmp/archiso-out/*.iso
127+
/tmp/archiso-out/SHA256SUMS
128+
env:
129+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
130+
131+
- name: Comment on PR with build info
132+
if: github.event_name == 'pull_request'
133+
uses: actions/github-script@v7
134+
with:
135+
script: |
136+
const iso_name = '${{ steps.iso_info.outputs.iso_name }}';
137+
const iso_size = '${{ steps.iso_info.outputs.iso_size }}';
138+
const iso_sha256 = '${{ steps.iso_info.outputs.iso_sha256 }}';
139+
140+
const comment = `## Build Preview Ready
141+
142+
The ISO has been built successfully!
143+
144+
**ISO Details:**
145+
- Filename: \`${iso_name}\`
146+
- Size: ${iso_size}
147+
- SHA256: \`${iso_sha256}\`
148+
149+
You can download the artifact from the [Actions tab](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}).
150+
`;
151+
152+
github.rest.issues.createComment({
153+
issue_number: context.issue.number,
154+
owner: context.repo.owner,
155+
repo: context.repo.repo,
156+
body: comment
157+
});

0 commit comments

Comments
 (0)