ci: add rustfmt component to release workflow #10
Workflow file for this run
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: Release to crates.io | |
| on: | |
| push: | |
| tags: | |
| - "v[0-9]+.[0-9]+.[0-9]+" | |
| permissions: | |
| contents: write | |
| packages: write | |
| id-token: write # Required for OIDC trusted publishing | |
| env: | |
| CARGO_TERM_COLOR: always | |
| CARGO_INCREMENTAL: 0 | |
| CARGO_NET_RETRY: 10 | |
| RUST_BACKTRACE: short | |
| RUSTFLAGS: "-D warnings" | |
| RUSTUP_MAX_RETRIES: 10 | |
| jobs: | |
| # Extract and verify version (runs first, others depend on it) | |
| version-check: | |
| name: Version Check | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| outputs: | |
| version: ${{ steps.version.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Extract version from tag | |
| id: version | |
| run: | | |
| VERSION="${GITHUB_REF#refs/tags/v}" | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Releasing version: $VERSION" | |
| - name: Verify version matches Cargo.toml | |
| run: | | |
| CARGO_VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/') | |
| TAG_VERSION="${GITHUB_REF#refs/tags/v}" | |
| if [ "$CARGO_VERSION" != "$TAG_VERSION" ]; then | |
| echo "Version mismatch: tag=$TAG_VERSION, Cargo.toml=$CARGO_VERSION" | |
| exit 1 | |
| fi | |
| echo "Version verified: $CARGO_VERSION" | |
| # Parallel verification jobs - all run simultaneously after version check | |
| format-check: | |
| name: Format Check | |
| needs: version-check | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Install Rust nightly | |
| uses: dtolnay/rust-toolchain@nightly | |
| with: | |
| components: rustfmt | |
| - name: Check formatting | |
| run: cargo +nightly fmt --all -- --check | |
| clippy-check: | |
| name: Clippy Check | |
| needs: version-check | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Install Rust nightly | |
| uses: dtolnay/rust-toolchain@nightly | |
| with: | |
| components: llvm-tools-preview | |
| - name: Cache Cargo | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| shared-key: "release-clippy" | |
| save-if: false | |
| - name: Run clippy | |
| run: cargo clippy --workspace --all-features --all-targets -- -D warnings | |
| test-check: | |
| name: Test Suite | |
| needs: version-check | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Install Rust nightly | |
| uses: dtolnay/rust-toolchain@nightly | |
| with: | |
| components: llvm-tools-preview | |
| - name: Cache Cargo | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| shared-key: "release-tests" | |
| save-if: false | |
| - name: Install nextest | |
| uses: taiki-e/install-action@v2 | |
| with: | |
| tool: nextest | |
| - name: Run tests with nextest | |
| run: cargo nextest run --workspace --all-features --all-targets --no-fail-fast | |
| - name: Run doctests | |
| run: cargo test --workspace --doc --all-features | |
| # Publish to crates.io - depends on all verification jobs | |
| publish: | |
| name: Publish to crates.io | |
| needs: [version-check, format-check, clippy-check, test-check] | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| permissions: | |
| id-token: write # Required for OIDC token generation | |
| contents: read | |
| environment: | |
| name: crates-io | |
| url: https://crates.io/crates/pjson-rs | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Install Rust stable | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Cache Cargo | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| shared-key: "publish" | |
| save-if: false | |
| - name: Authenticate with crates.io via OIDC | |
| uses: rust-lang/crates-io-auth-action@v1 | |
| id: auth | |
| - name: Publish crates to crates.io | |
| uses: katyo/publish-crates@v2 | |
| with: | |
| registry-token: ${{ steps.auth.outputs.token }} | |
| ignore-unpublished-changes: true | |
| publish-delay: 10000 | |
| # Create GitHub release with native release notes generation | |
| github-release: | |
| name: Create GitHub Release | |
| needs: [version-check, publish] | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: ${{ github.ref_name }} | |
| name: Release v${{ needs.version-check.outputs.version }} | |
| draft: false | |
| prerelease: false | |
| generate_release_notes: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # Post-release notifications | |
| notify: | |
| name: Release Complete | |
| needs: [version-check, github-release] | |
| runs-on: ubuntu-latest | |
| if: success() | |
| steps: | |
| - name: Release notification | |
| run: | | |
| echo "Release ${{ needs.version-check.outputs.version }} has been successfully published!" | |
| echo "Repository: https://github.com/${{ github.repository }}" | |
| echo "Release: https://github.com/${{ github.repository }}/releases/tag/${{ github.ref_name }}" | |
| echo "crates.io: https://crates.io/crates/pjson-rs" |