attempted to fix binary creation in CI for cli #36
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: Release Rust CLI | |
on: | |
push: | |
jobs: | |
build-and-release: | |
strategy: | |
matrix: | |
include: | |
- platform: windows | |
rust_target: x86_64-pc-windows-gnu | |
archive: zip | |
runs-on: ubuntu-latest | |
- platform: linux-tar-gz | |
rust_target: x86_64-unknown-linux-musl | |
archive: tar.gz | |
runs-on: ubuntu-latest | |
- platform: linux-tar-xz | |
rust_target: x86_64-unknown-linux-musl | |
archive: tar.xz | |
runs-on: ubuntu-latest | |
- platform: linux-tar-zst | |
rust_target: x86_64-unknown-linux-musl | |
archive: tar.zst | |
runs-on: ubuntu-latest | |
- platform: macos | |
rust_target: x86_64-apple-darwin | |
archive: zip | |
runs-on: macos-latest | |
runs-on: ${{ matrix.runs-on }} | |
steps: | |
# Checkout the repository | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
# Install Rust | |
- name: Install Rust | |
run: | | |
rustup install stable | |
rustup target add ${{ matrix.rust_target }} | |
# Build CLI tool | |
- name: Build CLI tool | |
run: | | |
if [[ "${{ matrix.runs-on }}" == "macos-latest" ]]; then | |
cd cli && cargo build --release --target=${{ matrix.rust_target }} | |
else | |
cargo install cross | |
cd cli && cross build --release --target=${{ matrix.rust_target }} | |
fi | |
mkdir -p dist/${{ matrix.platform }} | |
# Package the binary | |
- name: Package Binary | |
run: | | |
BINARY=target/${{ matrix.rust_target }}/release/rocraters | |
ARCHIVE=dist/${{ matrix.platform }}/rocraters-${{ matrix.rust_target }}.${{ matrix.archive }} | |
if [[ "${{ matrix.archive }}" == "zip" ]]; then | |
zip -j $ARCHIVE $BINARY | |
elif [[ "${{ matrix.archive }}" == "tar.gz" ]]; then | |
tar -czvf $ARCHIVE -C target/${{ matrix.rust_target }}/release rocraters | |
elif [[ "${{ matrix.archive }}" == "tar.xz" ]]; then | |
tar -cJvf $ARCHIVE -C target/${{ matrix.rust_target }}/release rocraters | |
elif [[ "${{ matrix.archive }}" == "tar.zst" ]]; then | |
tar --zstd -cvf $ARCHIVE -C target/${{ matrix.rust_target }}/release rocraters | |
fi | |
# Upload artifacts | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: rocraters-${{ matrix.platform }}-${{ matrix.archive }} | |
path: rocraters/dist/${{ matrix.platform }}/* |