|
| 1 | +name: Wait for Hydra Build |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + tags: |
| 8 | + - "v*.*" |
| 9 | + pull_request: |
| 10 | + |
| 11 | +env: |
| 12 | + FLAKE_REF: github:${{ github.repository }}?ref=${{ github.head_ref || github.ref }} |
| 13 | + GH_TOKEN: ${{ github.token }} |
| 14 | + |
| 15 | +jobs: |
| 16 | + wait-for-hydra: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: Checkout |
| 21 | + uses: actions/checkout@v4 |
| 22 | + |
| 23 | + - name: Install Nix with good defaults |
| 24 | + uses: input-output-hk/install-nix-action@v20 |
| 25 | + with: |
| 26 | + extra_nix_config: | |
| 27 | + trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= loony-tools:pr9m4BkM/5/eSTZlkQyRt57Jz7OMBxNSUiMC4FkcNfk= |
| 28 | + substituters = https://cache.nixos.org/ https://cache.iog.io/ https://cache.zw3rk.com |
| 29 | + nix_path: nixpkgs=channel:nixos-unstable |
| 30 | + |
| 31 | + - name: Display flake metadata |
| 32 | + id: flake-metadata |
| 33 | + run: | |
| 34 | + echo $PWD |
| 35 | + ls -lah . |
| 36 | + nix flake metadata ${{ env.FLAKE_REF }} |
| 37 | + nix flake metadata ${{ env.FLAKE_REF }} --json | jq -r '"LOCKED_URL=\(.url)"' >> "$GITHUB_OUTPUT" |
| 38 | +
|
| 39 | + - name: Wait for nix-tools meta job |
| 40 | + uses: input-output-hk/actions/wait-for-hydra@angerman/support-prs |
| 41 | + with: |
| 42 | + status: 'ci/hydra-build:nix-tools' |
| 43 | + |
| 44 | + - name: "Pull nix-tools" |
| 45 | + run: | |
| 46 | + ls -lah . |
| 47 | + cp $(nix build --builders "" --max-jobs 0 ${{ steps.flake-metadata.outputs.LOCKED_URL }}#hydraJobs.aarch64-darwin.nix-tools-static-no-ifd --no-link --print-out-paths)/*.zip . |
| 48 | + cp $(nix build --builders "" --max-jobs 0 ${{ steps.flake-metadata.outputs.LOCKED_URL }}#hydraJobs.x86_64-darwin.nix-tools-static-no-ifd --no-link --print-out-paths)/*.zip . |
| 49 | + cp $(nix build --builders "" --max-jobs 0 ${{ steps.flake-metadata.outputs.LOCKED_URL }}#hydraJobs.x86_64-linux.nix-tools-static-no-ifd --no-link --print-out-paths)/*.zip . |
| 50 | + cp $(nix build --builders "" --max-jobs 0 ${{ steps.flake-metadata.outputs.LOCKED_URL }}#hydraJobs.x86_64-linux.nix-tools-static-arm64-no-ifd --no-link --print-out-paths)/*.zip . |
| 51 | +
|
| 52 | + - name: Configure Git |
| 53 | + if: startsWith(github.ref, 'refs/tags/') |
| 54 | + run: | |
| 55 | + git config --global user.name 'Auto Update Bot' |
| 56 | + git config --global user.email '[email protected]' |
| 57 | +
|
| 58 | + - name: "Compute default.nix" |
| 59 | + if: startsWith(github.ref, 'refs/tags/') |
| 60 | + run: | |
| 61 | + git fetch --all |
| 62 | + git switch --force nix |
| 63 | + ( |
| 64 | + echo "pkgs: let baseurl = \"https://github.com/input-output-hk/haskell-nix-example/releases/download/${GITHUB_REF_NAME}/\"; in {" |
| 65 | + for arch in aarch64-darwin x86_64-darwin aarch64-linux x86_64-linux; do |
| 66 | + echo " ${arch} = pkgs.fetchurl { " |
| 67 | + echo " name = \"${arch}-nix-tools-static\";" |
| 68 | + echo " url = \"\${baseurl}${arch}-nix-tools-static.zip\";" |
| 69 | + echo " sha256 = \"$(nix-hash --sri --type sha256 --flat ${arch}-nix-tools-static.zip)\";" |
| 70 | + echo " };" |
| 71 | + done |
| 72 | + echo "}" |
| 73 | + ) > default.nix |
| 74 | + cat default.nix |
| 75 | +
|
| 76 | +
|
| 77 | + - name: Push to nix branch |
| 78 | + if: startsWith(github.ref, 'refs/tags/') |
| 79 | + run: | |
| 80 | + git add default.nix |
| 81 | + git commit -m "update default.nix" |
| 82 | + git push origin nix |
| 83 | +
|
| 84 | + - name: Release |
| 85 | + uses: input-output-hk/action-gh-release@v1 |
| 86 | + if: startsWith(github.ref, 'refs/tags/') |
| 87 | + with: |
| 88 | + files: | |
| 89 | + *-nix-tools-static.zip |
0 commit comments