Fix windows build #24
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: Rust Build and Release | |
on: | |
push: | |
branches: ["master"] | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
build: | |
name: Build on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
include: | |
- os: ubuntu-latest | |
target: x86_64-unknown-linux-gnu | |
- os: windows-latest | |
target: x86_64-pc-windows-msvc | |
- os: macos-latest | |
target: x86_64-apple-darwin | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
target: ${{ matrix.target }} | |
override: true | |
- name: Build | |
uses: actions-rs/cargo@v1 | |
with: | |
command: build | |
args: --release --target ${{ matrix.target }} | |
- name: Set binary name | |
shell: bash | |
run: | | |
BINARY_NAME="merklemap-cli" | |
if [ "${{ matrix.os }}" = "windows-latest" ]; then | |
BINARY_NAME="${BINARY_NAME}.exe" | |
fi | |
echo "BINARY_NAME=${BINARY_NAME}" >> $GITHUB_ENV | |
- name: Package Binary | |
shell: bash | |
run: | | |
echo "Packaging binary from: target/${{ matrix.target }}/release/${BINARY_NAME}" | |
if [ -f "target/${{ matrix.target }}/release/${BINARY_NAME}" ]; then | |
echo "Binary file exists" | |
tar -czvf "${BINARY_NAME}-${{ matrix.target }}.tar.gz" -C "target/${{ matrix.target }}/release" "${BINARY_NAME}" | |
echo "Packaging complete" | |
else | |
echo "Error: Binary file not found" | |
exit 1 | |
fi | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.BINARY_NAME }}-${{ matrix.target }} | |
path: ${{ env.BINARY_NAME }}-${{ matrix.target }}.tar.gz |