Skip to content

Commit

Permalink
workflow: fix: release.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
sppidy authored Dec 24, 2024
1 parent be5a395 commit 730c7c2
Showing 1 changed file with 46 additions and 69 deletions.
115 changes: 46 additions & 69 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,53 +4,40 @@ on:
workflow_dispatch:
inputs:
release_title:
description: 'Title of the release'
description: 'Title for the release'
required: true
default: 'SunnyOS Multi-Branch Release'
release_description:
description: 'Description for the release'
required: true
default: 'This release contains ISOs for multiple branches of SunnyOS.'
release_version:
description: 'Version of the release'
description: 'Version for the release'
required: true
default: '0.0.0'

jobs:
build_and_release:
runs-on: ubuntu-latest

steps:
- name: Checkout code
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Set up temporary storage
- name: Set up Docker image
env:
IMAGE_NAME: archlinux_sunnyos
run: |
sudo mkdir -p /mnt/temp
sudo chmod 777 /mnt/temp
- name: Build Docker Image if not exists
id: docker_build
run: |
IMAGE_NAME="archlinux_sunnyos"
# Check if the Docker image exists
docker images -q $IMAGE_NAME || \
# Check if the Docker image exists; build if not
if [ -z "$(docker images -q $IMAGE_NAME)" ]; then
echo "Building Docker image: $IMAGE_NAME"
docker build -t $IMAGE_NAME - <<EOF
FROM archlinux:latest
# Install necessary packages
RUN pacman -Sy --noconfirm archiso
# Install any additional dependencies here (if needed)
RUN pacman -Sy --noconfirm base-devel git
RUN pacman -Sy --noconfirm archiso base-devel git
EOF
else
echo "Docker image $IMAGE_NAME already exists."
fi
- name: Build ISOs for all branches
env:
IMAGE_NAME: archlinux_sunnyos
run: |
# Define the branches and corresponding desktop environments
branches=("sunnyos_gnome" "sunnyos_kde" "sunnyos_xfce")
Expand All @@ -60,69 +47,59 @@ jobs:
-v "$GITHUB_WORKSPACE:/work" \
-v "/mnt/temp:/tmp" \
$IMAGE_NAME /bin/bash -c "
for branch in ${branches[@]}; do
echo 'Checking out branch: $branch'
git checkout $branch
# Loop through each branch and build the ISO
for branch in \${branches[@]}; do
git checkout \$branch
# Determine the desktop environment based on the branch
case \$branch in
sunnyos_gnome)
desktop_env='gnome'
;;
sunnyos_kde)
desktop_env='kde'
;;
sunnyos_xfce)
desktop_env='xfce'
;;
*)
desktop_env='default'
;;
case $branch in
sunnyos_gnome) desktop_env='gnome' ;;
sunnyos_kde) desktop_env='kde' ;;
sunnyos_xfce) desktop_env='xfce' ;;
*) desktop_env='default' ;;
esac
echo 'Building ISO with \$desktop_env for branch \$branch'
# Build the ISO with mkarchiso
pacman -Sy --noconfirm archiso &&
mkarchiso -v -w /tmp/work -o /tmp/out /work/profiles/\$desktop_env
echo 'Building ISO with $desktop_env for branch $branch'
pacman -Sy --noconfirm archiso
mkarchiso -v -w /tmp/work -o /tmp/out /work/profiles/$desktop_env
# Move the generated ISO to a central location
mv /mnt/temp/out/*.iso /mnt/temp/\$branch-\$desktop_env-sunnyos.iso
mv /tmp/out/*.iso /mnt/temp/$branch-$desktop_env-sunnyos.iso
done
"
- name: Create GitHub Release
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
release_title="${{ github.event.inputs.release_title }}"
release_description="${{ github.event.inputs.release_description }}"
release_version="${{ github.event.inputs.release_version }}"
echo "Creating release with title: $release_title, description: $release_description, and version: $release_version"
# Create the release via GitHub API
release_response=$(curl -XPOST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
release_response=$(curl -XPOST -H "Authorization: token $GITHUB_TOKEN" \
-d '{
"tag_name": "'$release_version'",
"name": "'$release_title'",
"body": "'$release_description'",
"draft": false,
"prerelease": false
}' \
"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: |
# Upload all ISOs to the GitHub release
for iso in /mnt/temp/*-sunnyos.iso
do
for iso in /mnt/temp/*-sunnyos.iso; do
echo "Uploading $iso to release"
curl -XPOST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
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)"
Expand Down

0 comments on commit 730c7c2

Please sign in to comment.