diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 31e6c5141..e38fb1144 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -32,6 +32,12 @@ jobs: with: toolchain: stable targets: aarch64-apple-darwin,x86_64-apple-darwin + - name: Set up QEMU + if: runner.os == 'Linux' + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + if: runner.os == 'Linux' + uses: docker/setup-buildx-action@v3 - if: startsWith(github.ref, 'refs/tags/pact_mock_server_cli') && runner.os == 'Linux' run: ./release-linux.sh working-directory: rust/pact_mock_server_cli diff --git a/rust/pact_ffi/release-linux.sh b/rust/pact_ffi/release-linux.sh index 002483c7a..97efa4f97 100755 --- a/rust/pact_ffi/release-linux.sh +++ b/rust/pact_ffi/release-linux.sh @@ -30,18 +30,42 @@ rustup run nightly cbindgen \ cp include/*.h ../release_artifacts echo -- Build the musl release artifacts -- -sudo apt install musl-tools -rustup target add x86_64-unknown-linux-musl -cargo build --release --target=x86_64-unknown-linux-musl +cargo install cross@0.2.5 +cross build --release --target=x86_64-unknown-linux-musl gzip -c ../target/x86_64-unknown-linux-musl/release/libpact_ffi.a > ../release_artifacts/libpact_ffi-linux-x86_64-musl.a.gz openssl dgst -sha256 -r ../release_artifacts/libpact_ffi-linux-x86_64-musl.a.gz > ../release_artifacts/libpact_ffi-linux-x86_64-musl.a.gz.sha256 -cargo install cross@0.2.5 +mkdir tmp +cp ../target/x86_64-unknown-linux-musl/release/libpact_ffi.a tmp/ +docker run --platform=linux/amd64 --rm -v $PWD/tmp:/scratch alpine /bin/sh -c 'apk add --no-cache musl-dev gcc && \ +cd /scratch && \ + ar -x libpact_ffi.a && \ + gcc -shared *.o -o libpact_ffi.so && \ + rm -f *.o' + +gzip -c tmp/libpact_ffi.so > ../release_artifacts/libpact_ffi-linux-x86_64-musl.so.gz +openssl dgst -sha256 -r ../release_artifacts/libpact_ffi-linux-x86_64-musl.so.gz > ../release_artifacts/libpact_ffi-linux-x86_64-musl.so.gz.sha256 +rm -rf tmp + + 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/libpact_ffi.a > ../release_artifacts/libpact_ffi-linux-aarch64-musl.a.gz openssl dgst -sha256 -r ../release_artifacts/libpact_ffi-linux-aarch64-musl.a.gz > ../release_artifacts/libpact_ffi-linux-aarch64-musl.a.gz.sha256 +mkdir tmp +cp ../target/aarch64-unknown-linux-musl/release/libpact_ffi.a tmp/ +docker run --platform=linux/arm64 --rm -v $PWD/tmp:/scratch alpine /bin/sh -c 'apk add --no-cache musl-dev gcc && \ +cd /scratch && \ + ar -x libpact_ffi.a && \ + gcc -shared *.o -o libpact_ffi.so && \ + rm -f *.o' + +gzip -c tmp/libpact_ffi.so > ../release_artifacts/libpact_ffi-linux-aarch64-musl.so.gz +openssl dgst -sha256 -r ../release_artifacts/libpact_ffi-linux-aarch64-musl.so.gz > ../release_artifacts/libpact_ffi-linux-aarch64-musl.so.gz.sha256 +rm -rf tmp + echo -- Build the aarch64 release artifacts -- cargo clean cross build --target aarch64-unknown-linux-gnu --release