Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: musl variants #47

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# will have compiled files and executables
target/
release_artifacts

# These are backup files generated by rustfmt
**/*.rs.bk
Expand Down
43 changes: 28 additions & 15 deletions release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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-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-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"
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
Expand Down
Loading