Support cargo-generate #260
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
on: [push, pull_request, workflow_dispatch] | |
name: CI | |
env: | |
RUSTFLAGS: -D warnings | |
RUSTDOCFLAGS: -D warnings | |
jobs: | |
generate: | |
name: Generate from template | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: cargo-bins/cargo-binstall@main | |
- name: Install cargo-generate | |
run: cargo binstall -y cargo-generate | |
- name: Generate project | |
run: cargo generate --path . --name "eframe-template" | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: eframe-template | |
path: eframe-template | |
check: | |
name: Check | |
needs: generate | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: eframe-template | |
- uses: dtolnay/rust-toolchain@stable | |
- name: Check | |
run: cargo check | |
check_wasm: | |
name: Check wasm32 | |
needs: generate | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: eframe-template | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: wasm32-unknown-unknown | |
- name: Check | |
run: cargo check | |
test: | |
name: Test suite | |
needs: generate | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: eframe-template | |
- name: Install dependencies | |
run: sudo apt-get install libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev libssl-dev | |
- uses: dtolnay/rust-toolchain@stable | |
- name: Test | |
run: cargo test --lib | |
fmt: | |
name: Rustfmt | |
needs: generate | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: eframe-template | |
- uses: dtolnay/rust-toolchain@stable | |
- name: Format | |
run: cargo fmt --all -- --check | |
clippy: | |
name: Clippy | |
needs: generate | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: eframe-template | |
- uses: dtolnay/rust-toolchain@stable | |
- name: Clippy | |
run: cargo clippy -- -D warnings | |
trunk: | |
name: Trunk | |
needs: generate | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: eframe-template | |
- uses: cargo-bins/cargo-binstall@main | |
- name: Install trunk | |
run: cargo binstall -y trunk | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: wasm32-unknown-unknown | |
- name: Build | |
run: trunk build | |
build: | |
needs: generate | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- os: macos-latest | |
TARGET: aarch64-apple-darwin | |
- os: ubuntu-latest | |
TARGET: aarch64-unknown-linux-gnu | |
- os: ubuntu-latest | |
TARGET: armv7-unknown-linux-gnueabihf | |
- os: ubuntu-latest | |
TARGET: x86_64-unknown-linux-gnu | |
- os: windows-latest | |
TARGET: x86_64-pc-windows-msvc | |
EXTENSION: .exe | |
steps: | |
- name: Building ${{ matrix.TARGET }} | |
run: echo "${{ matrix.TARGET }}" | |
- name: Install build dependencies - Rustup | |
run: | | |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain stable --profile default --target ${{ matrix.TARGET }} -y | |
echo "$HOME/.cargo/bin" >> $GITHUB_PATH | |
# For linux, it's necessary to use cross from the git repository to avoid glibc problems | |
# Ref: https://github.com/cross-rs/cross/issues/1510 | |
- name: Install cross for linux | |
if: contains(matrix.TARGET, 'linux') | |
run: | | |
cargo install cross --git https://github.com/cross-rs/cross --rev 1b8cf50d20180c1a394099e608141480f934b7f7 | |
- name: Install cross for mac and windows | |
if: ${{ !contains(matrix.TARGET, 'linux') }} | |
run: | | |
cargo install cross | |
- uses: actions/download-artifact@v4 | |
with: | |
name: eframe-template | |
- name: Build | |
run: cross build --verbose --release --target=${{ matrix.TARGET }} | |
- name: Rename | |
run: cp target/${{ matrix.TARGET }}/release/eframe-template${{ matrix.EXTENSION }} eframe-template-${{ matrix.TARGET }}${{ matrix.EXTENSION }} | |
- uses: actions/upload-artifact@master | |
with: | |
name: eframe-template-${{ matrix.TARGET }}${{ matrix.EXTENSION }} | |
path: eframe-template-${{ matrix.TARGET }}${{ matrix.EXTENSION }} | |
- uses: svenstaro/upload-release-action@v2 | |
name: Upload binaries to release | |
if: ${{ github.event_name == 'push' }} | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: eframe-template-${{ matrix.TARGET }}${{ matrix.EXTENSION }} | |
asset_name: eframe-template-${{ matrix.TARGET }}${{ matrix.EXTENSION }} | |
tag: ${{ github.ref }} | |
prerelease: ${{ !startsWith(github.ref, 'refs/tags/') }} | |
overwrite: true |