Skip to content

Commit 2aa80b1

Browse files
committed
feat: add comprehensive installation and release automation
- Add version information and version command - Set up GitHub CI/CD workflows with automated testing - Configure GoReleaser for multi-platform releases - Add support for Homebrew, APT, AUR, and Snap packages - Create Docker containerization support - Add installation scripts for different platforms - Implement semantic versioning and release automation - Update documentation with all installation methods
1 parent 0866eb0 commit 2aa80b1

File tree

17 files changed

+1051
-19
lines changed

17 files changed

+1051
-19
lines changed

.github/workflows/ci.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
name: Test
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Go
18+
uses: actions/setup-go@v4
19+
with:
20+
go-version: '1.21'
21+
cache: true
22+
23+
- name: Download dependencies
24+
run: go mod download
25+
26+
- name: Run tests
27+
run: go test -v -race -coverprofile=coverage.out ./...
28+
29+
- name: Upload coverage to Codecov
30+
uses: codecov/codecov-action@v3
31+
with:
32+
file: ./coverage.out
33+
flags: unittests
34+
name: codecov-umbrella
35+
36+
lint:
37+
name: Lint
38+
runs-on: ubuntu-latest
39+
steps:
40+
- name: Checkout code
41+
uses: actions/checkout@v4
42+
43+
- name: Set up Go
44+
uses: actions/setup-go@v4
45+
with:
46+
go-version: '1.21'
47+
cache: true
48+
49+
- name: Run golangci-lint
50+
uses: golangci/golangci-lint-action@v3
51+
with:
52+
version: latest
53+
args: --timeout=5m
54+
55+
build:
56+
name: Build
57+
runs-on: ubuntu-latest
58+
needs: [test, lint]
59+
steps:
60+
- name: Checkout code
61+
uses: actions/checkout@v4
62+
63+
- name: Set up Go
64+
uses: actions/setup-go@v4
65+
with:
66+
go-version: '1.21'
67+
cache: true
68+
69+
- name: Build
70+
run: make build
71+
72+
- name: Build release binaries
73+
run: make release

.github/workflows/release.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
packages: write
11+
12+
jobs:
13+
goreleaser:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Set up Go
22+
uses: actions/setup-go@v4
23+
with:
24+
go-version: '1.21'
25+
cache: true
26+
27+
- name: Run GoReleaser
28+
uses: goreleaser/goreleaser-action@v5
29+
with:
30+
distribution: goreleaser
31+
version: latest
32+
args: release --clean
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
36+
docker:
37+
runs-on: ubuntu-latest
38+
steps:
39+
- name: Checkout
40+
uses: actions/checkout@v4
41+
42+
- name: Set up Docker Buildx
43+
uses: docker/setup-buildx-action@v3
44+
45+
- name: Login to GitHub Container Registry
46+
uses: docker/login-action@v3
47+
with:
48+
registry: ghcr.io
49+
username: ${{ github.actor }}
50+
password: ${{ secrets.GITHUB_TOKEN }}
51+
52+
- name: Extract metadata
53+
id: meta
54+
uses: docker/metadata-action@v5
55+
with:
56+
images: ghcr.io/${{ github.repository }}
57+
tags: |
58+
type=ref,event=tag
59+
type=raw,value=latest,enable={{is_default_branch}}
60+
61+
- name: Build and push Docker image
62+
uses: docker/build-push-action@v5
63+
with:
64+
context: .
65+
platforms: linux/amd64,linux/arm64
66+
push: true
67+
tags: ${{ steps.meta.outputs.tags }}
68+
labels: ${{ steps.meta.outputs.labels }}

.goreleaser.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,44 @@ brews:
7373
license: MIT
7474
description: AI-powered commit message generator
7575

76+
# Debian packages
77+
nfpms:
78+
-
79+
package_name: commitgen
80+
homepage: https://github.com/FreePeak/commitgen
81+
description: AI-powered git commit message generator
82+
maintainer: FreePeak <[email protected]>
83+
license: MIT
84+
formats:
85+
- deb
86+
- rpm
87+
- archlinux
88+
dependencies:
89+
- git
90+
recommends:
91+
- git
92+
contents:
93+
- src: ./README.md
94+
dst: /usr/share/doc/commitgen/README.md
95+
- src: ./LICENSE
96+
dst: /usr/share/licenses/commitgen/LICENSE
97+
98+
# Snap packages
99+
snapcrafts:
100+
- summary: AI-powered git commit message generator
101+
description: |
102+
Commitgen is a CLI tool that generates conventional commit messages
103+
using AI providers like Claude, Gemini, and Copilot. It analyzes
104+
your git changes and creates appropriate commit messages
105+
following best practices.
106+
grade: stable
107+
confinement: strict
108+
publish: true
109+
license: MIT
110+
apps:
111+
commitgen:
112+
plugs: ["home", "network"]
113+
76114
# GitHub release
77115
release:
78116
github:

Dockerfile

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Build stage
2+
FROM golang:1.21-alpine AS builder
3+
4+
WORKDIR /app
5+
6+
# Install dependencies
7+
RUN apk add --no-cache git ca-certificates tzdata
8+
9+
# Copy go mod and sum files
10+
COPY go.mod go.sum ./
11+
12+
# Download dependencies
13+
RUN go mod download
14+
15+
# Copy source code
16+
COPY . .
17+
18+
# Build the binary
19+
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o commitgen main.go
20+
21+
# Final stage
22+
FROM alpine:latest
23+
24+
# Install ca-certificates for HTTPS requests
25+
RUN apk --no-cache add ca-certificates tzdata
26+
27+
WORKDIR /root/
28+
29+
# Copy the binary from builder stage
30+
COPY --from=builder /app/commitgen .
31+
32+
# Create non-root user
33+
RUN addgroup -g 1001 -S commitgen && \
34+
adduser -u 1001 -S commitgen -G commitgen
35+
36+
# Change ownership of the binary
37+
RUN chown commitgen:commitgen /root/commitgen
38+
39+
# Switch to non-root user
40+
USER commitgen
41+
42+
# Set the entrypoint
43+
ENTRYPOINT ["./commitgen"]

