name: Cargo Build, Test & Release
on:
push:
branches:
- 'main'
pull_request:
branches:
- 'main'
env:
CARGO_TERM_COLOR: always
jobs:
build_and_test:
name: Rust project - latest
runs-on: ubuntu-latest
strategy:
matrix:
toolchain:
- stable
- beta
- nightly
steps:
- uses: actions/checkout@v3
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
- run: cargo build --verbose
- run: cargo test --verbose
publish:
name: Publish for ${{ matrix.os }}
needs: build_and_test
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
artifact_name: temp-converter
asset_name: temp-converter-linux
- os: windows-latest
artifact_name: temp-converter.exe
asset_name: temp-converter-windows.exe
- os: macos-latest
artifact_name: temp-converter
asset_name: temp-converter-macos
steps:
- uses: actions/checkout@v3
- name: Build
run: cargo build --release
- name: Get tag
id: get_tag
shell: bash
run: |
tag=$(echo -n v ; cargo pkgid | cut -d "@" -f2)
echo "tag=$tag" >> $GITHUB_OUTPUT
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: target/release/${{ matrix.artifact_name }}
asset_name: ${{ matrix.asset_name }}
tag: ${{ steps.get_tag.outputs.tag }}