|
| 1 | +name: Build and Release Multiple ISOs with Different Desktop Environments |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + release_title: |
| 7 | + description: 'Title of the release' |
| 8 | + required: true |
| 9 | + default: 'SunnyOS Multi-Branch Release' |
| 10 | + release_description: |
| 11 | + description: 'Description for the release' |
| 12 | + required: true |
| 13 | + default: 'This release contains ISOs for multiple branches of SunnyOS.' |
| 14 | + release_version: |
| 15 | + description: 'Version of the release' |
| 16 | + required: true |
| 17 | + default: '0.0.0' |
| 18 | + |
| 19 | +jobs: |
| 20 | + build_and_release: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + |
| 23 | + steps: |
| 24 | + - name: Checkout code |
| 25 | + uses: actions/checkout@v3 |
| 26 | + |
| 27 | + - name: Set up Docker Buildx |
| 28 | + uses: docker/setup-buildx-action@v3 |
| 29 | + |
| 30 | + - name: Set up temporary storage |
| 31 | + run: | |
| 32 | + sudo mkdir -p /mnt/temp |
| 33 | + sudo chmod 777 /mnt/temp |
| 34 | +
|
| 35 | + - name: Build Docker Image if not exists |
| 36 | + id: docker_build |
| 37 | + run: | |
| 38 | + IMAGE_NAME="archlinux_sunnyos" |
| 39 | + |
| 40 | + # Check if the Docker image exists |
| 41 | + docker images -q $IMAGE_NAME || \ |
| 42 | + docker build -t $IMAGE_NAME - <<EOF |
| 43 | + FROM archlinux:latest |
| 44 | +
|
| 45 | + # Install necessary packages |
| 46 | + RUN pacman -Sy --noconfirm archiso |
| 47 | +
|
| 48 | + # Install any additional dependencies here (if needed) |
| 49 | + RUN pacman -Sy --noconfirm base-devel git |
| 50 | +
|
| 51 | + EOF |
| 52 | +
|
| 53 | + - name: Build ISOs for all branches |
| 54 | + run: | |
| 55 | + # Define the branches and corresponding desktop environments |
| 56 | + branches=("sunnyos_gnome" "sunnyos_kde" "sunnyos_xfce") |
| 57 | +
|
| 58 | + # Start the Docker container for building |
| 59 | + docker run --rm --privileged \ |
| 60 | + -v "$GITHUB_WORKSPACE:/work" \ |
| 61 | + -v "/mnt/temp:/tmp" \ |
| 62 | + $IMAGE_NAME /bin/bash -c " |
| 63 | +
|
| 64 | + # Loop through each branch and build the ISO |
| 65 | + for branch in \${branches[@]}; do |
| 66 | + git checkout \$branch |
| 67 | + |
| 68 | + # Determine the desktop environment based on the branch |
| 69 | + case \$branch in |
| 70 | + sunnyos_gnome) |
| 71 | + desktop_env='gnome' |
| 72 | + ;; |
| 73 | + sunnyos_kde) |
| 74 | + desktop_env='kde' |
| 75 | + ;; |
| 76 | + sunnyos_xfce) |
| 77 | + desktop_env='xfce' |
| 78 | + ;; |
| 79 | + *) |
| 80 | + desktop_env='default' |
| 81 | + ;; |
| 82 | + esac |
| 83 | +
|
| 84 | + echo 'Building ISO with \$desktop_env for branch \$branch' |
| 85 | + |
| 86 | + # Build the ISO with mkarchiso |
| 87 | + pacman -Sy --noconfirm archiso && |
| 88 | + mkarchiso -v -w /tmp/work -o /tmp/out /work/profiles/\$desktop_env |
| 89 | +
|
| 90 | + # Move the generated ISO to a central location |
| 91 | + mv /mnt/temp/out/*.iso /mnt/temp/\$branch-\$desktop_env-sunnyos.iso |
| 92 | + done |
| 93 | + " |
| 94 | +
|
| 95 | + - name: Create GitHub Release |
| 96 | + id: create_release |
| 97 | + run: | |
| 98 | + release_title="${{ github.event.inputs.release_title }}" |
| 99 | + release_description="${{ github.event.inputs.release_description }}" |
| 100 | + release_version="${{ github.event.inputs.release_version }}" |
| 101 | +
|
| 102 | + echo "Creating release with title: $release_title, description: $release_description, and version: $release_version" |
| 103 | +
|
| 104 | + # Create the release via GitHub API |
| 105 | + release_response=$(curl -XPOST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ |
| 106 | + -d '{ |
| 107 | + "tag_name": "'$release_version'", |
| 108 | + "name": "'$release_title'", |
| 109 | + "body": "'$release_description'", |
| 110 | + "draft": false, |
| 111 | + "prerelease": false |
| 112 | + }' \ |
| 113 | + https://api.github.com/repos/${{ github.repository }}/releases) |
| 114 | +
|
| 115 | + release_id=$(echo $release_response | jq -r '.id') |
| 116 | +
|
| 117 | + echo "Created release with ID: $release_id" |
| 118 | +
|
| 119 | + - name: Upload ISOs to Release |
| 120 | + run: | |
| 121 | + # Upload all ISOs to the GitHub release |
| 122 | + for iso in /mnt/temp/*-sunnyos.iso |
| 123 | + do |
| 124 | + echo "Uploading $iso to release" |
| 125 | + curl -XPOST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ |
| 126 | + -H "Content-Type: application/octet-stream" \ |
| 127 | + --data-binary @$iso \ |
| 128 | + "https://uploads.github.com/repos/${{ github.repository }}/releases/$release_id/assets?name=$(basename $iso)" |
| 129 | + done |
0 commit comments