Skip to content

Commit

Permalink
Merge pull request #4 from YOU54F/feat/musl
Browse files Browse the repository at this point in the history
feat: build for musl
  • Loading branch information
YOU54F authored Feb 8, 2024
2 parents 101270e + 6f47bf5 commit d3d5a22
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 26 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: plugins/csv/target/artifacts/*
file: plugins/csv/release_artifacts/*
file_glob: true
tag: ${{ github.ref }}
- if: startsWith(github.ref, 'refs/tags/pact-plugin-cli')
Expand All @@ -49,6 +49,6 @@ jobs:
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: cli/target/artifacts/*
file: cli/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
Expand Up @@ -11,6 +11,7 @@ build
target
pacts
*.out
release_artifacts

# Misc

Expand Down
38 changes: 26 additions & 12 deletions cli/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,51 @@ fi
echo Building Release for "$1"

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-plugin-cli > target/artifacts/pact-plugin-cli-linux-x86_64.gz
openssl dgst -sha256 -r target/artifacts/pact-plugin-cli-linux-x86_64.gz > target/artifacts/pact-plugin-cli-linux-x86_64.gz.sha256
gzip -c target/release/pact-plugin-cli > release_artifacts/pact-plugin-cli-linux-x86_64.gz
openssl dgst -sha256 -r release_artifacts/pact-plugin-cli-linux-x86_64.gz > release_artifacts/pact-plugin-cli-linux-x86_64.gz.sha256

# Build aarch64
cargo install cross
cargo install [email protected]
cargo clean
cross build --target aarch64-unknown-linux-gnu --release
gzip -c target/aarch64-unknown-linux-gnu/release/pact-plugin-cli > target/artifacts/pact-plugin-cli-linux-aarch64.gz
openssl dgst -sha256 -r target/artifacts/pact-plugin-cli-linux-aarch64.gz > target/artifacts/pact-plugin-cli-linux-aarch64.gz.sha256
gzip -c target/aarch64-unknown-linux-gnu/release/pact-plugin-cli > release_artifacts/pact-plugin-cli-linux-aarch64.gz
openssl dgst -sha256 -r release_artifacts/pact-plugin-cli-linux-aarch64.gz > release_artifacts/pact-plugin-cli-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-plugin-cli > release_artifacts/pact-plugin-cli-linux-musl-x86_64.gz
openssl dgst -sha256 -r release_artifacts/pact-plugin-cli-linux-musl-x86_64.gz > release_artifacts/pact-plugin-cli-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-plugin-cli > release_artifacts/pact-plugin-cli-linux-aarch64-musl.gz
openssl dgst -sha256 -r release_artifacts/pact-plugin-cli-linux-musl-aarch64.gz > release_artifacts/pact-plugin-cli-linux-musl-aarch64.gz.sha256


;;
Windows) echo "Building for Windows"
cargo build --release
gzip -c target/release/pact-plugin-cli.exe > target/artifacts/pact-plugin-cli-windows-x86_64.exe.gz
openssl dgst -sha256 -r target/artifacts/pact-plugin-cli-windows-x86_64.exe.gz > target/artifacts/pact-plugin-cli-windows-x86_64.exe.gz.sha256
gzip -c target/release/pact-plugin-cli.exe > release_artifacts/pact-plugin-cli-windows-x86_64.exe.gz
openssl dgst -sha256 -r release_artifacts/pact-plugin-cli-windows-x86_64.exe.gz > release_artifacts/pact-plugin-cli-windows-x86_64.exe.gz.sha256
;;
macOS) echo "Building for OSX"
cargo build --release
gzip -c target/release/pact-plugin-cli > target/artifacts/pact-plugin-cli-osx-x86_64.gz
openssl dgst -sha256 -r target/artifacts/pact-plugin-cli-osx-x86_64.gz > target/artifacts/pact-plugin-cli-osx-x86_64.gz.sha256
gzip -c target/release/pact-plugin-cli > release_artifacts/pact-plugin-cli-osx-x86_64.gz
openssl dgst -sha256 -r release_artifacts/pact-plugin-cli-osx-x86_64.gz > release_artifacts/pact-plugin-cli-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-plugin-cli > target/artifacts/pact-plugin-cli-osx-aarch64.gz
openssl dgst -sha256 -r target/artifacts/pact-plugin-cli-osx-aarch64.gz > target/artifacts/pact-plugin-cli-osx-aarch64.gz.sha256
gzip -c target/aarch64-apple-darwin/release/pact-plugin-cli > release_artifacts/pact-plugin-cli-osx-aarch64.gz
openssl dgst -sha256 -r release_artifacts/pact-plugin-cli-osx-aarch64.gz > release_artifacts/pact-plugin-cli-osx-aarch64.gz.sha256
;;
*) echo "$1 is not a recognised OS"
exit 1
Expand Down
24 changes: 12 additions & 12 deletions plugins/csv/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,36 @@ fi
echo Building Release for "$1"

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-csv-plugin > target/artifacts/pact-csv-plugin-linux-x86_64.gz
openssl dgst -sha256 -r target/artifacts/pact-csv-plugin-linux-x86_64.gz > target/artifacts/pact-csv-plugin-linux-x86_64.gz.sha256
cp pact-plugin.json target/artifacts/
gzip -c target/release/pact-csv-plugin > release_artifacts/pact-csv-plugin-linux-x86_64.gz
openssl dgst -sha256 -r release_artifacts/pact-csv-plugin-linux-x86_64.gz > release_artifacts/pact-csv-plugin-linux-x86_64.gz.sha256
cp pact-plugin.json release_artifacts/
cargo install cross
cross build --target aarch64-unknown-linux-gnu --release
gzip -c target/aarch64-unknown-linux-gnu/release/pact-csv-plugin > target/artifacts/pact-csv-plugin-linux-aarch64.gz
openssl dgst -sha256 -r target/artifacts/pact-csv-plugin-linux-aarch64.gz > target/artifacts/pact-csv-plugin-linux-aarch64.gz.sha256
gzip -c target/aarch64-unknown-linux-gnu/release/pact-csv-plugin > release_artifacts/pact-csv-plugin-linux-aarch64.gz
openssl dgst -sha256 -r release_artifacts/pact-csv-plugin-linux-aarch64.gz > release_artifacts/pact-csv-plugin-linux-aarch64.gz.sha256
;;
Windows) echo "Building for Windows"
cargo build --release
gzip -c target/release/pact-csv-plugin.exe > target/artifacts/pact-csv-plugin-windows-x86_64.exe.gz
openssl dgst -sha256 -r target/artifacts/pact-csv-plugin-windows-x86_64.exe.gz > target/artifacts/pact-csv-plugin-windows-x86_64.exe.gz.sha256
gzip -c target/release/pact-csv-plugin.exe > release_artifacts/pact-csv-plugin-windows-x86_64.exe.gz
openssl dgst -sha256 -r release_artifacts/pact-csv-plugin-windows-x86_64.exe.gz > release_artifacts/pact-csv-plugin-windows-x86_64.exe.gz.sha256
;;
macOS) echo "Building for OSX"
cargo build --release
gzip -c target/release/pact-csv-plugin > target/artifacts/pact-csv-plugin-osx-x86_64.gz
openssl dgst -sha256 -r target/artifacts/pact-csv-plugin-osx-x86_64.gz > target/artifacts/pact-csv-plugin-osx-x86_64.gz.sha256
gzip -c target/release/pact-csv-plugin > release_artifacts/pact-csv-plugin-osx-x86_64.gz
openssl dgst -sha256 -r release_artifacts/pact-csv-plugin-osx-x86_64.gz > release_artifacts/pact-csv-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-csv-plugin > target/artifacts/pact-csv-plugin-osx-aarch64.gz
openssl dgst -sha256 -r target/artifacts/pact-csv-plugin-osx-aarch64.gz > target/artifacts/pact-csv-plugin-osx-aarch64.gz.sha256
gzip -c target/aarch64-apple-darwin/release/pact-csv-plugin > release_artifacts/pact-csv-plugin-osx-aarch64.gz
openssl dgst -sha256 -r release_artifacts/pact-csv-plugin-osx-aarch64.gz > release_artifacts/pact-csv-plugin-osx-aarch64.gz.sha256
;;
*) echo "$1 is not a recognised OS"
exit 1
Expand Down

0 comments on commit d3d5a22

Please sign in to comment.