Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
name: Format

on:
pull_request:
branches: [main]
paths:
- "**/*.go"
- ".github/workflows/format.yml"

permissions:
contents: read

jobs:
format-check:
name: Format Check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true

- name: Check formatting
run: |
if [ "$(gofmt -s -l . | wc -l)" -gt 0 ]; then
echo "The following files are not properly formatted:";
gofmt -s -l .;
echo "";
echo "Please run 'go fmt ./...' to fix formatting issues.";
exit 1;
fi
37 changes: 37 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
name: Lint

on:
pull_request:
branches: [main]
paths:
- "**/*.go"
- ".golangci.yml"
- "go.mod"
- "go.sum"
- ".github/workflows/lint.yml"

permissions:
contents: read

jobs:
golangci:
name: golangci-lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true

- name: Install golangci-lint (latest)
run: |
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
~/go/bin/golangci-lint --version

- name: Run golangci-lint
run: ~/go/bin/golangci-lint run --timeout=5m ./...
90 changes: 0 additions & 90 deletions .github/workflows/pr-checks.yml

This file was deleted.

61 changes: 61 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Release

on:
push:
tags:
- 'v*.*.*'

permissions:
contents: write

concurrency:
group: release-${{ github.ref }}
cancel-in-progress: true

jobs:
goreleaser:
name: Release with GoReleaser
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# GoReleaser needs full history for changelog generation
fetch-depth: 0

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true

- name: Validate version match
run: |
# Extract version from git tag (strip 'v' prefix)
TAG_VERSION="${GITHUB_REF#refs/tags/v}"
echo "Tag version: v${TAG_VERSION}"

# Extract version from cmd/root.go
CODE_VERSION=$(grep -oP 'Version:\s*"\K[^"]+' cmd/root.go)
echo "Code version: ${CODE_VERSION}"

# Compare versions
if [ "${TAG_VERSION}" != "${CODE_VERSION}" ]; then
echo "❌ Error: Version mismatch!"
echo " Git tag: v${TAG_VERSION}"
echo " Code: ${CODE_VERSION}"
echo ""
echo "Please update the version in cmd/root.go to match the tag."
exit 1
fi

echo "✅ Version match confirmed: ${CODE_VERSION}"

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34 changes: 34 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
name: Tests

on:
pull_request:
branches: [ main ]
paths:
- '**/*.go'
- 'go.mod'
- 'go.sum'
- '.github/workflows/tests.yml'

permissions:
contents: read

jobs:
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true

- name: Download deps
run: go mod download

- name: Run tests
run: go test -v -race
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

# Binary name
brokli
dist/

# Test binary, built with `go test -c`
*.test
Expand All @@ -31,6 +32,3 @@ go.work.sum

# env file
.env

# Binary name
brokli
64 changes: 27 additions & 37 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,36 @@
version: "2"
# golangci-lint configuration
# See https://golangci-lint.run/usage/configuration/

version: 2

run:
tests: true
timeout: 5m

linters:
enable:
- goconst
- gosec
- misspell
- unconvert
- unparam
settings:
goconst:
min-len: 2
min-occurrences: 3
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
- gosec
- unparam
path: _test\.go
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gofmt
- goimports
settings:
gofmt:
simplify: true
goimports:
local-prefixes:
- github.com/endlesstrax/brokli
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$

linters-settings:
goconst:
min-len: 2
min-occurrences: 3
gofmt:
simplify: true
goimports:
local-prefixes: github.com/endlesstrax/brokli

issues:
exclude-rules:
- path: _test\.go
linters:
- gosec
- unparam
exclude-dirs:
- third_party
- builtin
- examples
40 changes: 40 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# GoReleaser config for brokli (v2)
# See https://goreleaser.com for reference

version: 2

project_name: brokli

before:
hooks:
- go mod tidy

builds:
- id: brokli
main: .
binary: brokli
env:
- CGO_ENABLED=0
flags:
- -trimpath
ldflags:
- -s -w
goos: [linux, darwin, windows]
goarch: [amd64, arm64]
goarm: ["7"]

archives:
- name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'
files:
- LICENSE*
- README*
- CHANGELOG*

checksum:
name_template: 'SHA256SUMS_{{ .Version }}.txt'

changelog:
use: github

release:
prerelease: auto
Loading
Loading