Skip to content

Commit ee286d9

Browse files
unhappychoiceclaude
andcommitted
feat: add package distribution infrastructure
- Update Cargo.toml for crates.io publishing with homepage, documentation, and exclude - Add manual release workflow with major/minor/patch version bump support - Update README with Homebrew and Cargo installation methods - Create homebrew-tap repository with gittype formula - Set up automated crates.io publishing and Homebrew formula updates 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent a9a3430 commit ee286d9

File tree

3 files changed

+181
-7
lines changed

3 files changed

+181
-7
lines changed

.github/workflows/release.yml

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
name: Manual Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version_type:
7+
description: 'Version bump type'
8+
required: true
9+
default: 'patch'
10+
type: choice
11+
options:
12+
- major
13+
- minor
14+
- patch
15+
16+
env:
17+
CARGO_TERM_COLOR: always
18+
19+
jobs:
20+
release:
21+
name: Create Release
22+
runs-on: ubuntu-latest
23+
outputs:
24+
new_version: ${{ steps.version.outputs.new_version }}
25+
upload_url: ${{ steps.create_release.outputs.upload_url }}
26+
steps:
27+
- uses: actions/checkout@v4
28+
with:
29+
token: ${{ secrets.GITHUB_TOKEN }}
30+
fetch-depth: 0
31+
32+
- uses: dtolnay/rust-toolchain@stable
33+
- uses: Swatinem/rust-cache@v2
34+
35+
# Install cargo-edit for version bumping
36+
- name: Install cargo-edit
37+
run: cargo install cargo-edit
38+
39+
# Bump version in Cargo.toml
40+
- name: Bump version
41+
id: version
42+
run: |
43+
cargo set-version --bump ${{ github.event.inputs.version_type }}
44+
NEW_VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')
45+
echo "new_version=v$NEW_VERSION" >> $GITHUB_OUTPUT
46+
echo "New version: v$NEW_VERSION"
47+
48+
# Run tests before release
49+
- name: Run tests
50+
run: cargo test
51+
52+
# Commit version bump
53+
- name: Commit version bump
54+
run: |
55+
git config --local user.email "action@github.com"
56+
git config --local user.name "GitHub Action"
57+
git add Cargo.toml Cargo.lock
58+
git commit -m "chore: bump version to ${{ steps.version.outputs.new_version }}"
59+
git tag ${{ steps.version.outputs.new_version }}
60+
git push origin main
61+
git push origin ${{ steps.version.outputs.new_version }}
62+
63+
# Create GitHub Release
64+
- name: Create Release
65+
id: create_release
66+
uses: actions/create-release@v1
67+
env:
68+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69+
with:
70+
tag_name: ${{ steps.version.outputs.new_version }}
71+
release_name: Release ${{ steps.version.outputs.new_version }}
72+
draft: false
73+
prerelease: false
74+
75+
build-and-upload:
76+
name: Build and Upload
77+
needs: release
78+
strategy:
79+
matrix:
80+
include:
81+
- target: x86_64-unknown-linux-gnu
82+
os: ubuntu-latest
83+
- target: x86_64-pc-windows-msvc
84+
os: windows-latest
85+
- target: x86_64-apple-darwin
86+
os: macos-latest
87+
- target: aarch64-apple-darwin
88+
os: macos-latest
89+
runs-on: ${{ matrix.os }}
90+
steps:
91+
- uses: actions/checkout@v4
92+
with:
93+
ref: ${{ needs.release.outputs.new_version }}
94+
- uses: dtolnay/rust-toolchain@stable
95+
with:
96+
targets: ${{ matrix.target }}
97+
- uses: Swatinem/rust-cache@v2
98+
with:
99+
key: ${{ matrix.target }}
100+
- name: Build
101+
run: cargo build --release --target ${{ matrix.target }}
102+
- name: Create archive (Unix)
103+
if: matrix.os != 'windows-latest'
104+
run: |
105+
cd target/${{ matrix.target }}/release
106+
tar -czf ../../../gittype-${{ needs.release.outputs.new_version }}-${{ matrix.target }}.tar.gz gittype
107+
- name: Create archive (Windows)
108+
if: matrix.os == 'windows-latest'
109+
run: |
110+
cd target/${{ matrix.target }}/release
111+
Compress-Archive -Path gittype.exe -DestinationPath ../../../gittype-${{ needs.release.outputs.new_version }}-${{ matrix.target }}.zip
112+
- name: Upload Release Asset (Unix)
113+
if: matrix.os != 'windows-latest'
114+
uses: actions/upload-release-asset@v1
115+
env:
116+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
117+
with:
118+
upload_url: ${{ needs.release.outputs.upload_url }}
119+
asset_path: ./gittype-${{ needs.release.outputs.new_version }}-${{ matrix.target }}.tar.gz
120+
asset_name: gittype-${{ needs.release.outputs.new_version }}-${{ matrix.target }}.tar.gz
121+
asset_content_type: application/gzip
122+
- name: Upload Release Asset (Windows)
123+
if: matrix.os == 'windows-latest'
124+
uses: actions/upload-release-asset@v1
125+
env:
126+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
127+
with:
128+
upload_url: ${{ needs.release.outputs.upload_url }}
129+
asset_path: ./gittype-${{ needs.release.outputs.new_version }}-${{ matrix.target }}.zip
130+
asset_name: gittype-${{ needs.release.outputs.new_version }}-${{ matrix.target }}.zip
131+
asset_content_type: application/zip
132+
133+
publish-crates:
134+
name: Publish to crates.io
135+
runs-on: ubuntu-latest
136+
needs: [release, build-and-upload]
137+
steps:
138+
- uses: actions/checkout@v4
139+
with:
140+
ref: ${{ needs.release.outputs.new_version }}
141+
- uses: dtolnay/rust-toolchain@stable
142+
- uses: Swatinem/rust-cache@v2
143+
- name: Publish to crates.io
144+
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
145+
146+
update-homebrew:
147+
name: Update Homebrew Formula
148+
runs-on: ubuntu-latest
149+
needs: [release, build-and-upload]
150+
steps:
151+
- name: Update Homebrew formula
152+
uses: dawidd6/action-homebrew-bump-formula@v3
153+
with:
154+
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
155+
tap: unhappychoice/homebrew-tap
156+
formula: gittype
157+
tag: ${{ needs.release.outputs.new_version }}

