This repository was archived by the owner on Aug 23, 2026. It is now read-only.
Repository navigation
Sync libvhdi upstream #46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Sync libvhdi upstream | |
| on: | |
| schedule: | |
| - cron: "15 5 * * *" | |
| workflow_dispatch: | |
| inputs: | |
| dry_run: | |
| description: "Detect, update, and build without committing or tagging" | |
| required: false | |
| default: false | |
| type: boolean | |
| concurrency: | |
| group: libvhdi-upstream-sync | |
| cancel-in-progress: false | |
| jobs: | |
| sync: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install Nix | |
| uses: cachix/install-nix-action@v31 | |
| with: | |
| nix_path: nixpkgs=channel:nixos-unstable | |
| - name: Setup Cachix | |
| if: vars.CACHIX_CACHE_NAME != '' | |
| uses: cachix/cachix-action@v17 | |
| with: | |
| name: ${{ vars.CACHIX_CACHE_NAME }} | |
| authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} | |
| skipPush: true | |
| continue-on-error: true | |
| - name: Update package metadata | |
| id: package | |
| run: | | |
| set -euo pipefail | |
| package_version() { | |
| nix eval --raw --no-write-lock-file .#libvhdi.version | |
| } | |
| current_version=$(package_version) | |
| if [ -z "$current_version" ]; then | |
| echo "Failed to read current package version from flake package metadata" >&2 | |
| exit 1 | |
| fi | |
| chmod +x ./update.sh | |
| ./update.sh | tee update.log | |
| latest_version=$(sed -nE 's/^Latest libvhdi version: ([0-9]{8})$/\1/p' update.log | head -n 1) | |
| if [ -z "$latest_version" ]; then | |
| echo "Failed to read latest upstream libvhdi version from updater output" >&2 | |
| exit 1 | |
| fi | |
| new_version=$(package_version) | |
| if [ -z "$new_version" ]; then | |
| echo "Failed to read updated package version from flake package metadata" >&2 | |
| exit 1 | |
| fi | |
| echo "Current package version: $current_version" | |
| echo "Latest upstream version: $latest_version" | |
| echo "Package version after updater: $new_version" | |
| if git diff --quiet -- default.nix; then | |
| echo "update_available=false" >> "$GITHUB_OUTPUT" | |
| else | |
| if [ "$new_version" != "$latest_version" ]; then | |
| echo "Package version $new_version does not match upstream tag $latest_version" >&2 | |
| exit 1 | |
| fi | |
| if git rev-parse -q --verify "refs/tags/$new_version" >/dev/null; then | |
| echo "Tag $new_version already exists in this repository" >&2 | |
| exit 1 | |
| fi | |
| echo "update_available=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| if [ "$latest_version" != "$current_version" ] && [ "$new_version" = "$current_version" ]; then | |
| echo "Updater reported a newer upstream tag, but default.nix did not change" >&2 | |
| exit 1 | |
| fi | |
| echo "current_version=$current_version" >> "$GITHUB_OUTPUT" | |
| echo "latest_version=$latest_version" >> "$GITHUB_OUTPUT" | |
| echo "new_version=$new_version" >> "$GITHUB_OUTPUT" | |
| - name: Format and lint | |
| if: ${{ steps.package.outputs.update_available == 'true' }} | |
| run: | | |
| nix develop .#default -c nixpkgs-fmt default.nix flake.nix | |
| nix develop .#default -c shellcheck update.sh | |
| git diff --check | |
| - name: Build updated package variants | |
| if: ${{ steps.package.outputs.update_available == 'true' }} | |
| run: | | |
| nix build .#libvhdi-fuse2 -o result-fuse2 -L | |
| nix build .#libvhdi-fuse3 -o result-fuse3 -L | |
| - name: Run flake checks | |
| if: ${{ steps.package.outputs.update_available == 'true' }} | |
| run: nix flake check --no-write-lock-file -L | |
| - name: Confirm FUSE backends | |
| if: ${{ steps.package.outputs.update_available == 'true' }} | |
| run: | | |
| set -euo pipefail | |
| ldd result-fuse2/bin/vhdimount | tee fuse2.ldd | |
| grep -q 'libfuse.so' fuse2.ldd | |
| if grep -q 'libfuse3.so' fuse2.ldd; then | |
| echo "FUSE2 variant linked libfuse3 unexpectedly" >&2 | |
| exit 1 | |
| fi | |
| ldd result-fuse3/bin/vhdimount | tee fuse3.ldd | |
| grep -q 'libfuse3.so' fuse3.ldd | |
| - name: Push built package to Cachix | |
| if: ${{ steps.package.outputs.update_available == 'true' && (github.event_name != 'workflow_dispatch' || inputs.dry_run != true) && vars.CACHIX_CACHE_NAME != '' }} | |
| env: | |
| CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }} | |
| run: | | |
| set -euo pipefail | |
| if [ -z "${CACHIX_AUTH_TOKEN:-}" ]; then | |
| echo "CACHIX_AUTH_TOKEN is not configured; skipping Cachix push." | |
| exit 0 | |
| fi | |
| out_paths=$(readlink -f result-fuse2 result-fuse3) | |
| echo "Pushing built package outputs:" | |
| printf '%s\n' "$out_paths" | |
| printf '%s\n' "$out_paths" | cachix push "${{ vars.CACHIX_CACHE_NAME }}" | |
| - name: Commit and tag package update | |
| if: ${{ steps.package.outputs.update_available == 'true' && (github.event_name != 'workflow_dispatch' || inputs.dry_run != true) }} | |
| run: | | |
| set -euo pipefail | |
| new_version="${{ steps.package.outputs.new_version }}" | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add default.nix flake.nix | |
| git commit -m "libvhdi: update to $new_version" | |
| git tag -a "$new_version" -m "libvhdi $new_version" | |
| git push origin "HEAD:${GITHUB_REF_NAME}" | |
| git push origin "refs/tags/$new_version" | |
| - name: Report result | |
| if: always() | |
| run: | | |
| { | |
| echo "## libvhdi upstream sync" | |
| echo "" | |
| echo "- Current package version before run: \`${{ steps.package.outputs.current_version }}\`" | |
| echo "- Latest upstream version: \`${{ steps.package.outputs.latest_version }}\`" | |
| echo "- Update available: \`${{ steps.package.outputs.update_available }}\`" | |
| if [ "${{ steps.package.outputs.update_available }}" = "true" ]; then | |
| echo "- Updated package version: \`${{ steps.package.outputs.new_version }}\`" | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ] && [ "${{ inputs.dry_run }}" = "true" ]; then | |
| echo "- Dry run: package was built and checked, but no commit or tag was pushed" | |
| else | |
| echo "- Pushed tag: \`${{ steps.package.outputs.new_version }}\`" | |
| fi | |
| fi | |
| } >> "$GITHUB_STEP_SUMMARY" |