feat: new workflow to build the iso image of the distro #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build remastered ISO | |
on: | |
pull_request: | |
types: | |
- opened | |
- synchronize | |
workflow_dispatch: | |
inputs: | |
iso_image_url: | |
description: 'URL of the Debian ISO' | |
type: string | |
required: false | |
arch: | |
description: 'Architecture of the ISO image to generate' | |
type: choice | |
options: [amd64] | |
required: true | |
default: amd64 | |
type: | |
description: 'Type of the installation image' | |
type: choice | |
options: [netinst, dvd] | |
required: true | |
default: dvd | |
branch: | |
description: 'The branch of debian to use' | |
type: choice | |
options: [stable, testing, sid] | |
required: true | |
default: stable | |
jobs: | |
debian-desktop: | |
runs-on: ubuntu-latest | |
environment: build-iso-image | |
env: | |
ISO_IMAGE_URL: ${{ github.event.inputs.iso_image_url || vars.ISO_IMAGE_URL }} | |
REMASTERED_ISO_IMAGE: preseed-debian-${{ github.event.inputs.branch }}-${{ github.event.inputs.type }}-${{ github.event.inputs.arch }}.iso | |
ORIGINAL_ISO_IMAGE: debian.iso | |
PRESEED_FILE_TEMPLATE: preseed.cfg.template | |
PRESEED_FILE: preseed.cfg | |
ISO_FILES_DIR: isofiles | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
sparse-checkout: | | |
${{ env.PRESEED_FILE_TEMPLATE }} | |
${{ env.ORIGINAL_ISO_IMAGE }} | |
sparse-checkout-cone-mode: false | |
- name: Install dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y gettext cpio isolinux xorriso | |
- name: Download Debian ISO | |
run: | | |
if [ ! -f '${{ env.ORIGINAL_ISO_IMAGE }}' ]; then | |
curl -L ${{ env.ISO_IMAGE_URL }} -o ${{ env.ORIGINAL_ISO_IMAGE }} | |
fi | |
- name: Extract ISO files | |
run: | | |
mkdir ${{ env.ISO_FILES_DIR }} | |
sudo xorriso -osirrox on -indev ${{ env.ORIGINAL_ISO_IMAGE }} -extract / /media/debian | |
cp -rT /media/debian ${{ env.ISO_FILES_DIR }} | |
- name: Generate preseed file | |
env: | |
ROOT_PASSWORD_HASH: ${{ secrets.ROOT_PASSWORD_HASH }} | |
USER_FULLNAME: ${{ vars.USER_FULLNAME }} | |
USERNAME: ${{ vars.USERNAME }} | |
USER_PASSWORD_HASH: ${{ secrets.USER_PASSWORD_HASH }} | |
run: | | |
envsubst < ${{ env.PRESEED_FILE_TEMPLATE }} > ${{ env.PRESEED_FILE }} | |
- name: Modify initrd and add preseed file | |
env: | |
INSTALL_DIR: ${{ env.ISO_FILES_DIR }}/install.amd | |
run: | | |
chmod +w -R ${{ env.INSTALL_DIR }} | |
gunzip ${{ env.INSTALL_DIR }}/initrd.gz | |
echo ${{ env.PRESEED_FILE }} | cpio -H newc -o -A -F ${{ env.INSTALL_DIR }}/initrd | |
gzip ${{ env.INSTALL_DIR }}/initrd | |
chmod -w -R ${{ env.INSTALL_DIR }} | |
- name: Regenerate md5sum.txt | |
working-directory: ${{ env.ISO_FILES_DIR }} | |
run: | | |
chmod +w md5sum.txt | |
find -follow -type f ! -name md5sum.txt -print0 | xargs -0 md5sum > md5sum.txt | |
chmod -w md5sum.txt | |
- name: Create new bootable ISO | |
env: | |
ORIGINAL_ISO: ${{ env.ORIGINAL_ISO_IMAGE }} | |
NEW_FILES: ${{ env.ISO_FILES_DIR }} | |
NEW_ISO: ${{ env.REMASTERED_ISO_IMAGE }} | |
MBR_TEMPLATE: /usr/lib/ISOLINUX/isohdpfx.bin | |
# Note: FS_NAME must be at most 32 characters long | |
FS_NAME: 'Debian ${{ github.event.inputs.branch }} preseed ${{ github.event.inputs.arch }}' | |
run: | | |
# Extract MBR template file to disk | |
sudo dd if=${{ env.ORIGINAL_ISO }} bs=1 count=432 of=${{ env.MBR_TEMPLATE }} | |
# Create the new ISO image | |
xorriso \ | |
-as mkisofs \ | |
-r -V '${{ env.FS_NAME }}' \ | |
-o ${{ env.NEW_ISO }} \ | |
-J -joliet-long -cache-inodes \ | |
-isohybrid-mbr ${{ env.MBR_TEMPLATE }} \ | |
-b isolinux/isolinux.bin \ | |
-c isolinux/boot.cat \ | |
-boot-load-size 4 -boot-info-table -no-emul-boot \ | |
-eltorito-alt-boot \ | |
-e boot/grub/efi.img \ | |
-no-emul-boot -isohybrid-gpt-basdat -isohybrid-apm-hfsplus \ | |
${{ env.NEW_FILES }} | |
- name: Upload ISO artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: remastered-iso | |
path: ${{ env.REMASTERED_ISO_IMAGE }} | |
if-no-files-found: warn | |
retention-days: 7 |