Skip to content

Commit ace40ac

Browse files
committed
feat: add CI/CD workflows, license, and update project details
- Introduced `.github/workflows/ci.yml`: - Added CI pipeline for testing, building, and artifact upload. - Configured matrix builds for multiple OS/architectures. - Added `.github/workflows/release.yml`: - Automated release process triggered by version tags. - Builds binaries for Linux, macOS, and Windows. - Publishes release artifacts using `softprops/action-gh-release`. - Added `LICENSE` file with MIT license. - Updated `README.md`: - Added installation, usage, and prerequisites sections. - Improved documentation for advanced options. - Renamed internal constants and variables: - Changed `standup` references to `commitmsg` for consistency. - Updated `extension.yml` with metadata for version `v1.0.0`. - Enhanced prompt configuration: - Added line length guideline to `commitmsg.prompt.yml`.
1 parent e16e402 commit ace40ac

File tree

8 files changed

+183
-9
lines changed

8 files changed

+183
-9
lines changed

.github/workflows/ci.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Set up Go
16+
uses: actions/setup-go@v4
17+
with:
18+
go-version: '1.21'
19+
20+
- name: Download dependencies
21+
run: go mod download
22+
23+
- name: Run tests
24+
run: go test -v ./...
25+
26+
- name: Build
27+
run: go build -v ./cmd/commitmsg
28+
29+
build:
30+
runs-on: ubuntu-latest
31+
needs: test
32+
strategy:
33+
matrix:
34+
goos: [linux, windows, darwin]
35+
goarch: [amd64, arm64]
36+
exclude:
37+
- goarch: arm64
38+
goos: windows
39+
steps:
40+
- uses: actions/checkout@v4
41+
42+
- name: Set up Go
43+
uses: actions/setup-go@v4
44+
with:
45+
go-version: '1.21'
46+
47+
- name: Build binary
48+
env:
49+
GOOS: ${{ matrix.goos }}
50+
GOARCH: ${{ matrix.goarch }}
51+
run: |
52+
mkdir -p dist
53+
go build -o dist/gh-commitmsg-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goos == 'windows' && '.exe' || '' }} ./cmd/commitmsg
54+
55+
- name: Upload artifacts
56+
uses: actions/upload-artifact@v4
57+
with:
58+
name: gh-commitmsg-${{ matrix.goos }}-${{ matrix.goarch }}
59+
path: dist/
60+
retention-days: 5
61+
62+
merge-artifacts:
63+
needs: build
64+
runs-on: ubuntu-latest
65+
steps:
66+
- name: Merge Artifacts
67+
uses: actions/upload-artifact/merge@v4
68+
with:
69+
name: gh-commitmsg-all-platforms
70+
pattern: gh-commitmsg-*
71+
retention-days: 7

.github/workflows/release.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
steps:
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+
22+
- name: Build binaries
23+
run: |
24+
mkdir -p dist
25+
26+
# Linux
27+
GOOS=linux GOARCH=amd64 go build -o dist/gh-commitmsg-linux-amd64 ./cmd/commitmsg
28+
GOOS=linux GOARCH=arm64 go build -o dist/gh-commitmsg-linux-arm64 ./cmd/commitmsg
29+
30+
# macOS
31+
GOOS=darwin GOARCH=amd64 go build -o dist/gh-commitmsg-darwin-amd64 ./cmd/commitmsg
32+
GOOS=darwin GOARCH=arm64 go build -o dist/gh-commitmsg-darwin-arm64 ./cmd/commitmsg
33+
34+
# Windows
35+
GOOS=windows GOARCH=amd64 go build -o dist/gh-commitmsg-windows-amd64.exe ./cmd/commitmsg
36+
37+
- name: Create Release
38+
uses: softprops/action-gh-release@v1
39+
with:
40+
files: dist/*
41+
generate_release_notes: true

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 gh-commitmsg
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject so the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,48 @@
11
# gh-commitmsg
22

3-
Tool idea:
4-
- get staged changes in the git repository in the current directory
5-
- feed the obtained data to the GitHub Models LLM to generate a conventional commit message
6-
- display the generated commit message on the screen
7-
- if it works well, we can provide several previous commit messages as examples for the model
3+
Based on [gh-standup](https://github.com/sgoedecke/gh-standup) by Sean Goedecke.
4+
5+
A GitHub CLI extension that generates AI-powered commit messages using staged git changes from current repository. It uses free [GitHub Models](https://docs.github.com/en/github-models) for inference, so you don't need to do any token setup - your existing GitHub CLI token will do fine!
6+
7+
## Installation
8+
9+
```bash
10+
gh extension install hazadus/gh-commitmsg
11+
gh commitmsg
12+
```
13+
14+
### Organizations
15+
16+
To ensure the GitHub CLI can access your organization's data:
17+
18+
```bash
19+
# Authenticate with GitHub CLI (if not already done)
20+
gh auth login
21+
22+
# Authenticate with your organizations
23+
gh auth refresh -h github.com -s read:org
24+
```
25+
26+
### Prerequisites
27+
28+
- [GitHub CLI](https://cli.github.com/) installed and authenticated
829

930
## Usage
1031

32+
### Basic Usage
33+
34+
Generate a commit message for the staged changes:
35+
1136
```bash
12-
commitmsg --language russian
37+
gh commitmsg
38+
```
39+
40+
### Advanced Options
41+
42+
```bash
43+
# Use different language
44+
gh commitmsg --language russian
45+
46+
# Use previous 3 commit messages as context
47+
gh commitmsg --examples
1348
```

cmd/commitmsg/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"github.com/spf13/cobra"
1111
)
1212

13-
const extensionName = "standup"
13+
const extensionName = "commitmsg"
1414

1515
var (
1616
flagLanguage string

extension.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
name: commitmsg
2+
owner: gh-commitmsg
3+
host: github.com
4+
tag: v1.0.0

internal/llm/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
)
1717

1818
//go:embed commitmsg.prompt.yml
19-
var standupPromptYAML []byte
19+
var commitmsgPromptYAML []byte
2020

2121
// PromptConfig represents the structure of the prompt configuration file
2222
// It includes the model parameters and the messages to be sent to the model.
@@ -154,7 +154,7 @@ func (c *Client) GenerateCommitMessage(
154154

155155
func loadPromptConfig() (*PromptConfig, error) {
156156
var config PromptConfig
157-
err := yaml.Unmarshal(standupPromptYAML, &config)
157+
err := yaml.Unmarshal(commitmsgPromptYAML, &config)
158158
if err != nil {
159159
return nil, fmt.Errorf("failed to parse prompt configuration: %w", err)
160160
}

internal/llm/commitmsg.prompt.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ messages:
1515
1616
Guidelines:
1717
18+
- Each line should be no longer than 72 characters
19+
1820
- Keep it professional but conversational
1921
2022
- Focus on meaningful work rather than trivial changes

0 commit comments

Comments
 (0)