Skip to content

Build Images

Build Images #27

Workflow file for this run

name: Build Images
on:
workflow_dispatch:
jobs:
build:
runs-on: [self-hosted, ARM64, BredOS]
strategy:
fail-fast: false
matrix:
image: [nova-image, nx5-image, opi5-image, opi5plus-image, r58s-image, r58x-4g-image, r58x-image, r58x-pro-image, rock4c-plus-image, rock5a-image, rock5b-image, rock5bp-image, rock5c-image, rock5d-image, rock5itx-image, cpi4-image, edge2-cinnamon-image, fydetabduo-image, vim4-gnome-image]
steps:
- name: Checkout Images
uses: actions/checkout@v4
with:
path: images
- name: Checkout mkimage
uses: actions/checkout@v4
with:
repository: BredOS/mkimage
path: mkimage
- name: Install dependencies
run: |
sudo pacman -Sy --noconfirm --needed \
python python-prettytable parted btrfs-progs \
git wget arch-install-scripts unzip gptfdisk xz jq
- name: Build Image
run: |
sudo umount -R ./work/aarch64/* || true
sudo rm -rf /var/lib/pacman/db.lck ./out ./work
sudo python mkimage/mkimage.py -c images/${{ matrix.image }} -w ./work -o ./out
- name: Send image to release job
run: |
scp out/*.img.xz $RELEASE_VM:/images/
env:
RELEASE_VM: ${{ secrets.RELEASE_VM }}
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.image }}
path: out/*.img.xz
retention-days: 7
- name: Cleanup
if: always()
run: |
sudo umount -R ./work/aarch64/* || true
sudo rm -rf ./work ./out
release:
if: always()
needs: build
runs-on: [self-hosted, ARM64, BredOS, emag]
steps:
- name: Set current date as tag name
id: set_tag_name
run: echo "TAG_NAME=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
- name: Create Release and Upload Each Image Individually
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
TAG_NAME: ${{ env.TAG_NAME }}
run: |
# Create a draft release
RELEASE_RESPONSE=$(curl -s -X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"tag_name\": \"$TAG_NAME\", \"name\": \"$TAG_NAME\", \"draft\": true, \"prerelease\": true}" \
"https://api.github.com/repos/$REPO/releases")
RELEASE_ID=$(echo $RELEASE_RESPONSE | jq -r '.id')
if [ "$RELEASE_ID" == "null" ]; then
echo "Failed to create a release. Response: $RELEASE_RESPONSE"
exit 1
fi
# Upload each image file to the release
for img in /images/*.img.xz; do
FILENAME=$(basename "$img")
echo "Uploading $FILENAME to release $RELEASE_ID"
curl -s \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: application/octet-stream" \
-T "$img" \
"https://uploads.github.com/repos/$REPO/releases/$RELEASE_ID/assets?name=$FILENAME"
done
- name: Clean up
if: always()
run: |
rm -rf ./out/ /images/*.img.xz