Skip to content

Commit eb1b780

Browse files
committed
feat: restructed, added .mds, test cases and CI
1 parent 3728df1 commit eb1b780

36 files changed

Lines changed: 3282 additions & 498 deletions

.codecov.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
coverage:
2+
status:
3+
project:
4+
default:
5+
target: 60% # minimum overall coverage to keep CI green
6+
threshold: 2% # allow up to 2% drop before failing
7+
patch:
8+
default:
9+
target: 50% # new code in a PR must have at least 50% coverage
10+
11+
ignore:
12+
- "main.go" # entry point only — nothing to test directly
13+
14+
comment:
15+
layout: "reach,diff,flags,tree"
16+
behavior: default
17+
require_changes: false # always post a comment, even if coverage is unchanged

.github/workflows/ci.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
test:
14+
name: Test (${{ matrix.os }})
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
os: [ubuntu-latest, macos-latest, windows-latest]
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- uses: actions/setup-go@v5
25+
with:
26+
go-version: stable
27+
cache: true
28+
29+
- name: Verify module consistency
30+
run: go mod verify
31+
32+
- name: Build
33+
run: go build ./...
34+
35+
- name: Test
36+
run: go test -v -race -coverprofile=coverage.out -covermode=atomic ./...
37+
38+
- name: Upload coverage to Codecov
39+
# Only upload from one OS to avoid double-counting.
40+
if: matrix.os == 'ubuntu-latest'
41+
uses: codecov/codecov-action@v5
42+
with:
43+
files: ./coverage.out
44+
flags: unittests
45+
name: git-profile-coverage
46+
fail_ci_if_error: false # don't fail CI if Codecov is unavailable
47+
env:
48+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
49+
50+
lint:
51+
name: Lint
52+
runs-on: ubuntu-latest
53+
steps:
54+
- uses: actions/checkout@v4
55+
56+
- uses: actions/setup-go@v5
57+
with:
58+
go-version: stable
59+
cache: true
60+
61+
- name: golangci-lint
62+
uses: golangci/golangci-lint-action@v6
63+
with:
64+
version: latest
65+
args: --timeout=5m
66+
67+
build-snapshot:
68+
name: Build snapshot
69+
runs-on: ubuntu-latest
70+
steps:
71+
- uses: actions/checkout@v4
72+
with:
73+
fetch-depth: 0
74+
75+
- uses: actions/setup-go@v5
76+
with:
77+
go-version: stable
78+
cache: true
79+
80+
- uses: goreleaser/goreleaser-action@v6
81+
with:
82+
distribution: goreleaser
83+
version: "~> v2"
84+
args: release --snapshot --clean

.github/workflows/release.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
release:
14+
name: Release
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0 # GoReleaser needs full history for changelog
20+
21+
- uses: actions/setup-go@v5
22+
with:
23+
go-version: stable
24+
cache: true
25+
26+
- name: Run tests before release
27+
run: go test -race ./...
28+
29+
- uses: goreleaser/goreleaser-action@v6
30+
with:
31+
distribution: goreleaser
32+
version: "~> v2"
33+
args: release --clean
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
# Optional — set to publish to each distribution channel.
37+
# If a secret is absent the channel is skipped automatically.
38+
HOMEBREW_TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN || '' }}
39+
SCOOP_BUCKET_TOKEN: ${{ secrets.SCOOP_BUCKET_TOKEN || '' }}
40+
AUR_KEY: ${{ secrets.AUR_KEY || '' }}

.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Binary
2+
git-profile
3+
git-profile.exe
4+
5+
# Build artifacts
6+
dist/
7+
coverage.out
8+
9+
# Editor / OS
10+
.DS_Store
11+
.idea/
12+
.vscode/
13+
*.swp
14+
*.swo
15+
16+
# GoReleaser
17+
/dist

