Skip to content

Commit 52b5100

Browse files
authored
Merge pull request #2 from illegalstudio/feature/homebrew
feature/homebrew
2 parents d64b3d2 + ea7d03c commit 52b5100

6 files changed

Lines changed: 108 additions & 3 deletions

File tree

.github/workflows/release.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
goreleaser:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- uses: actions/setup-go@v5
20+
with:
21+
go-version-file: go.mod
22+
23+
- uses: goreleaser/goreleaser-action@v6
24+
with:
25+
version: "~> v2"
26+
args: release --clean
27+
env:
28+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}

.goreleaser.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
version: 2
2+
3+
builds:
4+
- id: ggg
5+
main: ./cmd/ggg
6+
binary: ggg
7+
env:
8+
- CGO_ENABLED=0
9+
ldflags:
10+
- -s -w
11+
- -X github.com/illegalstudio/ggg/internal/version.Version={{.Version}}
12+
- -X github.com/illegalstudio/ggg/internal/version.Commit={{.ShortCommit}}
13+
goos:
14+
- darwin
15+
- linux
16+
goarch:
17+
- amd64
18+
- arm64
19+
20+
archives:
21+
- id: default
22+
formats:
23+
- tar.gz
24+
files:
25+
- README.md
26+
- LICENSE
27+
28+
changelog:
29+
sort: asc
30+
filters:
31+
exclude:
32+
- "^docs:"
33+
- "^test:"
34+
- "^chore:"
35+
36+
homebrew_casks:
37+
- repository:
38+
owner: illegalstudio
39+
name: homebrew-tap
40+
token: "{{ .Env.HOMEBREW_TAP_TOKEN }}"
41+
homepage: https://github.com/illegalstudio/ggg
42+
description: Clone and manage git repositories from a YAML configuration file

Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,17 @@
33
BINARY := ggg
44
PKG := ./cmd/ggg
55

6+
VERSION := $(shell git describe --tags --abbrev=0 2>/dev/null | sed 's/^v//' || echo dev)
7+
COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo none)
8+
LDFLAGS := -s -w \
9+
-X github.com/illegalstudio/ggg/internal/version.Version=$(VERSION) \
10+
-X github.com/illegalstudio/ggg/internal/version.Commit=$(COMMIT)
11+
612
build:
7-
go build -o $(BINARY) $(PKG)
13+
go build -ldflags "$(LDFLAGS)" -o $(BINARY) $(PKG)
814

915
install:
10-
go install $(PKG)
16+
go install -ldflags "$(LDFLAGS)" $(PKG)
1117

1218
test:
1319
go test ./...

README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,19 @@ GGG has a brother, [GGW](https://github.com/illegalstudio/ggw), that helps you m
1111

1212
## Installation
1313

14+
### Homebrew
15+
16+
```bash
17+
brew install illegalstudio/tap/ggg
18+
```
19+
20+
### Go
21+
1422
```bash
1523
go install github.com/illegalstudio/ggg/cmd/ggg@latest
1624
```
1725

18-
Or build from source:
26+
### From source
1927

2028
```bash
2129
git clone https://github.com/illegalstudio/ggg.git
@@ -43,6 +51,9 @@ ggg list
4351

4452
# Optional: enable gcd and shell completions
4553
eval "$(ggg shell-init zsh)"
54+
55+
# Print the installed version
56+
ggg --version
4657
```
4758

4859
## Commands

internal/cli/root.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"strings"
88

99
"github.com/illegalstudio/ggg/internal/config"
10+
"github.com/illegalstudio/ggg/internal/version"
1011

1112
"github.com/spf13/cobra"
1213
)
@@ -20,6 +21,7 @@ const (
2021
var rootCmd = &cobra.Command{
2122
Use: "ggg",
2223
Short: "Go Git Get — clone and manage git repositories from a config file",
24+
Version: version.String(),
2325
SilenceErrors: true,
2426
Long: `Go Git Get — clone and manage git repositories from a config file.
2527
@@ -37,6 +39,7 @@ Use "ggg <command> --help" for details on any command.`,
3739

3840
func init() {
3941
rootCmd.PersistentFlags().BoolVar(&jsonOutput, "json", false, "Output in JSON format (suppresses spinners and prompts)")
42+
rootCmd.SetVersionTemplate("{{.Version}}\n")
4043
}
4144

4245
func Execute() {

internal/version/version.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package version
2+
3+
import "fmt"
4+
5+
// Set via ldflags at build time (see .goreleaser.yaml).
6+
var (
7+
Version = "dev"
8+
Commit = "none"
9+
)
10+
11+
// String returns a human-readable version string.
12+
func String() string {
13+
return fmt.Sprintf("ggg v%s (%s)", Version, Commit)
14+
}

0 commit comments

Comments
 (0)