Skip to content

Commit

Permalink
Merge pull request #819 from IntersectMBO/angerman/cross
Browse files Browse the repository at this point in the history
Build aarch64-linux binary in Hydra + use static binary for x86-64 Linux release
  • Loading branch information
palas committed Jul 15, 2024
2 parents 23e4354 + 1d26070 commit 9b34c13
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 7 deletions.
27 changes: 22 additions & 5 deletions .github/workflows/release-upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ jobs:
echo "TARGET_TAG=$target_tag" >> "$GITHUB_ENV"
echo "TARGET_TAG=$target_tag" >> "$GITHUB_OUTPUT"
flake_ref="github:${{ github.repository }}/${{ env.TARGET_TAG }}"
flake_ref="github:${{ github.repository }}/$target_tag"
echo "FLAKE_REF=$flake_ref" >> "$GITHUB_OUTPUT"
echo "DRY_RUN=$dry_run" >> "$GITHUB_OUTPUT"
Expand Down Expand Up @@ -135,7 +135,7 @@ jobs:
strategy:
matrix:
# TODO generalize
arch: [x86_64-linux, x86_64-darwin, aarch64-darwin]
arch: [x86_64-linux, x86_64-darwin, aarch64-darwin, aarch64-linux]
name: "Download Asset"
runs-on: ubuntu-latest
steps:
Expand All @@ -153,7 +153,23 @@ jobs:
nix flake metadata "${{ needs.wait_for_hydra.outputs.FLAKE_REF }}" --json | jq -r '"LOCKED_URL=\(.url)"' >> "$GITHUB_ENV"
- name: Build
run: |
derivation="hydraJobs.${{ matrix.arch }}.packages.cardano-cli:exe:cardano-cli"
derivation="hydraJobs."
case ${{ matrix.arch }} in
"x86_64-darwin" | "aarch64-darwin")
derivation+="${{ matrix.arch }}"
;;
"x86_64-linux")
derivation+="x86_64-linux.x86_64-unknown-linux-musl"
;;
"aarch64-linux")
derivation+="x86_64-linux.aarch64-unknown-linux-musl"
;;
*)
echo "Unexpected matrix.arch value: ${{ matrix.arch }}"
exit 1
;;
esac
derivation+=".packages.cardano-cli:exe:cardano-cli"
nix build --builders "" --max-jobs 0 ${{ env.LOCKED_URL }}#$derivation
tree result
cp result/bin/cardano-cli cardano-cli-${{ matrix.arch }} # (1)
Expand All @@ -178,15 +194,15 @@ jobs:
# (2)
# 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
for arch in x86_64-linux x86_64-darwin aarch64-darwin; do
for arch in x86_64-linux x86_64-darwin aarch64-darwin aarch64-linux; do
tar -czf ${{ needs.wait_for_hydra.outputs.TARGET_TAG }}-$arch.tar.gz cardano-cli-$arch
done
# TODO generalize
# zip ${{ needs.wait_for_hydra.outputs.TARGET_TAG }}-win64.zip cardano-cli-win64
- name: Checksums
run: |
# (3)
for arch in x86_64-linux x86_64-darwin aarch64-darwin; do
for arch in x86_64-linux x86_64-darwin aarch64-darwin aarch64-linux; do
sha256sum ${{ needs.wait_for_hydra.outputs.TARGET_TAG }}-$arch.tar.gz >> ${{ needs.wait_for_hydra.outputs.TARGET_TAG }}-sha256sums.txt
done
- name: Create short tag
Expand All @@ -213,5 +229,6 @@ jobs:
${{ needs.wait_for_hydra.outputs.TARGET_TAG }}-x86_64-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
${{ needs.wait_for_hydra.outputs.TARGET_TAG }}-aarch64-linux.tar.gz
${{ needs.wait_for_hydra.outputs.TARGET_TAG }}-sha256sums.txt
body_path: RELEASE_CHANGELOG.md
11 changes: 11 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ if os(windows)
constraints: time ^>=1.14
allow-newer: *:time

constraints: any.text source
-- Depending on C++ for just so slightly faster utf8 parsing is a bit annoying
-- especially as it brings in all kinds of complications for GHC.
package text
flags: -simdutf

-- formatting (>= 7.2) allows us do drop double-conversion (which again is one
-- of the offending c++ dependencies)
package formatting
flags: +no-double-conversion

tests: True

test-show-details: direct
Expand Down
9 changes: 7 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,13 @@

# we also want cross compilation to windows on linux (and only with default compiler).
crossPlatforms = p:
lib.optional (system == "x86_64-linux" && config.compiler-nix-name == mingwVersion)
p.mingwW64;
lib.optionals (system == "x86_64-linux" && config.compiler-nix-name == mingwVersion)
[
p.mingwW64 # x86_64-windows
p.aarch64-multiplatform-musl # aarch64-linux (static)
p.musl64 # x86_64-linux (static)

];

# CHaP input map, so we can find CHaP packages (needs to be more
# recent than the index-state we set!). Can be updated with
Expand Down

0 comments on commit 9b34c13

Please sign in to comment.