Makefile

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,39 @@
22

33
# Build the binary
44
build:
5-
go build -o harvey main.go
5+
go build -o commitgen main.go
66

77
# Install to /usr/local/bin
88
install: build
9-
./harvey install
9+
./commitgen install
1010

1111
# Run tests
1212
test:
1313
go test ./...
1414

1515
# Clean build artifacts
1616
clean:
17-
rm -f harvey
17+
rm -f commitgen
1818

1919
# Install dependencies
2020
deps:
2121
go mod tidy
2222

2323
# Development build with race detection
2424
dev:
25-
go build -race -o harvey main.go
25+
go build -race -o commitgen main.go
2626

2727
# Release build
2828
release:
29-
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o harvey-linux-amd64 main.go
30-
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="-w -s" -o harvey-darwin-amd64 main.go
31-
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags="-w -s" -o harvey-darwin-arm64 main.go
29+
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o commitgen-linux-amd64 main.go
30+
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="-w -s" -o commitgen-darwin-amd64 main.go
31+
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags="-w -s" -o commitgen-darwin-arm64 main.go
3232

3333
# Show available targets
3434
help:
3535
@echo "Available targets:"
36-
@echo " build - Build the harvey binary"
37-
@echo " install - Build and install harvey to /usr/local/bin"
36+
@echo " build - Build the commitgen binary"
37+
@echo " install - Build and install commitgen to /usr/local/bin"
3838
@echo " test - Run all tests"
3939
@echo " clean - Remove build artifacts"
4040
@echo " deps - Install dependencies"

README.md

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,68 @@ A standalone CLI tool that generates conventional commit messages using AI. Comm
3636

3737
## Installation
3838

39-
### From Source
39+
### 🚀 One-Command Installation (Recommended)
40+
41+
```bash
42+
curl -fsSL https://raw.githubusercontent.com/FreePeak/commitgen/main/install-package.sh | bash
43+
```
44+
45+
This script automatically detects your OS and installs commitgen using the best available package manager.
46+
47+
### 📦 Package Manager Installation
48+
49+
#### macOS (Homebrew)
50+
```bash
51+
brew tap FreePeak/tap
52+
brew install commitgen
53+
```
54+
55+
#### Go Install (Cross-platform)
56+
```bash
57+
go install github.com/FreePeak/commitgen@latest
58+
```
59+
60+
#### Debian/Ubuntu (APT)
61+
```bash
62+
# Download and install .deb package
63+
curl -fsSL https://raw.githubusercontent.com/FreePeak/commitgen/main/install-package.sh | METHOD=2 bash
64+
```
65+
66+
#### Arch Linux (Pacman/AUR)
67+
```bash
68+
# Using yay (recommended)
69+
yay -S commitgen
70+
71+
# Or using paru
72+
paru -S commitgen
73+
74+
# Or manually
75+
git clone https://aur.archlinux.org/commitgen.git
76+
cd commitgen
77+
makepkg -si
78+
```
79+
80+
#### Snap (Cross-platform)
81+
```bash
82+
sudo snap install commitgen
83+
```
84+
85+
### 🐳 Docker Installation
86+
```bash
87+
# Pull from GitHub Container Registry
88+
docker pull ghcr.io/freepeak/commitgen:latest
89+
90+
# Run with volume mount
91+
docker run --rm -v $(pwd):/app -w /app ghcr.io/freepeak/commitgen:latest commit staged
92+
```
93+
94+
### 📥 Manual Binary Download
95+
```bash
96+
# Download the latest binary for your platform
97+
curl -fsSL https://raw.githubusercontent.com/FreePeak/commitgen/main/install.sh | bash
98+
```
99+
100+
### 🔧 From Source
40101

41102
```bash
42103
git clone https://github.com/FreePeak/commitgen.git
@@ -45,7 +106,7 @@ go build -o commitgen main.go
45106
./commitgen install
46107
```
47108

48-
### Quick Install
109+
### Quick Install (Power users)
49110

50111
```bash
51112
# Clone and build in one command

homebrew/commitgen.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Documentation: https://docs.brew.sh/Formula-Cookbook
2+
# https://rubydoc.brew.sh/Formula
3+
# PLEASE REMOVE ALL GENERATED COMMENTS BEFORE SUBMITTING YOUR PULL REQUEST!
4+
5+
class Commitgen < Formula
6+
desc "AI-powered git commit message generator"
7+
homepage "https://github.com/FreePeak/commitgen"
8+
url "https://github.com/FreePeak/commitgen/archive/refs/tags/v0.1.0.tar.gz"
9+
sha256 ""
10+
license "MIT"
11+
head "https://github.com/FreePeak/commitgen.git", branch: "main"
12+
13+
depends_on "go" => :build
14+
15+
def install
16+
system "go", "build", *std_go_args(ldflags: "-s -w"), "-o", bin/"commitgen", "main.go"
17+
end
18+
19+
test do
20+
system "#{bin}/commitgen", "--help"
21+
end
22+
end

0 commit comments

Comments
 (0)