Skip to content

Commit 107f968

Browse files
committed
Update CI/CD workflows
1 parent 2aa69b4 commit 107f968

8 files changed

Lines changed: 214 additions & 91 deletions

File tree

.github/workflows/format.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
name: Format
3+
4+
on:
5+
pull_request:
6+
branches: [main]
7+
paths:
8+
- "**/*.go"
9+
- ".github/workflows/format.yml"
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
format-check:
16+
name: Format Check
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Setup Go
23+
uses: actions/setup-go@v5
24+
with:
25+
go-version-file: go.mod
26+
cache: true
27+
28+
- name: Check formatting
29+
run: |
30+
if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then
31+
echo "The following files are not properly formatted:";
32+
gofmt -s -l .;
33+
echo "";
34+
echo "Please run 'go fmt ./...' to fix formatting issues.";
35+
exit 1;
36+
fi

.github/workflows/lint.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
name: Lint
3+
4+
on:
5+
pull_request:
6+
branches: [main]
7+
paths:
8+
- "**/*.go"
9+
- ".golangci.yml"
10+
- "go.mod"
11+
- "go.sum"
12+
- ".github/workflows/lint.yml"
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
golangci:
19+
name: golangci-lint
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: Setup Go
26+
uses: actions/setup-go@v5
27+
with:
28+
go-version-file: go.mod
29+
cache: true
30+
31+
- name: Run golangci-lint
32+
uses: golangci/golangci-lint-action@v6
33+
with:
34+
version: latest
35+
args: --timeout=5m

.github/workflows/pr-checks.yml

Lines changed: 0 additions & 90 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*.*.*'
7+
8+
permissions:
9+
contents: write
10+
11+
concurrency:
12+
group: release-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
goreleaser:
17+
name: Release with GoReleaser
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
with:
23+
# GoReleaser needs full history for changelog generation
24+
fetch-depth: 0
25+
26+
- name: Setup Go
27+
uses: actions/setup-go@v5
28+
with:
29+
go-version-file: go.mod
30+
cache: true
31+
32+
- name: Run GoReleaser
33+
uses: goreleaser/goreleaser-action@v6
34+
with:
35+
distribution: goreleaser
36+
version: latest
37+
args: release --clean
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/tests.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
name: Tests
3+
4+
on:
5+
pull_request:
6+
branches: [ main ]
7+
paths:
8+
- '**/*.go'
9+
- 'go.mod'
10+
- 'go.sum'
11+
- '.github/workflows/tests.yml'
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
unit-tests:
18+
name: Unit Tests
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: Setup Go
25+
uses: actions/setup-go@v5
26+
with:
27+
go-version-file: go.mod
28+
cache: true
29+
30+
- name: Download deps
31+
run: go mod download
32+
33+
- name: Run tests
34+
run: go test -v -race

.goreleaser.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# GoReleaser config for brokli
2+
# See https://goreleaser.com for reference
3+
4+
project_name: brokli
5+
6+
before:
7+
hooks:
8+
- go mod tidy
9+
10+
builds:
11+
- id: brokli
12+
main: .
13+
binary: brokli
14+
env:
15+
- CGO_ENABLED=0
16+
flags:
17+
- -trimpath
18+
ldflags:
19+
- -s -w
20+
goos: [linux, darwin, windows]
21+
goarch: [amd64, arm64]
22+
goarm: ["7"]
23+
24+
archives:
25+
- id: release-archives
26+
builds: [brokli]
27+
name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}'
28+
format_overrides:
29+
- goos: windows
30+
format: zip
31+
32+
checksum:
33+
name_template: 'SHA256SUMS.txt'
34+
35+
changelog:
36+
use: github
37+
filters:
38+
exclude:
39+
- '^docs:'
40+
- '^chore:'
41+
42+
release:
43+
# Mark pre-releases if the tag contains a hyphen (e.g., v1.0.0-rc1)
44+
prerelease: auto

Taskfile.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,31 @@ tasks:
8484
generates:
8585
- "{{.BINARY_NAME}}"
8686

87+
# Release (GoReleaser)
88+
goreleaser-install:
89+
desc: "Install GoReleaser CLI"
90+
cmd: go install github.com/goreleaser/goreleaser/v2@latest
91+
92+
release-check:
93+
desc: "Validate GoReleaser configuration"
94+
cmds:
95+
- |
96+
if ! command -v goreleaser >/dev/null 2>&1; then
97+
echo "GoReleaser not found. Install it with: task goreleaser-install";
98+
exit 1;
99+
fi
100+
- goreleaser check
101+
102+
release-snapshot:
103+
desc: "Build a local snapshot release (no publish)"
104+
cmds:
105+
- |
106+
if ! command -v goreleaser >/dev/null 2>&1; then
107+
echo "GoReleaser not found. Install it with: task goreleaser-install";
108+
exit 1;
109+
fi
110+
- goreleaser release --snapshot --clean
111+
87112
# Maintenance
88113
clean:
89114
desc: "Clean build artifacts and temporary files"

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ module github.com/endlesstrax/brokli
33
go 1.24.0
44

55
require (
6+
github.com/fatih/color v1.18.0
67
github.com/spf13/cobra v1.10.1
78
golang.org/x/net v0.44.0
89
)
910

1011
require (
11-
github.com/fatih/color v1.18.0 // indirect
1212
github.com/inconshreveable/mousetrap v1.1.0 // indirect
1313
github.com/mattn/go-colorable v0.1.13 // indirect
1414
github.com/mattn/go-isatty v0.0.20 // indirect

0 commit comments

Comments
 (0)