Skip to content

Use rust to mock CLI apps in tests #153

Use rust to mock CLI apps in tests

Use rust to mock CLI apps in tests #153

Workflow file for this run

name: 📦 Cargo Publish
on:
push:
branches-ignore: [wip/**]
tags: ["**"]
pull_request:
jobs:
test:
name: 📦 Cargo ${{ startsWith(github.ref, 'refs/tags') && 'Publish' || 'Package' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Rust Cache
uses: Swatinem/rust-cache@v2
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with: { toolchain: stable }
- name: Package
run: cargo publish --dry-run
- name: Publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
v="v$(grep "^version" Cargo.toml | sed -r 's/version[^"]+"([^"]+).*/\1/')"
if [ "$v" != "$GITHUB_REF_NAME" ]; then
printf "Cargo.toml version %s does not match tag %s\n" "$v" "$GITHUB_REF_NAME" >&2
exit 1
fi
cargo publish
if: startsWith( github.ref, 'refs/tags/v' )