Merge pull request #7 from code0-tech/#6-support-html #13
This file contains hidden or 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: | |
| branches: | |
| - main | |
| tags: | |
| - "v*" | |
| pull_request: | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| env: | |
| CARGO_TERM_COLOR: always | |
| RUST_BACKTRACE: "1" | |
| jobs: | |
| check: | |
| name: Build and test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v6 | |
| with: | |
| persist-credentials: false | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: clippy, rustfmt | |
| - name: Cache Cargo | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Check formatting | |
| run: cargo fmt --all -- --check | |
| - name: Build workspace | |
| run: cargo build --workspace --locked | |
| - name: Test workspace | |
| run: cargo test --workspace --locked | |
| - name: Lint workspace | |
| run: cargo clippy --workspace --all-targets --locked -- -D warnings | |
| publish: | |
| name: Publish lupus | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| needs: check | |
| runs-on: ubuntu-latest | |
| environment: crates-io | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v6 | |
| with: | |
| persist-credentials: false | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Set crate version from tag | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| tag_version="${GITHUB_REF_NAME#v}" | |
| if [[ ! "$tag_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+([+-][0-9A-Za-z.-]+)?$ ]]; then | |
| echo "Tag $GITHUB_REF_NAME is not a valid crate version" >&2 | |
| exit 1 | |
| fi | |
| sed -i \ | |
| "s/^version = \".*\"$/version = \"$tag_version\"/" \ | |
| Cargo.toml | |
| # Refresh workspace package versions recorded in Cargo.lock without | |
| # changing locked dependency versions. | |
| cargo update -p lupus --precise "$tag_version" | |
| crate_version="$(cargo metadata --no-deps --format-version 1 | | |
| jq -r '.packages[] | select(.name == "lupus") | .version')" | |
| if [[ "$tag_version" != "$crate_version" ]]; then | |
| echo "Tag $GITHUB_REF_NAME does not match lupus version $crate_version" >&2 | |
| exit 1 | |
| fi | |
| - name: Publish to crates.io | |
| run: cargo publish -p lupus --locked --allow-dirty | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} |