configuration.nix/.forgejo/workflows/iso-nixos-installer.yaml
Gregory Bednov 53be2c86e8
All checks were successful
/ build-installer (push) Successful in 1h2m29s
autopublish nixos, fixed names
2026-08-28 22:40:44 +03:00

43 lines
1.6 KiB
YAML

on: [push]
jobs:
build-installer:
runs-on: builder
steps:
- uses: https://code.forgejo.org/actions/checkout@v4
- run: nix build ./installer
- name: Publish release if ISO changed
env:
TOKEN: ${{ forgejo.token }}
SERVER: ${{ forgejo.server_url }}
REPO: ${{ forgejo.repository }}
run: |
ISO="result/iso/mirea-nixos-installer.iso"
NEW_SHA=$(sha256sum "$ISO" | awk '{print $1}')
LATEST_BODY=$(curl -sf \
-H "Authorization: token $TOKEN" \
"$SERVER/api/v1/repos/$REPO/releases/latest" \
| jq -r '.body // ""' || echo "")
OLD_SHA=$(echo "$LATEST_BODY" | grep -oE '[a-f0-9]{64}' | head -1 || echo "")
if [ "$NEW_SHA" = "$OLD_SHA" ]; then
echo "ISO unchanged (sha256: $NEW_SHA), skipping release."
exit 0
fi
TAG="iso-$(date -u +%Y%m%d-%H%M%S)"
RELEASE_ID=$(curl -sf -X POST \
-H "Authorization: token $TOKEN" \
-H "Content-Type: application/json" \
"$SERVER/api/v1/repos/$REPO/releases" \
-d "$(jq -n --arg tag "$TAG" --arg sha "$NEW_SHA" \
'{tag_name: $tag, name: ("NixOS Installer " + $tag), body: $sha}')" \
| jq -r '.id')
curl -sf -X POST \
-H "Authorization: token $TOKEN" \
-H "Content-Type: application/octet-stream" \
"$SERVER/api/v1/repos/$REPO/releases/$RELEASE_ID/assets?name=mirea-nixos-installer.iso" \
--data-binary "@$ISO"
echo "Published release $TAG (sha256: $NEW_SHA)"