Release Crates #1
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 Crates | |
| on: | |
| push: | |
| tags: | |
| - "v*.*.*" | |
| workflow_dispatch: | |
| inputs: | |
| dry-run: | |
| description: "Perform a dry run without actually publishing" | |
| required: false | |
| type: boolean | |
| default: false | |
| jobs: | |
| publish-crates: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| toolchain: stable | |
| - name: Rust cache | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| cache-on-failure: true | |
| - name: Run tests | |
| run: cargo test --all --locked | |
| - name: Verify package can be built | |
| run: cargo package --locked --allow-dirty | |
| - name: Publish to crates.io (dry-run) | |
| if: github.event_name == 'workflow_dispatch' && inputs.dry-run | |
| run: cargo publish --dry-run --locked | |
| - name: Publish to crates.io | |
| if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && !inputs.dry-run) | |
| uses: katyo/publish-crates@v2 | |
| with: | |
| registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
| ignore-unpublished-changes: true | |
| - name: Create GitHub Release | |
| if: github.event_name == 'push' | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| generate_release_notes: true | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |