Skip to content

Commit aed0d67

Browse files
committed
feat: Update release workflow and enhance package manager setup documentation
1 parent 87ac037 commit aed0d67

File tree

5 files changed

+204
-67
lines changed

5 files changed

+204
-67
lines changed

.github/workflows/release.yml

Lines changed: 14 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ on:
1111
required: true
1212
default: 'v0.1.0'
1313

14+
permissions:
15+
contents: write
16+
packages: write
17+
1418
jobs:
15-
release:
19+
goreleaser:
1620
runs-on: ubuntu-latest
17-
permissions:
18-
contents: write
19-
packages: write
2021

2122
steps:
2223
- name: Checkout
@@ -39,70 +40,20 @@ jobs:
3940
- name: Run linting
4041
run: task lint
4142

42-
- name: Build all platforms
43-
run: task build:all
44-
45-
- name: Package binaries
46-
run: task package
47-
48-
- name: Generate checksums
49-
run: |
50-
cd bin/releases
51-
sha256sum * > checksums.txt
52-
53-
- name: Create Release
54-
uses: softprops/action-gh-release@v1
55-
with:
56-
files: |
57-
bin/releases/codebase-interface-linux-amd64.tar.gz
58-
bin/releases/codebase-interface-darwin-amd64.tar.gz
59-
bin/releases/codebase-interface-darwin-arm64.tar.gz
60-
bin/releases/codebase-interface-windows-amd64.zip
61-
bin/releases/codebase-interface-linux-amd64
62-
bin/releases/codebase-interface-darwin-amd64
63-
bin/releases/codebase-interface-darwin-arm64
64-
bin/releases/codebase-interface-windows-amd64.exe
65-
bin/releases/checksums.txt
66-
generate_release_notes: true
67-
draft: false
68-
prerelease: false
69-
env:
70-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71-
72-
docker:
73-
runs-on: ubuntu-latest
74-
permissions:
75-
contents: read
76-
packages: write
77-
78-
steps:
79-
- name: Checkout
80-
uses: actions/checkout@v4
81-
82-
- name: Set up Docker Buildx
83-
uses: docker/setup-buildx-action@v3
84-
8543
- name: Log in to GitHub Container Registry
8644
uses: docker/login-action@v3
8745
with:
8846
registry: ghcr.io
8947
username: ${{ github.actor }}
9048
password: ${{ secrets.GITHUB_TOKEN }}
9149

92-
- name: Extract metadata
93-
id: meta
94-
uses: docker/metadata-action@v5
95-
with:
96-
images: ghcr.io/${{ github.repository }}
97-
tags: |
98-
type=ref,event=tag
99-
type=raw,value=latest,enable={{is_default_branch}}
100-
101-
- name: Build and push Docker image
102-
uses: docker/build-push-action@v5
50+
- name: Run GoReleaser
51+
uses: goreleaser/goreleaser-action@v5
10352
with:
104-
context: .
105-
platforms: linux/amd64,linux/arm64
106-
push: true
107-
tags: ${{ steps.meta.outputs.tags }}
108-
labels: ${{ steps.meta.outputs.labels }}
53+
distribution: goreleaser
54+
version: latest
55+
args: release --clean
56+
env:
57+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
59+
CHOCOLATEY_API_KEY: ${{ secrets.CHOCOLATEY_API_KEY }}

.goreleaser.yaml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@ archives:
5151
checksum:
5252
name_template: 'checksums.txt'
5353

