Build and Release Multiple ISOs with Different Desktop Environments #18
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 | |
jobs: | |
build_and_release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Build ISOs for all branches | |
env: | |
IMAGE_NAME: archlinux:latest | |
run: | | |
# Define the branches and corresponding desktop environments | |
branches=("sunnyos_gnome" "sunnyos_budgie" "lite_gnome") | |
# Start the Docker container for building | |
docker run --rm --privileged \ | |
-v "$GITHUB_WORKSPACE:/work" \ | |
-v "/mnt/temp:/tmp" \ | |
$IMAGE_NAME /bin/bash -c " | |
pacman -Sy --noconfirm archiso | |
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 | |
# Move the generated ISO to a central location | |
mv /tmp/out/*.iso /mnt/temp/$branch-sunnyos.iso | |
done | |
" | |
- 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 |