Skip to content

Commit

Permalink
chore(release): Rename MacOS artifacts correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
rholshausen committed Dec 19, 2024
1 parent e8a8c2d commit 7bc0cf5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 89 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:
shell: bash
working-directory: rust/pact_ffi
- if: startsWith(github.ref, 'refs/tags/libpact_ffi') && runner.os == 'macOS'
run: ./release-osx.sh
run: ./release-macos.sh
shell: bash
working-directory: rust/pact_ffi
- name: Upload Release Assets
Expand Down
88 changes: 19 additions & 69 deletions rust/pact_ffi/release-macos.sh
Original file line number Diff line number Diff line change
@@ -1,69 +1,19 @@
#!/bin/bash

set -e
set -x

RUST_DIR="$(cd -- "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
APP_NAME=libpact_ffi

source "$RUST_DIR/scripts/gzip-and-sum.sh"
ARTIFACTS_DIR=${ARTIFACTS_DIR:-"$RUST_DIR/release_artifacts"}
mkdir -p "$ARTIFACTS_DIR"
export CARGO_TARGET_DIR=${CARGO_TARGET_DIR:-"$RUST_DIR/target"}

# We target the oldest supported version of macOS.
export MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-12}

# All flags passed to this script are passed to cargo.
case $1 in
x86_64-apple-darwin)
TARGET=$1
shift
;;
aarch64-apple-darwin)
TARGET=$1
shift
;;
*) ;;
esac
cargo_flags=("$@")

build_target() {
TARGET=$1

case $TARGET in
x86_64-apple-darwin)
ARCH_SUFFIX=x86_64
;;
aarch64-apple-darwin)
ARCH_SUFFIX=aarch64
;;
*)
echo unknown target $TARGET
exit 1
;;
esac
cargo build --target $TARGET "${cargo_flags[@]}"

if [[ "${cargo_flags[*]}" =~ "--release" ]]; then
file "$CARGO_TARGET_DIR/$TARGET/release/$APP_NAME.a"
file "$CARGO_TARGET_DIR/$TARGET/release/$APP_NAME.dylib"
du -sh "$CARGO_TARGET_DIR/$TARGET/release/$APP_NAME.a"
du -sh "$CARGO_TARGET_DIR/$TARGET/release/$APP_NAME.dylib"
gzip_and_sum \
"$CARGO_TARGET_DIR/$TARGET/release/$APP_NAME.a" \
"$ARTIFACTS_DIR/$APP_NAME-macos-$ARCH_SUFFIX.a.gz"
gzip_and_sum \
"$CARGO_TARGET_DIR/$TARGET/release/$APP_NAME.dylib" \
"$ARTIFACTS_DIR/$APP_NAME-macos-$ARCH_SUFFIX.dylib.gz"
fi
}

if [ ! -z "$TARGET" ]; then
echo building for target $TARGET
build_target $TARGET
else
echo building for all targets
build_target x86_64-apple-darwin
build_target aarch64-apple-darwin
fi
#!/bin/bash -e

cargo clean
cargo build --release
mkdir -p ../release_artifacts
gzip -c ../target/release/libpact_ffi.dylib > ../release_artifacts/libpact_ffi-osx-x86_64.dylib.gz
openssl dgst -sha256 -r ../release_artifacts/libpact_ffi-osx-x86_64.dylib.gz > ../release_artifacts/libpact_ffi-osx-x86_64.dylib.gz.sha256
gzip -c ../target/release/libpact_ffi.a > ../release_artifacts/libpact_ffi-osx-x86_64.a.gz
openssl dgst -sha256 -r ../release_artifacts/libpact_ffi-osx-x86_64.a.gz > ../release_artifacts/libpact_ffi-osx-x86_64.a.gz.sha256

# M1
export SDKROOT=$(xcrun -sdk macosx11.1 --show-sdk-path)
export MACOSX_DEPLOYMENT_TARGET=$(xcrun -sdk macosx11.1 --show-sdk-platform-version)
cargo build --target aarch64-apple-darwin --release

gzip -c ../target/aarch64-apple-darwin/release/libpact_ffi.dylib > ../release_artifacts/libpact_ffi-osx-aarch64-apple-darwin.dylib.gz
openssl dgst -sha256 -r ../release_artifacts/libpact_ffi-osx-aarch64-apple-darwin.dylib.gz > ../release_artifacts/libpact_ffi-osx-aarch64-apple-darwin.dylib.gz.sha256
gzip -c ../target/aarch64-apple-darwin/release/libpact_ffi.a > ../release_artifacts/libpact_ffi-osx-aarch64-apple-darwin.a.gz
openssl dgst -sha256 -r ../release_artifacts/libpact_ffi-osx-aarch64-apple-darwin.a.gz > ../release_artifacts/libpact_ffi-osx-aarch64-apple-darwin.a.gz.sha256
19 changes: 0 additions & 19 deletions rust/pact_ffi/release-osx.sh

This file was deleted.

0 comments on commit 7bc0cf5

Please sign in to comment.