Skip to content

Commit

Permalink
CI: Release darwin binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
smelc committed Apr 23, 2024
1 parent 4e0b897 commit 35d5401
Showing 1 changed file with 37 additions and 21 deletions.
58 changes: 37 additions & 21 deletions .github/workflows/release-upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,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"
Expand All @@ -114,7 +113,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
Expand All @@ -123,10 +122,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
Expand All @@ -145,20 +144,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)
Expand All @@ -174,31 +180,40 @@ 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
run: |
# (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
if: ${{ needs.wait_for_hydra.outputs.DRY_RUN == 'false' }}
run: |
# Transform the long tag (e.g. "cardano-cli-8.22.0.0")
# into the short version (e.g. "8.22.0.0")
long_tag=${{ needs.wait_for_hydra.outputs.TARGET_TAG }}
short_tag="${long_tag#cardano-cli-}"
echo "SHORT_TAG=$short_tag" >> "$GITHUB_ENV"
- name: Create changelog
if: ${{ needs.wait_for_hydra.outputs.DRY_RUN == 'false' }}
run: |
echo -e "# Changelog\n" > RELEASE_CHANGELOG.md
./scripts/ci/extract-changelog.sh ${{ env.SHORT_TAG }} >> RELEASE_CHANGELOG.md
Expand All @@ -209,9 +224,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

0 comments on commit 35d5401

Please sign in to comment.