|
| 1 | +name: Post Release Upload |
| 2 | +# This makes it easy to get download release binaries built using |
| 3 | +# a github action for any tagged commit. |
| 4 | +# |
| 5 | +# This workflow builds and uploads the linux |
| 6 | +# binary packages as github assets. |
| 7 | +# |
| 8 | +# It uses `--builders "" --max-jobs 0` to ensure the assets are |
| 9 | +# from the IOG cache. |
| 10 | +on: |
| 11 | + workflow_dispatch: |
| 12 | + release: |
| 13 | + types: |
| 14 | + - published |
| 15 | + push: |
| 16 | + tags: |
| 17 | + - '**' |
| 18 | +env: |
| 19 | + # Only to avoid some repetition |
| 20 | + FLAKE_REF: github:${{ github.repository }}/${{ github.ref_name }} |
| 21 | + GH_TOKEN: ${{ github.token }} |
| 22 | + |
| 23 | +jobs: |
| 24 | + wait-for-hydra: |
| 25 | + name: "Wait for hydra check-runs" |
| 26 | + runs-on: ubuntu-latest |
| 27 | + steps: |
| 28 | + - name: Waiting for ci/hydra-build:x86_64-linux.required to complete |
| 29 | + run: | |
| 30 | + while [[ true ]]; do |
| 31 | + check_name='ci/hydra-build:x86_64-linux.required' |
| 32 | + conclusion=$(gh api "repos/$GITHUB_REPOSITORY/commits/$GITHUB_SHA/check-runs?check_name=$check_name" --paginate --jq '.check_runs[].conclusion') |
| 33 | + case "$conclusion" in |
| 34 | + success) |
| 35 | + echo "$check_name succeeded" |
| 36 | + exit 0;; |
| 37 | + '') |
| 38 | + echo "$check_name pending. Waiting 30s..." |
| 39 | + sleep 30;; |
| 40 | + *) |
| 41 | + echo "$check_name terminated unsuccessfully" |
| 42 | + exit 1;; |
| 43 | + esac |
| 44 | + done |
| 45 | +
|
| 46 | + pull: |
| 47 | + needs: [wait-for-hydra] |
| 48 | + strategy: |
| 49 | + matrix: |
| 50 | + arch: [linux] |
| 51 | + name: "Download Asset from the Cache" |
| 52 | + runs-on: ubuntu-latest |
| 53 | + steps: |
| 54 | + - name: Install Nix with good defaults |
| 55 | + uses: input-output-hk/install-nix-action@v20 |
| 56 | + with: |
| 57 | + extra_nix_config: | |
| 58 | + trusted-public-keys = cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY= hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= |
| 59 | + substituters = https://cache.iog.io/ https://cache.nixos.org/ |
| 60 | + experimental-features = nix-command flakes fetch-closure |
| 61 | + allow-import-from-derivation = true |
| 62 | + accept-flake-config = true |
| 63 | + nix_path: nixpkgs=channel:nixos-unstable |
| 64 | + |
| 65 | + - name: Checkout repository |
| 66 | + uses: actions/checkout@v3 |
| 67 | + |
| 68 | + - name: Build |
| 69 | + run: | |
| 70 | + case ${{ matrix.arch }} in |
| 71 | + linux) |
| 72 | + nix build \ |
| 73 | + --builders "" \ |
| 74 | + --max-jobs 0 \ |
| 75 | + .#packages.x86_64-linux.dmq-node-static |
| 76 | + esac |
| 77 | +
|
| 78 | + - uses: actions/upload-artifact@v4 |
| 79 | + with: |
| 80 | + name: ${{ github.sha }}-${{ matrix.arch }} |
| 81 | + path: dmq-node-*.* |
| 82 | + retention-days: 1 |
| 83 | + |
| 84 | + upload-assets: |
| 85 | + needs: [pull] |
| 86 | + name: "Upload Assets" |
| 87 | + runs-on: ubuntu-latest |
| 88 | + steps: |
| 89 | + - uses: actions/download-artifact@v4 |
| 90 | + with: |
| 91 | + merge-multiple: true |
| 92 | + - name: Checksums |
| 93 | + run: | |
| 94 | + # find returns something like this: |
| 95 | + # "cardano-node-8.11.0-linux.tar.gz cardano-node-8.11.0-darwin.tar.gz ..." |
| 96 | + # We use the first member of this list to compute the prefix "cardano-node-8.11.0" |
| 97 | + first_archive=$(find . -maxdepth 1 -name "dmq-node-*" -printf '%P\n' | head -n 1) |
| 98 | + # Then we trim the architecture-specific suffix (last "-" and after) |
| 99 | + sha256sums_filename=$(echo "${first_archive%-*}-sha256sums.txt") |
| 100 | + sha256sum dmq-node-* >> "$sha256sums_filename" |
| 101 | + - name: Release |
| 102 | + uses: input-output-hk/action-gh-release@v1 |
| 103 | + with: |
| 104 | + draft: true |
| 105 | + files: | |
| 106 | + dmq-node-*-linux.tar.gz |
| 107 | + dmq-node-*-sha256sums.txt |
0 commit comments