Publish #12
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: Publish | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| # Publish bashkit (core library) to crates.io | |
| publish-bashkit: | |
| name: Publish bashkit | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Verify version matches tag | |
| run: | | |
| # Get tag from release event or skip check for workflow_dispatch | |
| TAG_VERSION="${{ github.event.release.tag_name }}" | |
| if [ -n "$TAG_VERSION" ]; then | |
| TAG_VERSION="${TAG_VERSION#v}" # Remove 'v' prefix | |
| CARGO_VERSION=$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/') | |
| if [ "$TAG_VERSION" != "$CARGO_VERSION" ]; then | |
| echo "Error: Tag version ($TAG_VERSION) does not match Cargo.toml version ($CARGO_VERSION)" | |
| exit 1 | |
| fi | |
| echo "Version verified: $TAG_VERSION" | |
| else | |
| echo "Manual dispatch - skipping tag verification" | |
| fi | |
| - name: Publish bashkit to crates.io | |
| run: cargo publish -p bashkit | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
| # Publish bashkit-cli (depends on bashkit) | |
| publish-bashkit-cli: | |
| name: Publish bashkit-cli | |
| runs-on: ubuntu-latest | |
| needs: publish-bashkit | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Wait for crates.io index update | |
| run: sleep 30 | |
| - name: Publish bashkit-cli to crates.io | |
| run: cargo publish -p bashkit-cli | |
| env: | |
| CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} |