Release #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 | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "Crate version to publish (e.g., 0.2.0)" | |
| required: true | |
| type: string | |
| dry_run: | |
| description: "Run cargo publish --dry-run only" | |
| required: false | |
| default: false | |
| type: boolean | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| release: | |
| name: Publish | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: release | |
| permissions: | |
| contents: write | |
| id-token: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Configure Git | |
| run: | | |
| git config --global user.name "movable-ref release bot" | |
| git config --global user.email "actions@github.com" | |
| - name: Install Rust (stable) | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: cargo | |
| - name: Verify working tree is clean | |
| run: | | |
| if [ -n "$(git status --porcelain)" ]; then | |
| echo "Working tree is not clean" >&2 | |
| git status --short >&2 | |
| exit 1 | |
| fi | |
| - name: Validate version input | |
| run: | | |
| expected="${{ inputs.version }}" | |
| actual=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version') | |
| if [ "$expected" != "$actual" ]; then | |
| echo "Input version $expected does not match Cargo.toml version $actual" >&2 | |
| exit 1 | |
| fi | |
| - name: Tests | |
| run: | | |
| cargo test | |
| cargo clippy --all-targets -- -D warnings | |
| - name: Cargo publish (dry-run) | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
| run: cargo publish --dry-run | |
| - name: Cargo publish | |
| if: ${{ !inputs.dry_run }} | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
| run: cargo publish | |
| - name: Create tag | |
| if: ${{ !inputs.dry_run }} | |
| run: | | |
| git tag v${{ inputs.version }} | |
| git push origin v${{ inputs.version }} | |
| - name: Create GitHub release | |
| if: ${{ !inputs.dry_run }} | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: v${{ inputs.version }} | |
| name: v${{ inputs.version }} | |
| body_path: RELEASE_NOTES.md |