From 3882e224d2b12d82a01a817a5c20f897c23a0720 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Hurlin?= Date: Tue, 23 Apr 2024 14:59:43 +0200 Subject: [PATCH] CI: Release darwin binaries --- .github/workflows/release-upload.yaml | 56 +++++++++++++++++---------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/.github/workflows/release-upload.yaml b/.github/workflows/release-upload.yaml index c4367621cf..709debdb3d 100644 --- a/.github/workflows/release-upload.yaml +++ b/.github/workflows/release-upload.yaml @@ -96,8 +96,7 @@ jobs: timeout-minutes: 120 run: | while true; do - # When supporting other architectures than Linux, this query should be adapted: - conclusion=$(gh api "repos/$GITHUB_REPOSITORY/commits/${{ env.TARGET_TAG }}/check-runs" --jq '.check_runs[] | select(.name | test("ci/hydra-build:.*-linux.required")) | .conclusion') + conclusion=$(gh api "repos/$GITHUB_REPOSITORY/commits/${{ env.TARGET_TAG }}/check-runs" --jq '.check_runs[] | select(.name | test("ci/hydra-build:.*\\.required")) | .conclusion' | more | uniq) case "$conclusion" in success) echo "ci/hydra-build:required succeeded" @@ -106,7 +105,7 @@ jobs: echo "ci/hydra-build:required failed" exit 1;; *) - echo "ci/hydra-build:required pending. Waiting 30s..." + echo "ci/hydra-build:required pending with $conclusion. Waiting 30s..." sleep 30;; esac done @@ -115,10 +114,10 @@ jobs: needs: [wait_for_hydra] strategy: matrix: - arch: [linux] + arch: [linux, x86_64-darwin, aarch64-darwin] # TODO generalize # arch: [linux, macos, win64] - name: "Download Asset from the Cache" + name: "Download Asset" runs-on: ubuntu-latest steps: - name: Install Nix with good defaults @@ -137,20 +136,27 @@ jobs: run: | case ${{ matrix.arch }} in linux) - nix build --builders "" --max-jobs 0 ${{ env.LOCKED_URL }}#cardano-cli:exe:cardano-cli - tree result - cp result/bin/cardano-cli cardano-cli-${{ matrix.arch }} # (1) + derivation="cardano-cli:exe:cardano-cli" + ;; + x86_64-darwin) + derivation="hydraJobs.x86_64-darwin.packages.cardano-cli:exe:cardano-cli" + ;; + aarch64-darwin) + derivation="hydraJobs.aarch64-darwin.packages.cardano-cli:exe:cardano-cli" ;; # TODO generalize - # macos) - # nix build --builders "" --max-jobs 0 ${{ steps.flake-metadata.outputs.LOCKED_URL }}#cardano-cli:exe:cardano-cli - # tree result # ;; # win64) - # nix build --builders "" --max-jobs 0 ${{ steps.flake-metadata.outputs.LOCKED_URL }}#x86_64-w64-mingw32:cardano-cli:exe:cardano-cli - # tree result + # derivation="x86_64-w64-mingw32:cardano-cli:exe:cardano-cli" # ;; + *) + echo "Unrecognized arch: ${{ matrix.arch }}" + exit 1 + ;; esac + nix build --builders "" --max-jobs 0 ${{ env.LOCKED_URL }}#$derivation + tree result + cp result/bin/cardano-cli cardano-cli-${{ matrix.arch }} # (1) - uses: actions/upload-artifact@v4 with: name: cardano-cli-${{ matrix.arch }} # (2) @@ -166,12 +172,17 @@ jobs: - uses: actions/checkout@v4 # We need the repo to execute extract-changelog.sh below - uses: actions/download-artifact@v4 with: - name: cardano-cli-linux # Should match (2) + merge-multiple: true + # with: + # name: cardano-cli-linux # Should match (2) + # - uses: actions/download-artifact@v4 + # with: + # name: cardano-cli-x86_64-darwin # Should match (2) + # - uses: actions/download-artifact@v4 + # with: + # name: cardano-cli-aarch64-darwin # Should match (2) # TODO generalize - # - uses: actions/download-artifact@v3 - # with: - # name: cardano-cli-macos # Should match (2) - # - uses: actions/download-artifact@v3 + # - uses: actions/download-artifact@v4 # with: # name: cardano-cli-win64 # Should match (2) - name: Compress @@ -179,9 +190,11 @@ jobs: # (3) # TARGET_TAG is of the form cardano-cli-8.22.0, so we don't need to prefix the tar.gz's name # with cardano-cli - tar -czf ${{ needs.wait_for_hydra.outputs.TARGET_TAG }}-linux.tar.gz cardano-cli-linux + for arch in linux x86_64-darwin aarch64-darwin + do + tar -czf ${{ needs.wait_for_hydra.outputs.TARGET_TAG }}-$arch.tar.gz cardano-cli-$arch + done # TODO generalize - # tar -czf ${{ needs.wait_for_hydra.outputs.TARGET_TAG }}-macos.tar.gz cardano-cli-macos # zip ${{ needs.wait_for_hydra.outputs.TARGET_TAG }}-win64.zip cardano-cli-win64 - name: Create short tag run: | @@ -201,9 +214,10 @@ jobs: tag_name: ${{ needs.wait_for_hydra.outputs.TARGET_TAG }} # Git tag the release is attached to name: ${{ env.SHORT_TAG }} # Release name in GitHub UI # TODO generalize - # cardano-cli-${{ needs.wait_for_hydra.outputs.TARGET_TAG }}-macos.tar.gz # cardano-cli-${{ needs.wait_for_hydra.outputs.TARGET_TAG }}-win64.zip # All entries in 'files' below should match (3) files: | ${{ needs.wait_for_hydra.outputs.TARGET_TAG }}-linux.tar.gz + ${{ needs.wait_for_hydra.outputs.TARGET_TAG }}-x86_64-darwin.tar.gz + ${{ needs.wait_for_hydra.outputs.TARGET_TAG }}-aarch64-darwin.tar.gz body_path: RELEASE_CHANGELOG.md