54-
snapshot:
55-
name_template: "{{ incpatch .Version }}-next"
56-
5754
changelog:
5855
sort: asc
5956
use: github
@@ -83,6 +80,8 @@ brews:
8380
repository:
8481
owner: codebase-interface
8582
name: homebrew-cli
83+
branch: main
84+
token: "{{ .Env.HOMEBREW_TAP_GITHUB_TOKEN }}"
8685
commit_author:
8786
name: goreleaserbot
8887
@@ -94,6 +93,7 @@ brews:
9493
bin.install_symlink bin/"codebase-interface" => "cbi"
9594
test: |
9695
system "#{bin}/codebase-interface", "version"
96+
system "#{bin}/cbi", "version"
9797
9898
# Chocolatey package for Windows
9999
chocolateys:
@@ -106,14 +106,24 @@ chocolateys:
106106
license_url: https://github.com/codebase-interface/cli/blob/main/LICENSE
107107
require_license_acceptance: false
108108
project_source_url: https://github.com/codebase-interface/cli
109-
docs_url: https://github.com/codebase-interface/cli/blob/main/README.md
109+
docs_url: https://cli.codebaseinterface.org
110110
bug_tracker_url: https://github.com/codebase-interface/cli/issues
111111
tags: "cli development validation codebase"
112112
summary: A CLI tool for validating codebase structure and development standards
113113
description: |
114114
Codebase Interface CLI validates essential files and configurations for proper codebase setup.
115115
It checks for README.md, CONTRIBUTING.md, Git configuration files, and development standards.
116+
117+
Features:
118+
- Essential files validation (README, CONTRIBUTING, docs/)
119+
- Git configuration validation (.gitignore, .editorconfig, .gitattributes)
120+
- Development standards validation (conventional commits, branch naming)
121+
- JSON Schema-based configuration validation
122+
- Multiple output formats (table, JSON)
123+
- Configuration presets for quick setup
124+
- Cross-platform support (Windows, macOS, Linux)
116125
release_notes: "https://github.com/codebase-interface/cli/releases/tag/v{{ .Version }}"
126+
api_key: "{{ .Env.CHOCOLATEY_API_KEY }}"
117127

118128
# Docker images
119129
dockers:

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ Invoke-WebRequest -Uri "https://github.com/codebase-interface/cli/releases/lates
2929

3030
### 📦 Package Managers
3131

