From 0097b6d41c14893d9168edcfde84f2b944cf61a1 Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Thu, 8 Feb 2024 19:39:14 +0000 Subject: [PATCH 1/2] feat: build for musl --- .github/workflows/release.yml | 2 +- .gitignore | 1 + release.sh | 43 +++++++++++++++++++++++------------ 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 864ec25..e84f7ae 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -35,6 +35,6 @@ jobs: uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: target/artifacts/* + file: release_artifacts/* file_glob: true tag: ${{ github.ref }} diff --git a/.gitignore b/.gitignore index d732df6..badfc77 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # will have compiled files and executables target/ +release_artifacts # These are backup files generated by rustfmt **/*.rs.bk diff --git a/release.sh b/release.sh index dba58ff..790024b 100755 --- a/release.sh +++ b/release.sh @@ -11,41 +11,54 @@ set -e echo Building Release for "$1" - "$2" cargo clean -mkdir -p target/artifacts +mkdir -p release_artifacts case "$1" in Linux) echo "Building for Linux" docker run --rm --user "$(id -u)":"$(id -g)" -v "$(pwd):/workspace" -w /workspace -t pactfoundation/rust-musl-build -c 'cargo build --release' - gzip -c target/release/pact-protobuf-plugin > target/artifacts/pact-protobuf-plugin-linux-x86_64.gz - openssl dgst -sha256 -r target/artifacts/pact-protobuf-plugin-linux-x86_64.gz > target/artifacts/pact-protobuf-plugin-linux-x86_64.gz.sha256 - cp pact-plugin.json target/artifacts + gzip -c target/release/pact-protobuf-plugin > release_artifacts/pact-protobuf-plugin-linux-x86_64.gz + openssl dgst -sha256 -r release_artifacts/pact-protobuf-plugin-linux-x86_64.gz > release_artifacts/pact-protobuf-plugin-linux-x86_64.gz.sha256 + cp pact-plugin.json release_artifacts NEXT=$(echo "$2" | cut -d\- -f2) - sed -e 's/VERSION=\"0.1.5\"/VERSION=\"'${NEXT}'\"/' scripts/install-plugin.sh > target/artifacts/install-plugin.sh - openssl dgst -sha256 -r target/artifacts/install-plugin.sh > target/artifacts/install-plugin.sh.sha256 + sed -e 's/VERSION=\"0.1.5\"/VERSION=\"'${NEXT}'\"/' scripts/install-plugin.sh > release_artifacts/install-plugin.sh + openssl dgst -sha256 -r release_artifacts/install-plugin.sh > release_artifacts/install-plugin.sh.sha256 # Build aarch64 - cargo install cross --git https://github.com/cross-rs/cross + cargo install cross@0.2.5 + cargo clean cross build --target aarch64-unknown-linux-gnu --release - gzip -c target/aarch64-unknown-linux-gnu/release/pact-protobuf-plugin > target/artifacts/pact-protobuf-plugin-linux-aarch64.gz - openssl dgst -sha256 -r target/artifacts/pact-protobuf-plugin-linux-aarch64.gz > target/artifacts/pact-protobuf-plugin-linux-aarch64.gz.sha256 + gzip -c target/aarch64-unknown-linux-gnu/release/pact-protobuf-plugin > release_artifacts/pact-protobuf-plugin-linux-aarch64.gz + openssl dgst -sha256 -r release_artifacts/pact-protobuf-plugin-linux-aarch64.gz > release_artifacts/pact-protobuf-plugin-linux-aarch64.gz.sha256 + + cargo clean + cross build --release --target=x86_64-unknown-linux-musl + gzip -c target/x86_64-unknown-linux-musl/release/pact-protobuf-plugin > release_artifacts/pact-protobuf-plugin-linux-musl-x86_64.gz + openssl dgst -sha256 -r release_artifacts/pact-protobuf-plugin-linux-musl-x86_64.gz > release_artifacts/pact-protobuf-plugin-linux-musl-x86_64.gz.sha256 + + echo -- Build the musl aarch64 release artifacts -- + cargo clean + cross build --release --target=aarch64-unknown-linux-musl + gzip -c target/aarch64-unknown-linux-musl/release/pact-protobuf-plugin > release_artifacts/pact-protobuf-plugin-linux-musl-aarch64.gz + openssl dgst -sha256 -r release_artifacts/pact-protobuf-plugin-linux-musl-aarch64.gz > release_artifacts/pact-protobuf-plugin-linux-musl-aarch64.gz.sha256 + ;; Windows) echo "Building for Windows" cargo build --release - gzip -c target/release/pact-protobuf-plugin.exe > target/artifacts/pact-protobuf-plugin-windows-x86_64.exe.gz - openssl dgst -sha256 -r target/artifacts/pact-protobuf-plugin-windows-x86_64.exe.gz > target/artifacts/pact-protobuf-plugin-windows-x86_64.exe.gz.sha256 + gzip -c target/release/pact-protobuf-plugin.exe > release_artifacts/pact-protobuf-plugin-windows-x86_64.exe.gz + openssl dgst -sha256 -r release_artifacts/pact-protobuf-plugin-windows-x86_64.exe.gz > release_artifacts/pact-protobuf-plugin-windows-x86_64.exe.gz.sha256 ;; macOS) echo "Building for OSX" cargo build --release - gzip -c target/release/pact-protobuf-plugin > target/artifacts/pact-protobuf-plugin-osx-x86_64.gz - openssl dgst -sha256 -r target/artifacts/pact-protobuf-plugin-osx-x86_64.gz > target/artifacts/pact-protobuf-plugin-osx-x86_64.gz.sha256 + gzip -c target/release/pact-protobuf-plugin > release_artifacts/pact-protobuf-plugin-osx-x86_64.gz + openssl dgst -sha256 -r release_artifacts/pact-protobuf-plugin-osx-x86_64.gz > release_artifacts/pact-protobuf-plugin-osx-x86_64.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/pact-protobuf-plugin > target/artifacts/pact-protobuf-plugin-osx-aarch64.gz - openssl dgst -sha256 -r target/artifacts/pact-protobuf-plugin-osx-aarch64.gz > target/artifacts/pact-protobuf-plugin-osx-aarch64.gz.sha256 + gzip -c target/aarch64-apple-darwin/release/pact-protobuf-plugin > release_artifacts/pact-protobuf-plugin-osx-aarch64.gz + openssl dgst -sha256 -r release_artifacts/pact-protobuf-plugin-osx-aarch64.gz > release_artifacts/pact-protobuf-plugin-osx-aarch64.gz.sha256 ;; *) echo "$1 is not a recognised OS" exit 1 From 10156c163e45a21a445e7b88f6ec1a863d35a95d Mon Sep 17 00:00:00 2001 From: Yousaf Nabi Date: Thu, 8 Feb 2024 20:29:37 +0000 Subject: [PATCH 2/2] chore: align musl name path with pact ffi --- release.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/release.sh b/release.sh index 790024b..67b837d 100755 --- a/release.sh +++ b/release.sh @@ -32,14 +32,14 @@ case "$1" in cargo clean cross build --release --target=x86_64-unknown-linux-musl - gzip -c target/x86_64-unknown-linux-musl/release/pact-protobuf-plugin > release_artifacts/pact-protobuf-plugin-linux-musl-x86_64.gz - openssl dgst -sha256 -r release_artifacts/pact-protobuf-plugin-linux-musl-x86_64.gz > release_artifacts/pact-protobuf-plugin-linux-musl-x86_64.gz.sha256 + gzip -c target/x86_64-unknown-linux-musl/release/pact-protobuf-plugin > release_artifacts/pact-protobuf-plugin-linux-x86_64-musl.gz + openssl dgst -sha256 -r release_artifacts/pact-protobuf-plugin-linux-x86_64-musl.gz > release_artifacts/pact-protobuf-plugin-linux-x86_64-musl.gz.sha256 echo -- Build the musl aarch64 release artifacts -- cargo clean cross build --release --target=aarch64-unknown-linux-musl - gzip -c target/aarch64-unknown-linux-musl/release/pact-protobuf-plugin > release_artifacts/pact-protobuf-plugin-linux-musl-aarch64.gz - openssl dgst -sha256 -r release_artifacts/pact-protobuf-plugin-linux-musl-aarch64.gz > release_artifacts/pact-protobuf-plugin-linux-musl-aarch64.gz.sha256 + gzip -c target/aarch64-unknown-linux-musl/release/pact-protobuf-plugin > release_artifacts/pact-protobuf-plugin-linux-aarch64-musl.gz + openssl dgst -sha256 -r release_artifacts/pact-protobuf-plugin-linux-aarch64-musl.gz > release_artifacts/pact-protobuf-plugin-linux-aarch64-musl.gz.sha256 ;; Windows) echo "Building for Windows"