Cargo.toml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,26 @@ authors = ["unhappychoice"]
66
description = "A typing practice tool using your own code repositories"
77
license = "MIT"
88
repository = "https://github.com/unhappychoice/gittype"
9+
homepage = "https://github.com/unhappychoice/gittype"
10+
documentation = "https://docs.rs/gittype"
911
keywords = ["typing", "practice", "cli", "git", "code"]
1012
categories = ["command-line-utilities", "games"]
1113
default-run = "gittype"
14+
exclude = [
15+
"*.png",
16+
"*.gif",
17+
"*.jpg",
18+
"*.jpeg",
19+
"docs/",
20+
"examples/",
21+
"tests/fixtures/",
22+
".github/",
23+
]
1224

1325
[[bin]]
1426
name = "gittype"
1527
path = "src/main.rs"
1628

17-
[[bin]]
18-
name = "generate_all_ascii_titles"
19-
path = "generate_all_ascii_titles.rs"
20-
2129
[dependencies]
2230
clap = { version = "4.0", features = ["derive"] }
2331
tree-sitter = "0.20"

README.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,21 @@
1414
- 🎯 **Actually useful**: Build muscle memory with *real* syntax patterns
1515
- 🔍 **Smart filtering**: Skip the `node_modules` nightmare automatically
1616

17-
## Quick Start 🚀
17+
## Installation 📦
18+
19+
### Homebrew (macOS/Linux)
20+
```bash
21+
brew install unhappychoice/tap/gittype
22+
```
1823

24+
### Cargo (Universal)
1925
```bash
20-
# Install (yes, it's that easy)
21-
brew install gittype
26+
cargo install gittype
27+
```
28+
29+
## Quick Start 🚀
2230

31+
```bash
2332
# cd into your messy codebase
2433
cd ~/that-project-you-never-finished
2534

0 commit comments

Comments
 (0)