Build and Release Multiple ISOs with Different Desktop Environments #9
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 and Release Multiple ISOs with Different Desktop Environments | |
on: | |
workflow_dispatch: | |
inputs: | |
release_title: | |
description: 'Title for the release' | |
required: true | |
release_description: | |
description: 'Description for the release' | |
required: true | |
release_version: | |
description: 'Version for the release' | |
required: true | |
permissions: | |
contents: write # Grant write access to create releases | |
jobs: | |
build_and_release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Docker container | |
env: | |
IMAGE_NAME: archlinux:latest | |
run: | | |
# Pull the Arch Linux image if not already available | |
docker pull $IMAGE_NAME | |
# Start the Docker container in the background | |
docker run --rm --privileged -d \ | |
-v "$GITHUB_WORKSPACE:/work" \ | |
-v "/mnt/temp:/tmp" \ | |
--name build-container \ | |
$IMAGE_NAME | |
- name: Build ISOs inside Docker | |
run: | | |
# Define the branches and corresponding desktop environments | |
branches=("sunnyos_gnome" "sunnyos_budgie" "lite_gnome") | |
# Run commands inside the container | |
docker exec build-container bash -c " | |
set -e | |
pacman -Sy --noconfirm archiso | |
cd /work | |
git fetch --all | |
for branch in \"\${branches[@]}\"; do | |
echo 'Checking out branch: $branch' | |
git checkout $branch | |
echo 'Building ISO for branch $branch' | |
mkarchiso -v -w /tmp/work -o /tmp/out /work | |
mv /tmp/out/*.iso /tmp/$branch-sunnyos.iso | |
done | |
" | |
- name: Stop Docker container | |
run: | | |
docker stop build-container | |
- name: Create GitHub Release | |
id: create_release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
release_response=$(curl -XPOST -H "Authorization: token $GITHUB_TOKEN" \ | |
-d '{ | |
"tag_name": "${{ github.event.inputs.release_version }}", | |
"name": "${{ github.event.inputs.release_title }}", | |
"body": "${{ github.event.inputs.release_description }}", | |
"draft": false, | |
"prerelease": false | |
}' \ | |
https://api.github.com/repos/${{ github.repository }}/releases) | |
release_id=$(echo $release_response | jq -r '.id') | |
if [[ "$release_id" == "null" || -z "$release_id" ]]; then | |
echo "Failed to create release. Response: $release_response" | |
exit 1 | |
fi | |
echo "Created release with ID: $release_id" | |
echo "release_id=$release_id" >> $GITHUB_ENV | |
- name: Upload ISOs to Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
release_id: ${{ env.release_id }} | |
run: | | |
for iso in /mnt/temp/*-sunnyos.iso; do | |
echo "Uploading $iso to release" | |
curl -XPOST -H "Authorization: token $GITHUB_TOKEN" \ | |
-H "Content-Type: application/octet-stream" \ | |
--data-binary @$iso \ | |
"https://uploads.github.com/repos/${{ github.repository }}/releases/$release_id/assets?name=$(basename $iso)" | |
done |