diff --git a/.github/workflows/bump-version.yml b/.github/workflows/bump-version.yml index 50378dd..8888761 100644 --- a/.github/workflows/bump-version.yml +++ b/.github/workflows/bump-version.yml @@ -28,6 +28,12 @@ jobs: - name: Refresh tags run: git fetch --force --tags origin + - name: Set up Rust + uses: dtolnay/rust-toolchain@stable + + - name: Cache cargo artifacts + uses: Swatinem/rust-cache@v2 + - name: Configure git author run: | git config user.name "github-actions[bot]" @@ -240,6 +246,25 @@ jobs: git commit -m "chore: bump version to ${RELEASE_VERSION} (${BUMP_LEVEL}) [skip release]" git push origin "HEAD:main" + - name: Publish crate to crates.io + env: + RELEASE_VERSION: ${{ steps.version.outputs.release_version }} + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + run: | + set -euo pipefail + + if curl -fsSL "https://crates.io/api/v1/crates/deff/${RELEASE_VERSION}" >/dev/null 2>&1; then + echo "deff ${RELEASE_VERSION} is already published on crates.io" + exit 0 + fi + + if [ -z "${CARGO_REGISTRY_TOKEN}" ]; then + echo "CARGO_REGISTRY_TOKEN secret is not set" + exit 1 + fi + + cargo publish --locked --token "${CARGO_REGISTRY_TOKEN}" + - name: Create and push release tag env: RELEASE_TAG: ${{ steps.version.outputs.release_tag }} diff --git a/README.md b/README.md index 4db3aec..02b4984 100644 --- a/README.md +++ b/README.md @@ -6,13 +6,21 @@ My name is deff ## Quickstart -Run the installer script from this repository: +Choose one install method: + +1. Install from crates.io with Cargo: + +```bash +cargo install deff +``` + +2. Run the installer script from this repository: ```bash curl -fsSL https://raw.githubusercontent.com/flamestro/deff/main/install.sh | bash ``` -Installer source: https://github.com/flamestro/deff/blob/main/install.sh +Installer script source: https://github.com/flamestro/deff/blob/main/install.sh The script checks for `cargo`, clones this project into a temporary directory, installs it, and removes the temporary checkout. Bundled syntax grammars are compiled into the binary, so removing the checkout does not affect highlighting. @@ -126,8 +134,9 @@ Search and reviewed workflow: This repo ships with `.github/workflows/bump-version.yml`. -- Trigger: publish a GitHub release with a tag like `v0.1.0` -- Updates `Cargo.toml`/`Cargo.lock` on the default branch using commit prefixes (`feat:` -> next minor, `chore:`/`docs:` -> next patch) +- Trigger: push to `main` (excluding commits authored by `github-actions[bot]`) +- Computes the next version from commit prefixes (`feat:` -> next minor, `fix:`/`chore:`/`docs:` -> next patch) and updates `Cargo.toml`/`Cargo.lock` when needed +- Publishes new crate versions to crates.io and then creates/pushes the matching `vX.Y.Z` tag and GitHub release ## Contributing