Skip to content

Commit

Permalink
Publish to crates.io (#75)
Browse files Browse the repository at this point in the history
* Publish to crates.io

* Publish to crates.io

* Add binstall
  • Loading branch information
j178 authored Nov 18, 2024
1 parent 29e91e8 commit 04cb26c
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Publish a release to PyPI.
# Publish a release to PyPI and crates.io.
#
# Assumed to run as a subworkflow of .github/workflows/release.yml; specifically, as a publish job
# within `cargo-dist`.
name: "Publish to PyPI"
name: "Publish"

on:
workflow_call:
Expand Down Expand Up @@ -30,3 +30,19 @@ jobs:
merge-multiple: true
- name: Publish to PyPi
run: uv publish -v wheels/*

crates-publish:
name: Publish to crates.io
runs-on: ubuntu-latest
environment:
name: release
steps:
- uses: actions/checkout@v4
- uses: rui314/setup-mold@v1
- uses: Swatinem/rust-cache@v2
- name: "Install Rust toolchain"
run: rustup show
- name: "Publish to crates.io"
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,12 +234,12 @@ jobs:
done
git push
custom-publish-pypi:
custom-publish:
needs:
- plan
- host
if: ${{ !fromJson(needs.plan.outputs.val).announcement_is_prerelease || fromJson(needs.plan.outputs.val).publish_prereleases }}
uses: ./.github/workflows/publish-pypi.yml
uses: ./.github/workflows/publish.yml
with:
plan: ${{ needs.plan.outputs.val }}
secrets: inherit
Expand All @@ -254,11 +254,11 @@ jobs:
- plan
- host
- publish-homebrew-formula
- custom-publish-pypi
- custom-publish
# use "always() && ..." to allow us to wait for all publish jobs while
# still allowing individual publish jobs to skip themselves (for prereleases).
# "host" however must run to completion, no skipping allowed!
if: ${{ always() && needs.host.result == 'success' && (needs.publish-homebrew-formula.result == 'skipped' || needs.publish-homebrew-formula.result == 'success') && (needs.custom-publish-pypi.result == 'skipped' || needs.custom-publish-pypi.result == 'success') }}
if: ${{ always() && needs.host.result == 'success' && (needs.publish-homebrew-formula.result == 'skipped' || needs.publish-homebrew-formula.result == 'success') && (needs.custom-publish.result == 'skipped' || needs.custom-publish.result == 'success') }}
runs-on: "ubuntu-20.04"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description = "pre-commit implemeneted in Rust"
repository = "https://github.com/j178/pre-commit-rs"
homepage = "https://github.com/j178/pre-commit-rs"
edition = "2021"
publish = false
license-file = "LICENSE"

[dependencies]
anstream = "0.6.15"
Expand Down Expand Up @@ -117,7 +117,7 @@ targets = ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-
# Local artifacts jobs to run in CI
local-artifacts-jobs = ["./build-binaries"]
# Publish jobs to run in CI
publish-jobs = ["./publish-pypi", "homebrew"]
publish-jobs = ["./publish", "homebrew"]
# A GitHub repo to push Homebrew formulas to
tap = "j178/homebrew-tap"
# Customize the Homebrew formula name
Expand Down
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,16 @@ brew install j178/tap/pre-commit-rs

### Cargo

Build from source using Cargo:

```console
cargo install --locked pre-commit-rs
```

Install from the binary directly using `cargo binstall`:

```console
cargo install --locked --git https://github.com/j178/pre-commit-rs
cargo binstall pre-commit-rs
```

### GitHub Releases
Expand All @@ -51,6 +59,9 @@ cargo install --locked --git https://github.com/j178/pre-commit-rs

## Usage

> [!NOTE]
> The binary executable is named `pre-commit` (or `pre-commit.exe` on Windows) - without the `-rs` suffix. It should be available in your `PATH` after installation.
This tool is designed to be a drop-in replacement for the original pre-commit tool, so you can use it with your existing configurations and hooks.

Please refer to the [official documentation](https://pre-commit.com/) for more information on how to configure and use pre-commit.
Expand Down

0 comments on commit 04cb26c

Please sign in to comment.