name: Rust
on:
push:
branches: [ master ]
tags: [ 'v*' ]
pull_request:
branches: [ master ]
env:
CARGO_TERM_COLOR: always
jobs:
build-util:
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
use_cross: false
args: --features util,driver-pal/hal-cp2130,driver-pal/hal-linux
- target: armv7-unknown-linux-gnueabihf
os: ubuntu-20.04
use_cross: true
- target: aarch64-unknown-linux-gnu
os: ubuntu-20.04
use_cross: true
steps:
- uses: actions/checkout@v2
- uses: FranzDiebold/github-env-vars-action@v1.2.1
- name: Configure toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
target: ${{ matrix.target }}
override: true
- name: Configure caching
uses: actions/cache@v2
if: ${{ matrix.os != 'macos-latest' }}
with:
key: ${{ matrix.os }}-${{ matrix.target }}
path: |
${{ env.HOME }}/.cargo
target
- name: Install libusb (apt native)
if: ${{ matrix.os == 'ubuntu-latest' && matrix.target == 'x86_64-unknown-linux-gnu' }}
run: sudo apt install -y libusb-1.0-0 libusb-1.0-0-dev
- name: Install libusb (armv7)
if: ${{ matrix.target == 'armv7-unknown-linux-gnueabihf' }}
uses: ryankurte/action-apt@v0.3.0
with:
arch: armhf
packages: libusb-1.0-0-dev:armhf
- name: Install cross toolchain (armv7)
if: ${{ matrix.target == 'armv7-unknown-linux-gnueabihf' }}
run: sudo apt install gcc-arm-linux-gnueabihf
- name: Build release
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.use_cross }}
command: build
args: --target ${{ matrix.target }} --release ${{ matrix.args }}
- name: Copy / Rename utility
run: |
cp target/${{ matrix.target }}/release/scd30-util scd30-util-${{ matrix.target }}
tar -czvf scd30-util-${{ matrix.target }}.tgz scd30-util-${{ matrix.target }}
- name: Upload utility artifacts
uses: actions/upload-artifact@v1
with:
name: scd30-util-${{ matrix.target }}
path: scd30-util-${{ matrix.target }}
- name: Upload utility binary to release
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: scd30-util-${{ matrix.target }}.tgz
asset_name: scd30-util-${{ matrix.target }}.tgz
tag: ${{ github.ref }}
overwrite: true
release:
name: Create release
runs-on: ubuntu-latest
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
steps:
- name: Create Release
uses: actions/create-release@v1
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body: Release ${{ github.ref }}