autopublish nixos
Some checks failed
/ build-installer (push) Failing after 1s

This commit is contained in:
Gregory Bednov 2026-08-28 22:28:39 +03:00
commit 0907e6989f

View file

@ -5,3 +5,39 @@ jobs:
steps: steps:
- uses: https://code.forgejo.org/actions/checkout@v4 - uses: https://code.forgejo.org/actions/checkout@v4
- run: nix build ./installer - run: nix build ./installer
- name: Publish release if ISO changed
env:
TOKEN: ${{ gitea.token }}
SERVER: ${{ gitea.server_url }}
REPO: ${{ gitea.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)"