diff --git a/.github/workflows/doc-assert.yml b/.github/workflows/doc-assert.yml index 0e41d38..39a5083 100644 --- a/.github/workflows/doc-assert.yml +++ b/.github/workflows/doc-assert.yml @@ -27,7 +27,7 @@ jobs: name: lint, build & test runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Format run: cargo fmt --all -- --check - name: Lint diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ada6162 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,67 @@ +# Copyright 2024 The DocAssert Authors +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Publishes the crate to crates.io when a version tag (e.g. v0.1.2) is pushed. +# Authentication uses crates.io Trusted Publishing (OIDC), so no long-lived +# API token is stored in the repository. + +name: Release + +on: + push: + tags: [ "v*" ] + +env: + CARGO_TERM_COLOR: always + +jobs: + publish: + name: publish to crates.io + runs-on: ubuntu-latest + environment: release + permissions: + id-token: write + contents: read + steps: + - uses: actions/checkout@v4 + - name: Check tag matches Cargo.toml version + run: | + version=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[] | select(.name == "doc-assert") | .version') + if [ "v$version" != "$GITHUB_REF_NAME" ]; then + echo "Tag $GITHUB_REF_NAME does not match Cargo.toml version v$version" + exit 1 + fi + - name: Format + run: cargo fmt --all -- --check + - name: Lint + run: cargo clippy -- -D warnings + - name: Build + run: cargo build --verbose --features="binary" + - name: Run tests + run: cargo test --verbose --workspace + - name: Start sample-api backend + working-directory: ./tests/functional + run: make backend-start + - name: Wait for sample-api backend + working-directory: ./tests/functional + run: make backend-wait + - name: Run sanity functional tests + working-directory: ./tests/functional + run: make sanity + - name: Authenticate with crates.io + uses: rust-lang/crates-io-auth-action@v1 + id: auth + - name: Publish + run: cargo publish + env: + CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}