32+
> **Note**: Package manager distribution requires setup of Homebrew tap and Chocolatey API keys. See [Package Manager Setup Guide](docs/package-manager-setup.md) for maintainer instructions.
33+
3234
**Homebrew (macOS/Linux):**
3335
```bash
3436
brew tap codebase-interface/cli

docs/package-manager-setup.md

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
# Package Manager Setup Guide
2+
3+
This guide explains how to set up the automated package publishing for Homebrew and Chocolatey.
4+
5+
## 🍺 Homebrew Setup
6+
7+
### 1. Create Homebrew Tap Repository
8+
9+
First, you need to create a separate repository for the Homebrew tap:
10+
11+
```bash
12+
# Create a new repository named 'homebrew-cli'
13+
# This should be done through GitHub UI or API
14+
# Repository should be: codebase-interface/homebrew-cli
15+
```
16+
17+
The repository structure will look like:
18+
```
19+
homebrew-cli/
20+
└── Formula/
21+
└── codebase-interface.rb
22+
```
23+
24+
### 2. Set Up GitHub Token
25+
26+
Create a GitHub token with repository access:
27+
28+
1. Go to GitHub Settings → Developer settings → Personal access tokens
29+
2. Generate a new token (classic) with `repo` permissions
30+
3. Add it as a repository secret named `HOMEBREW_TAP_GITHUB_TOKEN`
31+
32+
### 3. How It Works
33+
34+
When you create a release:
35+
36+
1. **GoReleaser** automatically creates a Homebrew formula
37+
2. **Formula** gets pushed to `codebase-interface/homebrew-cli`
38+
3. **Users** can then install with:
39+
```bash
40+
brew tap codebase-interface/cli
41+
brew install codebase-interface
42+
```
43+
44+
The formula will be generated automatically and look like:
45+
```ruby
46+
class CodebaseInterface < Formula
47+
desc "A CLI tool for validating codebase structure and development standards"
48+
homepage "https://github.com/codebase-interface/cli"
49+
url "https://github.com/codebase-interface/cli/releases/download/v1.0.0/codebase-interface-Darwin-x86_64.tar.gz"
50+
sha256 "..."
51+
license "MIT"
52+
53+
def install
54+
bin.install "codebase-interface"
55+
bin.install_symlink bin/"codebase-interface" => "cbi"
56+
end
57+
58+
test do
59+
system "#{bin}/codebase-interface", "version"
60+
system "#{bin}/cbi", "version"
61+
end
62+
end
63+
```
64+
65+
## 🍫 Chocolatey Setup
66+
67+
### 1. Create Chocolatey Account
68+
69+
1. Create account at [chocolatey.org](https://chocolatey.org/)
70+
2. Get your API key from your account profile
71+
3. Add it as a repository secret named `CHOCOLATEY_API_KEY`
72+
73+
### 2. How It Works
74+
75+
When you create a release:
76+
77+
1. **GoReleaser** creates a Chocolatey package (.nupkg)
78+
2. **Package** gets automatically uploaded to Chocolatey repository
79+
3. **Users** can then install with:
80+
```powershell
81+
choco install codebase-interface
82+
```
83+
84+
The package will include:
85+
- Windows executable
86+
- PowerShell install/uninstall scripts
87+
- Automatic PATH configuration
88+
- Both `codebase-interface.exe` and `cbi.exe` commands
89+
90+
## 🔧 Required Repository Secrets
91+
92+
Add these secrets to your GitHub repository:
93+
94+
```bash
95+
# For Homebrew tap publishing
96+
HOMEBREW_TAP_GITHUB_TOKEN=github_pat_...
97+
98+
# For Chocolatey package publishing
99+
CHOCOLATEY_API_KEY=...
100+
101+
# Already configured for GitHub releases
102+
GITHUB_TOKEN=... (automatic)
103+
```
104+
105+
## 🎯 Testing Package Managers
106+
107+
### Test Homebrew Locally
108+
109+
```bash
110+
# Install from your tap
111+
brew tap codebase-interface/cli
112+
brew install codebase-interface
113+
114+
# Verify installation
115+
codebase-interface version
116+
cbi version
117+
118+
# Test upgrade path
119+
brew upgrade codebase-interface
120+
```
121+
122+
### Test Chocolatey Locally
123+
124+
```powershell
125+
# Install from Chocolatey
126+
choco install codebase-interface
127+
128+
# Verify installation
129+
codebase-interface version
130+
cbi version
131+
132+
# Test upgrade path
133+
choco upgrade codebase-interface
134+
```
135+
136+
## 📋 Release Checklist
137+
138+
Before releasing with package manager support:
139+
140+
- [ ] Create `codebase-interface/homebrew-cli` repository
141+
- [ ] Add `HOMEBREW_TAP_GITHUB_TOKEN` secret
142+
- [ ] Add `CHOCOLATEY_API_KEY` secret
143+
- [ ] Test GoReleaser configuration locally:
144+
```bash
145+
goreleaser check
146+
goreleaser release --snapshot --clean
147+
```
148+
- [ ] Create a test release with a pre-release tag
149+
- [ ] Verify packages are published correctly
150+
151+
## 🚀 First Release
152+
153+
For your first release with package managers:
154+
155+
1. **Create the required repositories and secrets**
156+
2. **Tag your release:**
157+
```bash
158+
git tag v1.0.0
159+
git push --tags
160+
```
161+
3. **Monitor the GitHub Action** to ensure all steps complete
162+
4. **Test installation** from both package managers
163+
5. **Update documentation** with installation instructions
164+
165+
The release process will:
166+
- ✅ Build binaries for all platforms
167+
- ✅ Create GitHub release with assets
168+
- ✅ Publish Docker images to GHCR
169+
- ✅ Create Homebrew formula in tap repository
170+
- ✅ Publish Chocolatey package to chocolatey.org
171+
172+
After the first successful release, users will be able to install your CLI using standard package managers!

mkdocs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ nav:
4444
- Go Project: examples/go-project.yml
4545
- Open Source: examples/open-source.yml
4646
- Strict Standards: examples/strict.yml
47+
- Development:
48+
- Package Manager Setup: package-manager-setup.md
4749

4850
plugins:
4951
- search

0 commit comments

Comments
 (0)