name: Rust
on:
push:
branches: [ master ]
jobs:
build:
strategy:
matrix:
target:
- x86_64-unknown-linux-gnu
- x86_64-apple-darwin
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-apple-darwin
os: macos-latest
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Cache cargo registry
uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v1
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo build
uses: actions/cache@v1
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
- name: Setup toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Cross build (Linux)
if: runner.os == 'Linux'
env:
PKG_CONFIG_ALLOW_CROSS: 1
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target=x86_64-unknown-linux-gnu
- name: Compress (Linux)
if: runner.os == 'Linux'
run: zip --junk-paths sqstransfer-x86_64-unknown-linux-gnu target/x86_64-unknown-linux-gnu/release/sqstransfer
- name: Upload (Linux)
if: runner.os == 'Linux'
uses: actions/upload-artifact@v1
with:
name: build-${{ matrix.target }}
path: sqstransfer-${{ matrix.target }}.zip
- name: Cross build (Windows)
if: runner.os == 'Linux'
env:
PKG_CONFIG_ALLOW_CROSS: 1
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target=x86_64-pc-windows-gnu
use-cross: true
- name: Compress (Windows)
if: runner.os == 'Linux'
run: zip --junk-paths sqstransfer-x86_64-pc-windows-gnu target/x86_64-pc-windows-gnu/release/sqstransfer.exe
- name: Upload (Windows)
if: runner.os == 'Linux'
uses: actions/upload-artifact@v1
with:
name: build-x86_64-pc-windows-gnu
path: sqstransfer-x86_64-pc-windows-gnu.zip
- name: Cross build (MacOS)
if: runner.os == 'macOS'
env:
PKG_CONFIG_ALLOW_CROSS: 1
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target=x86_64-apple-darwin
use-cross: true
- name: Compress (MacOS)
if: runner.os == 'macOS'
run: zip --junk-paths sqstransfer-x86_64-apple-darwin target/x86_64-apple-darwin/release/sqstransfer
- name: Upload (MacOS)
if: runner.os == 'macOS'
uses: actions/upload-artifact@v1
with:
name: build-x86_64-apple-darwin
path: sqstransfer-x86_64-apple-darwin.zip