test: cx pipeline #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Upload Binary for Windows | |
on: | |
push: | |
branches: | |
- '**' | |
pull_request: | |
types: [closed] | |
jobs: | |
release: | |
name: Release - ${{ matrix.platform.os_name }} | |
strategy: | |
matrix: | |
platform: | |
- os_name: FreeBSD-x86_64 | |
os: ubuntu-20.04 | |
target: x86_64-unknown-freebsd | |
bin: calimero-node | |
name: calimero-node-FreeBSD-x86_64.tar.gz | |
cross: true | |
cargo_command: ./cross | |
- os_name: Linux-x86_64 | |
os: ubuntu-20.04 | |
target: x86_64-unknown-linux-musl | |
bin: calimero-node | |
name: calimero-node-Linux-x86_64-musl.tar.gz | |
cross: false | |
cargo_command: cargo | |
- os_name: Windows-aarch64 | |
os: windows-latest | |
target: aarch64-pc-windows-msvc | |
bin: calimero-node.exe | |
name: calimero-node-Windows-aarch64.zip | |
cross: false | |
cargo_command: cargo | |
- os_name: Windows-x86_64 | |
os: windows-latest | |
target: x86_64-pc-windows-msvc | |
bin: calimero-node.exe | |
name: calimero-node-Windows-x86_64.zip | |
cross: false | |
cargo_command: cargo | |
- os_name: macOS-x86_64 | |
os: macOS-latest | |
target: x86_64-apple-darwin | |
bin: calimero-node | |
name: calimero-node-Darwin-x86_64.tar.gz | |
cross: false | |
cargo_command: cargo | |
- os_name: macOS-x86_64 | |
os: macOS-latest | |
target: aarch64-apple-darwin | |
bin: calimero-node | |
name: calimero-node-Darwin-aarch64.tar.gz | |
cross: false | |
cargo_command: cargo | |
runs-on: ${{ matrix.platform.os }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install toolchain if not cross-compiling | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: ${{ matrix.platform.target }} | |
if: ${{ !matrix.platform.cross }} | |
- name: Install musl-tools on Linux | |
run: sudo apt-get update --yes && sudo apt-get install --yes musl-tools | |
if: contains(matrix.platform.os, 'ubuntu') && !matrix.platform.cross | |
- name: Install cross if cross-compiling (*nix) | |
id: cross-nix | |
shell: bash | |
run: | | |
set -e | |
export TARGET="$HOME/bin" | |
mkdir -p "$TARGET" | |
./bootstrap/bootstrap-ubi.sh | |
"$HOME/bin/ubi" --project cross-rs/cross --matching musl --in . | |
if: matrix.platform.cross && !contains(matrix.platform.os, 'windows') | |
- name: Install cross if cross-compiling (Windows) | |
id: cross-windows | |
shell: powershell | |
run: | | |
.\bootstrap\bootstrap-ubi.ps1 | |
.\ubi --project cross-rs/cross --in . | |
if: matrix.platform.cross && contains(matrix.platform.os, 'windows') | |
- name: Build binary (*nix) | |
shell: bash | |
run: | | |
${{ matrix.platform.cargo_command }} build -p calimero-node --locked --release --target ${{ matrix.platform.target }} | |
if: ${{ !contains(matrix.platform.os, 'windows') }} | |
- name: Build binary (Windows) | |
shell: powershell | |
run: | | |
& ${{ matrix.platform.cargo_command }} build -p calimero-node --locked --release --target ${{ matrix.platform.target }} | |
if: contains(matrix.platform.os, 'windows') | |
- name: Strip binary | |
shell: bash | |
run: | | |
strip target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }} | |
if: ${{ !(matrix.platform.cross || matrix.platform.target == 'aarch64-pc-windows-msvc') }} | |
- name: Package as archive | |
shell: bash | |
run: | | |
cd target/${{ matrix.platform.target }}/release | |
if [[ "${{ matrix.platform.os }}" == "windows-latest" ]]; then | |
7z a ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }} | |
else | |
tar czvf ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }} | |
fi | |
cd - | |
- name: Publish release artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: calimero-node-${{ matrix.platform.os_name }} | |
path: "calimero-node*" |