Skip to content

Publish

Publish #27

Workflow file for this run

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: Strip git-only dependencies for publishing
# monty is a git dep (not yet on crates.io) — remove before publish
run: |
TOML=crates/bashkit/Cargo.toml
# Remove monty dependency line
sed -i '/^monty = .*/d' "$TOML"
# Remove python feature that references monty
sed -i '/^python = \["dep:monty"\]/d' "$TOML"
# Remove python_scripts example block (requires python feature)
sed -i '/^\[\[example\]\]/{N;N;/python_scripts/d}' "$TOML"
echo "--- Cargo.toml after stripping ---"
cat "$TOML"
- name: Publish bashkit to crates.io
run: cargo publish -p bashkit --allow-dirty 2>&1 || echo "::warning::bashkit publish failed (may already exist)"
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: Strip python feature from bashkit-cli
# python feature is stripped from bashkit during publish (monty is git-only)
run: |
TOML=crates/bashkit-cli/Cargo.toml
# Remove python feature and default that references it
sed -i '/^python = \["bashkit\/python"\]/d' "$TOML"
sed -i 's/default = \["python"\]/default = []/' "$TOML"
echo "--- bashkit-cli Cargo.toml after stripping ---"
cat "$TOML"
- name: Publish bashkit-cli to crates.io
run: cargo publish -p bashkit-cli --allow-dirty
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}