Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 34 additions & 4 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
name: CI
on: [pull_request]

permissions: {}

concurrency:
group: ci-${{ github.event.pull_request.number }}
cancel-in-progress: true

jobs:
build:
name: Build (${{ matrix.os }})
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
permissions:
contents: read

steps:
- uses: actions/checkout@0c366fd6a839edf440554fa01a7085ccba70ac98
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Mise install
uses: jdx/mise-action@641a2bcbed5ce4f7aa8ffed0a3af42b65cdf1094
uses: jdx/mise-action@d5574b52816a478f9d4e6529a3f6ff17a8a36785 # v5.2.8
with:
cache: true
experimental: true

- uses: Swatinem/rust-cache@f51f967e158417aafa338a1e46ab22095f07aa01
- uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3

- name: Run build
run: mise build
Expand All @@ -29,3 +39,23 @@ jobs:
- name: Run tests
run: mise test

zizmor:
name: Audit workflows (zizmor)
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Mise install
uses: jdx/mise-action@d5574b52816a478f9d4e6529a3f6ff17a8a36785 # v5.2.8
with:
install_args: zizmor

- name: Audit workflows
run: mise run zizmor
env:
GH_TOKEN: ${{ github.token }}
121 changes: 121 additions & 0 deletions .github/workflows/release-plz.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
name: Release

on:
push:
branches:
- main

permissions: {}

concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false

jobs:
release-plz-release:
name: Release
environment: release
if: github.repository_owner == 'heroesofcode'
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
outputs:
releases_created: ${{ steps.release-plz.outputs.releases_created }}
releases: ${{ steps.release-plz.outputs.releases }}

steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false

- name: Mise install
uses: jdx/mise-action@d5574b52816a478f9d4e6529a3f6ff17a8a36785 # v5.2.8
with:
install_args: rust

- name: Run release-plz
id: release-plz
uses: release-plz/action@66b324fd6c72d05d2a08568492ecdd62bfb8a62b # v0.5.148
with:
command: release
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}

release-plz-pr:
name: Release PR
environment: release
if: github.repository_owner == 'heroesofcode'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write

steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false

- name: Mise install
uses: jdx/mise-action@d5574b52816a478f9d4e6529a3f6ff17a8a36785 # v5.2.8
with:
install_args: rust

- name: Run release-plz
uses: release-plz/action@66b324fd6c72d05d2a08568492ecdd62bfb8a62b # v0.5.148
with:
command: release-pr
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}

homebrew:
name: Homebrew
environment: release
needs: release-plz-release
if: needs.release-plz-release.outputs.releases_created == 'true'
runs-on: macos-latest
permissions:
contents: write
env:
TAG: ${{ fromJSON(needs.release-plz-release.outputs.releases)[0].tag }}

steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ env.TAG }}
persist-credentials: false

- name: Mise install
uses: jdx/mise-action@d5574b52816a478f9d4e6529a3f6ff17a8a36785 # v5.2.8
with:
install_args: rust cargo:releasor

- name: Package with releasor
run: mise run package

- name: Upload to the GitHub release
run: gh release upload "$TAG" gitrat.tar.gz --clobber
env:
GH_TOKEN: ${{ github.token }}

- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: heroesofcode/homebrew-taps
path: homebrew-taps
persist-credentials: false

- name: Update formula
working-directory: homebrew-taps
env:
RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN }}
run: |
sha=$(shasum -a 256 ../gitrat.tar.gz | cut -d ' ' -f 1)
url="https://github.com/heroesofcode/gitrat/releases/download/$TAG/gitrat.tar.gz"
sed -i '' -E "s|^( *url ).*|\1\"$url\"|; s|^( *sha256 ).*|\1\"$sha\"|" gitrat.rb
git diff
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git commit -am "gitrat ${TAG#v}"
git push "https://x-access-token:${RELEASE_TOKEN}@github.com/heroesofcode/homebrew-taps.git" HEAD:main
11 changes: 10 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ cargo clippy --all-targets --all-features # or: mise lint
cargo fmt --all -- --check # or: mise fmt
cargo fmt --all # apply formatting
cargo build --release # or: mise release
mise run zizmor # audit .github/workflows (must report no findings)
mise run package # releasor -f gitrat β†’ gitrat.tar.gz (macOS)
mise lock --platform linux-x64,linux-arm64,macos-x64,macos-arm64,windows-x64 # after changing [tools]
```

## Code Style
Expand All @@ -24,7 +27,13 @@ Formatting is enforced via `.rustfmt.toml`:

## Toolchain

Rust 1.100 (edition 2024), pinned in `mise.toml` and `rust-version` in `Cargo.toml`. CI installs it via `mise`.
Rust 1.100 (edition 2024), pinned in `mise.toml` and `rust-version` in `Cargo.toml`. CI installs it via `mise`; tool versions are locked in `mise.lock`.

## CI and releases

- `CI.yml` (PRs): build/lint/test on Ubuntu, macOS and Windows, plus a `zizmor` job. Actions are pinned by commit SHA with a `# vX.Y.Z` comment, `persist-credentials: false`, `permissions: {}` at the top and commented per-job permissions.
- `release-plz.yml` (push to `main`): release-plz (`release-plz.toml`, changelog via `cliff.toml`) opens the release PR; merging it publishes to crates.io, tags `vX.Y.Z` and creates the GitHub release. The `homebrew` job then builds `gitrat.tar.gz` with releasor on macOS, uploads it to the release and updates `gitrat.rb` in `heroesofcode/homebrew-taps`.
- Never bump the version in `Cargo.toml` by hand; release-plz does it.

## Architecture

Expand Down
57 changes: 57 additions & 0 deletions mise.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions mise.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
[settings]
lockfile = true

[tools]
rust = { version = "1.100.0", components = "clippy,rustfmt" }
zizmor = "1.32.0"
# Packages the release binary (`mise run package`); only needed on macOS.
"cargo:releasor" = { version = "2.0.1", os = ["macos"] }

[tasks.lint]
run = "cargo clippy --all-targets --all-features"
Expand Down Expand Up @@ -28,3 +34,9 @@ run = "cargo fmt --all -- --check"
[tasks.changelog]
run = "git cliff -o CHANGELOG.md"


[tasks.zizmor]
run = "zizmor .github/workflows"

[tasks.package]
run = "releasor -f gitrat"
11 changes: 11 additions & 0 deletions release-plz.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[workspace]
# Changelog generated with git-cliff using the project's cliff.toml.
changelog_config = "cliff.toml"
changelog_update = true
# Tag `vX.Y.Z` and create the GitHub release; the release workflow then
# attaches the macOS binary built by releasor and updates the Homebrew tap.
git_tag_enable = true
git_tag_name = "v{{ version }}"
git_release_enable = true
git_release_name = "v{{ version }}"
publish = true
Loading