add publish step #42
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: ci | |
on: [push, pull_request] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
CARGO_TERM_COLOR: always | |
CARGO_INCREMENTAL: 0 | |
RUST_TOOLCHAIN_VERSION: 1.76 | |
DPRINT_VERSION: 0.45.0 | |
DENY_VERSION: 0.14.15 | |
GRCOV_VERSION: 0.8.19 | |
SCCACHE_VERSION: 0.7.7 | |
SCCACHE_CACHE_KEY: v1 | |
# TODO ensure config scheme is up to date | |
# TODO https://github.com/obi1kenobi/cargo-semver-checks-action | |
# TODO semantic commits for changelog and version | |
# TODO if it's a tag build disable sccache | |
jobs: | |
lint: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup tools path | |
run: | | |
CARGO_INSTALL_ROOT=${{ runner.temp }}/cache | |
echo "CARGO_INSTALL_ROOT=${CARGO_INSTALL_ROOT}" >> "${GITHUB_ENV}" | |
echo "${CARGO_INSTALL_ROOT}/bin" >> "${GITHUB_PATH}" | |
shell: bash | |
- name: Cache tools | |
uses: actions/cache@v4 | |
id: cache-tools | |
with: | |
path: ${{ env.CARGO_INSTALL_ROOT }} | |
key: tools-dprint-${{ env.DPRINT_VERSION }}-deny-${{ env.DENY_VERSION }}-${{ hashFiles('dprint.json') }} | |
- name: Install tools | |
if: steps.cache-tools.outputs.cache-hit != 'true' | |
run: | | |
cargo install --locked 'dprint@${{ env.DPRINT_VERSION }}' | |
cargo install --locked 'cargo-deny@${{ env.DENY_VERSION }}' | |
- name: Check formatting | |
run: dprint check | |
- name: Check deny | |
run: cargo deny --all-features check bans licenses sources | |
- name: Check advisories | |
run: cargo deny --all-features check advisories | |
continue-on-error: true | |
main: | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- os: ubuntu-22.04 | |
target: x86_64-unknown-linux-gnu | |
component: clippy | |
- os: ubuntu-22.04 | |
target: x86_64-unknown-linux-musl | |
- os: macos-12 | |
target: x86_64-apple-darwin | |
- os: macos-14 | |
target: aarch64-apple-darwin | |
- os: windows-2022 | |
target: x86_64-pc-windows-msvc | |
rustflags: -C target-feature=+crt-static | |
runs-on: ${{ matrix.os }} | |
name: ${{ matrix.target }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install toolchain | |
run: | | |
# TODO make clippy optional | |
rustup toolchain install --profile minimal ${{ env.RUST_TOOLCHAIN_VERSION }} -t ${{ matrix.target }} --no-self-update -c llvm-tools-preview -c clippy | |
rustup default ${{ env.RUST_TOOLCHAIN_VERSION }} | |
- name: Setup tools path | |
run: | | |
CARGO_INSTALL_ROOT=${{ runner.temp }}/cache | |
echo "CARGO_INSTALL_ROOT=${CARGO_INSTALL_ROOT}" >> "${GITHUB_ENV}" | |
echo "${CARGO_INSTALL_ROOT}/bin" >> "${GITHUB_PATH}" | |
shell: bash | |
- name: Cache tools | |
uses: actions/cache@v4 | |
id: cache-tools | |
with: | |
path: ${{ env.CARGO_INSTALL_ROOT }} | |
key: tools-grcov-${{ env.GRCOV_VERSION }}-sccache-${{ env.SCCACHE_VERSION }}-${{ matrix.os }} | |
- name: Install tools | |
if: steps.cache-tools.outputs.cache-hit != 'true' | |
run: | | |
cargo install --locked 'grcov@${{ env.GRCOV_VERSION }}' | |
cargo install --locked 'sccache@${{ env.SCCACHE_VERSION }}' | |
- name: Configure sccache | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || ''); | |
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || ''); | |
- name: Start sccache server | |
run: sccache --start-server | |
env: | |
SCCACHE_GHA_VERSION: ${{ env.SCCACHE_CACHE_KEY }} | |
SCCACHE_IDLE_TIMEOUT: 0 | |
- name: Fetch | |
run: cargo fetch | |
- name: Build tests | |
run: cargo build --tests --target ${{ matrix.target }} | |
env: | |
RUSTFLAGS: -C instrument-coverage | |
RUSTC_WRAPPER: sccache | |
- run: sccache --show-stats && sccache -z | |
- name: Test | |
run: cargo test --target ${{ matrix.target }} | |
env: | |
RUSTFLAGS: -C instrument-coverage | |
- name: Run grcov | |
run: grcov . -s . --binary-path target/${{ matrix.target }}/debug --llvm --branch -t lcov -o lcov.info --keep-only "src/*" | |
- name: Publish code coverage | |
uses: coverallsapp/github-action@v2 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
flag-name: ${{ matrix.target }} | |
file: lcov.info | |
- name: Clippy | |
if: ${{ matrix.component == 'clippy' }} | |
run: cargo clippy --all-targets -- -D warnings | |
env: | |
RUSTC_WRAPPER: sccache | |
- run: sccache --show-stats && sccache -z | |
if: ${{ matrix.component == 'clippy' }} | |
- name: Build release | |
run: cargo build --release --target ${{ matrix.target }} | |
env: | |
RUSTFLAGS: ${{ matrix.rustflags }} | |
RUSTC_WRAPPER: sccache | |
- run: sccache --show-stats && sccache -z | |
- name: Upload | |
uses: actions/upload-artifact@v4 | |
with: | |
name: havocompare-${{ matrix.target }} | |
path: target/${{ matrix.target }}/release/havocompare${{ startsWith(matrix.os, 'windows') && '.exe' || '' }} | |
if-no-files-found: error | |
publish: | |
name: publish | |
runs-on: ubuntu-22.04 | |
needs: main | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
sparse-checkout: Cargo.toml | |
- name: Download | |
uses: actions/download-artifact@v4 | |
with: | |
path: artifacts | |
pattern: havocompare-* | |
- run: ls -larth | |
- run: ls -larth artifacts | |
- name: Create release | |
run: | | |
# TODO - check version: tag vs cargo toml | |
gh --version | |
# if: ${{ startsWith(github.ref, 'refs/tags/') }} |