.goreleaser.yaml

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
version: 2
2+
3+
project_name: git-profile
4+
5+
before:
6+
hooks:
7+
- go mod tidy
8+
- go vet ./...
9+
10+
builds:
11+
- id: git-profile
12+
main: .
13+
binary: git-profile
14+
env:
15+
- CGO_ENABLED=0
16+
ldflags:
17+
- -s -w
18+
- -X main.version={{.Version}}
19+
- -X main.commit={{.Commit}}
20+
- -X main.date={{.Date}}
21+
goos:
22+
- linux
23+
- darwin
24+
- windows
25+
goarch:
26+
- amd64
27+
- arm64
28+
- arm # linux/arm (armv7 — Raspberry Pi, embedded)
29+
goarm:
30+
- "7"
31+
ignore:
32+
- goos: windows
33+
goarch: arm64
34+
- goos: windows
35+
goarch: arm
36+
- goos: darwin
37+
goarch: arm
38+
39+
archives:
40+
- id: default
41+
format: tar.gz
42+
name_template: >-
43+
{{ .ProjectName }}_
44+
{{- .Os }}_
45+
{{- if eq .Arch "amd64" }}x86_64
46+
{{- else if eq .Arch "arm64" }}arm64
47+
{{- else if eq .Arch "arm" }}armv7
48+
{{- else }}{{ .Arch }}{{ end }}
49+
format_overrides:
50+
- goos: windows
51+
format: zip
52+
files:
53+
- LICENSE
54+
- README.md
55+
56+
checksum:
57+
name_template: checksums.txt
58+
algorithm: sha256
59+
60+
snapshot:
61+
version_template: "{{ incpatch .Version }}-dev"
62+
63+
changelog:
64+
sort: asc
65+
use: github
66+
filters:
67+
exclude:
68+
- "^docs:"
69+
- "^test:"
70+
- "^chore:"
71+
- "^ci:"
72+
- "Merge pull request"
73+
- "Merge branch"
74+
groups:
75+
- title: "New Features"
76+
regexp: "^feat"
77+
order: 0
78+
- title: "Bug Fixes"
79+
regexp: "^fix"
80+
order: 1
81+
- title: "Other"
82+
order: 999
83+
84+
# ── macOS / Linux: Homebrew ────────────────────────────────────────────────
85+
brews:
86+
- repository:
87+
owner: hapiio
88+
name: homebrew-tap
89+
token: "{{ .Env.HOMEBREW_TAP_TOKEN }}"
90+
commit_author:
91+
name: goreleaserbot
92+
email: bot@goreleaser.com
93+
commit_message_template: "Brew formula update for {{ .ProjectName }} version {{ .Tag }}"
94+
directory: Formula
95+
homepage: "https://github.com/hapiio/git-profile"
96+
description: "Manage multiple git identity profiles with a single command"
97+
license: "MIT"
98+
test: |
99+
system "#{bin}/git-profile", "version"
100+
install: |
101+
bin.install "git-profile"
102+
# Shell completions
103+
bash_completion.install Utils.safe_popen_read(bin/"git-profile", "completion", "bash") => "git-profile"
104+
zsh_completion.install Utils.safe_popen_read(bin/"git-profile", "completion", "zsh") => "_git-profile"
105+
fish_completion.install Utils.safe_popen_read(bin/"git-profile", "completion", "fish") => "git-profile.fish"
106+
107+
# ── Windows: Scoop ────────────────────────────────────────────────────────
108+
# Skipped automatically when SCOOP_BUCKET_TOKEN secret is not configured.
109+
scoops:
110+
- repository:
111+
owner: hapiio
112+
name: scoop-bucket
113+
token: "{{ .Env.SCOOP_BUCKET_TOKEN }}"
114+
commit_author:
115+
name: goreleaserbot
116+
email: bot@goreleaser.com
117+
commit_message_template: "Scoop update for {{ .ProjectName }} version {{ .Tag }}"
118+
directory: bucket
119+
homepage: "https://github.com/hapiio/git-profile"
120+
description: "Manage multiple git identity profiles with a single command"
121+
license: MIT
122+
skip_upload: "{{ if not .Env.SCOOP_BUCKET_TOKEN }}true{{ end }}"
123+
124+
# ── Arch Linux: AUR ──────────────────────────────────────────────────────
125+
aurs:
126+
- name: git-profile-bin
127+
homepage: "https://github.com/hapiio/git-profile"
128+
description: "Manage multiple git identity profiles with a single command"
129+
maintainers:
130+
- "hapiio <hapiio at users dot noreply dot github dot com>"
131+
license: MIT
132+
private_key: "{{ .Env.AUR_KEY }}"
133+
git_url: "ssh://aur@aur.archlinux.org/git-profile-bin.git"
134+
skip_upload: auto # skip if AUR_KEY secret is not set
135+
package: |-
136+
install -Dm755 "./git-profile" "${pkgdir}/usr/bin/git-profile"
137+
install -Dm644 "./LICENSE" "${pkgdir}/usr/share/licenses/git-profile/LICENSE"
138+
install -Dm644 "./README.md" "${pkgdir}/usr/share/doc/git-profile/README.md"
139+
140+
# ── Linux: .deb / .rpm ───────────────────────────────────────────────────
141+
nfpms:
142+
- id: packages
143+
package_name: git-profile
144+
homepage: https://github.com/hapiio/git-profile
145+
maintainer: hapiio <hapiio@users.noreply.github.com>
146+
description: Manage multiple git identity profiles with a single command.
147+
license: MIT
148+
formats:
149+
- deb
150+
- rpm
151+
bindir: /usr/bin
152+
contents:
153+
- src: ./LICENSE
154+
dst: /usr/share/licenses/git-profile/LICENSE
155+
- src: ./README.md
156+
dst: /usr/share/doc/git-profile/README.md

0 commit comments

Comments
 (0)