Skip to content

Update Flake Hash on Release #5

Update Flake Hash on Release

Update Flake Hash on Release #5

name: Update Flake Hash on Release
on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: 'Version to update (e.g., 0.8.1)'
required: true
jobs:
update-hash:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: true
- name: Set up Nix
uses: cachix/install-nix-action@v16
with:
nix_path: nixpkgs=channel:nixos-25.05
- name: Calculate SHA256 hash
id: calculate-hash
uses: workflow/nix-shell-action@v3
with:
packages: nix
script: |
set -euo pipefail
if [ "${{ github.event_name }}" = "release" ]; then
VERSION="${{ github.event.release.tag_name }}"
else
VERSION="${{ github.event.inputs.version }}"
fi
VERSION="${VERSION#v}"
URL="https://github.com/TibixDev/winboat/releases/download/v${VERSION}/winboat-${VERSION}-x64.tar.gz"
echo "Prefetching from: $URL"
HASH=$(nix-prefetch-url "$URL")
echo "Calculated SHA256: $HASH"
echo "nix_sha256=${HASH}" >> $GITHUB_OUTPUT
ESC_HASH=$(printf '%s' "$HASH" | sed -e 's/[\/&]/\\&/g')
git config user.name "github-actions[bot]"
echo "set user.name to github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
echo "set user.email to github-actions[bot]@users.noreply.github.com"
git fetch origin main
git merge --no-edit -X theirs origin/main
sed -i "s/sha256 = \".*\";/sha256 = \"${ESC_HASH}\";/" flake.nix
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"