Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 39 additions & 6 deletions .github/workflows/update-flake-hash.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
name: Update Flake Hash on Release

on:
release:
types: [published]
workflow_run:
workflows: ["Build WinBoat"]
types:
- completed
branches:
- main
workflow_dispatch:
inputs:
version:
Expand All @@ -12,6 +16,10 @@ on:
jobs:
update-hash:
runs-on: ubuntu-latest
# Only run if the workflow succeeded and was triggered by a tag
if: |
github.event.workflow_run.conclusion == 'success' &&
startsWith(github.event.workflow_run.head_branch, 'refs/tags/')
permissions:
contents: write

Expand All @@ -35,16 +43,33 @@ jobs:
script: |
set -euo pipefail

if [ "${{ github.event_name }}" = "release" ]; then
VERSION="${{ github.event.release.tag_name }}"
if [ "${{ github.event_name }}" = "workflow_run" ]; then
# Extract version from the tag ref (refs/tags/v0.8.7 -> v0.8.7)
VERSION="${{ github.event.workflow_run.head_branch }}"
VERSION="${VERSION#refs/tags/}"
else
VERSION="${{ github.event.inputs.version }}"
# Manual workflow_dispatch trigger
VERSION="${{ inputs.version }}"
fi

VERSION="${VERSION#v}"

URL="https://github.com/TibixDev/winboat/releases/download/v${VERSION}/winboat-${VERSION}-x64.tar.gz"

echo "Checking if release asset is available..."
for i in {1..30}; do
if curl --head --fail "$URL" &>/dev/null; then
echo "✓ Release asset is available"
break
fi
if [ $i -eq 30 ]; then
echo "✗ Release asset not available after 5 minutes"
exit 1
fi
echo "Waiting for asset... (attempt $i/30)"
sleep 10
done

echo "Prefetching from: $URL"
HASH=$(nix-prefetch-url "$URL")

Expand All @@ -66,4 +91,12 @@ jobs:

git add flake.nix || true
git commit -m "chore: update flake.nix for version ${VERSION}" || echo "No changes to commit"
git push origin HEAD:main || echo "Push failed"
git push origin HEAD:main || echo "Push failed"

# Also update the tag with the corrected flake hash
if [ "${{ github.event_name }}" = "release" ]; then
TAG="${{ github.event.release.tag_name }}"
echo "Updating tag ${TAG} with corrected flake hash"
git tag -f "${TAG}" HEAD
git push -f origin "${TAG}" || echo "Failed to update tag"
fi