ci: add GitHub Actions workflows for testing, linting, and releasing
- Add ci.yml for lint, test, build on PR and push to main - Add release.yml for GoReleaser on version tags - Configure path filters to skip docs/markdown changes
- commit
- 22acf88d09798fc7cf0a233df3d7216954e3ba9a
- author
- brice · · 2026-01-12 20:19 UTC
- committer
- brice · · 2026-01-12 22:00 UTC
- parent
- 0456561
- signature
- unsigned
2 files · +135 -0
A .github/workflows/ci.yml +104 -0
| @@ -0,0 +1,104 @@ | |||
| 1 | + | name: CI | |
| 2 | + | ||
| 3 | + | on: | |
| 4 | + | push: | |
| 5 | + | branches: [main] | |
| 6 | + | paths: | |
| 7 | + | - '**.go' | |
| 8 | + | - 'go.mod' | |
| 9 | + | - 'go.sum' | |
| 10 | + | - '.golangci.yml' | |
| 11 | + | - 'Makefile' | |
| 12 | + | - '.github/workflows/**' | |
| 13 | + | - '!**.md' | |
| 14 | + | - '!docs/**' | |
| 15 | + | - '!LICENSE' | |
| 16 | + | pull_request: | |
| 17 | + | paths: | |
| 18 | + | - '**.go' | |
| 19 | + | - 'go.mod' | |
| 20 | + | - 'go.sum' | |
| 21 | + | - '.golangci.yml' | |
| 22 | + | - 'Makefile' | |
| 23 | + | - '.github/workflows/**' | |
| 24 | + | - '!**.md' | |
| 25 | + | - '!docs/**' | |
| 26 | + | - '!LICENSE' | |
| 27 | + | ||
| 28 | + | jobs: | |
| 29 | + | lint: | |
| 30 | + | name: Lint | |
| 31 | + | runs-on: ubuntu-latest | |
| 32 | + | steps: | |
| 33 | + | - uses: actions/checkout@v4 | |
| 34 | + | ||
| 35 | + | - uses: actions/setup-go@v5 | |
| 36 | + | with: | |
| 37 | + | go-version: stable | |
| 38 | + | ||
| 39 | + | - name: Cache Go modules | |
| 40 | + | uses: actions/cache@v4 | |
| 41 | + | with: | |
| 42 | + | path: ~/go/pkg/mod | |
| 43 | + | key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} | |
| 44 | + | restore-keys: | | |
| 45 | + | ${{ runner.os }}-go-mod- | |
| 46 | + | ||
| 47 | + | - name: Install golangci-lint | |
| 48 | + | run: | | |
| 49 | + | curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b /usr/local/bin v2.1.6 | |
| 50 | + | ||
| 51 | + | - name: Run golangci-lint | |
| 52 | + | run: golangci-lint run --timeout=5m | |
| 53 | + | ||
| 54 | + | test: | |
| 55 | + | name: Test | |
| 56 | + | runs-on: ubuntu-latest | |
| 57 | + | steps: | |
| 58 | + | - uses: actions/checkout@v4 | |
| 59 | + | ||
| 60 | + | - uses: actions/setup-go@v5 | |
| 61 | + | with: | |
| 62 | + | go-version: stable | |
| 63 | + | ||
| 64 | + | - name: Cache Go modules | |
| 65 | + | uses: actions/cache@v4 | |
| 66 | + | with: | |
| 67 | + | path: ~/go/pkg/mod | |
| 68 | + | key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} | |
| 69 | + | restore-keys: | | |
| 70 | + | ${{ runner.os }}-go-mod- | |
| 71 | + | ||
| 72 | + | - name: Cache Go build cache | |
| 73 | + | uses: actions/cache@v4 | |
| 74 | + | with: | |
| 75 | + | path: ~/.cache/go-build | |
| 76 | + | key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} | |
| 77 | + | restore-keys: | | |
| 78 | + | ${{ runner.os }}-go-build- | |
| 79 | + | ||
| 80 | + | - name: Run tests | |
| 81 | + | run: go test -race -v ./... | |
| 82 | + | ||
| 83 | + | build: | |
| 84 | + | name: Build | |
| 85 | + | runs-on: ubuntu-latest | |
| 86 | + | needs: [lint, test] | |
| 87 | + | steps: | |
| 88 | + | - uses: actions/checkout@v4 | |
| 89 | + | ||
| 90 | + | - uses: actions/setup-go@v5 | |
| 91 | + | with: | |
| 92 | + | go-version: stable | |
| 93 | + | ||
| 94 | + | - name: Build binaries | |
| 95 | + | run: | | |
| 96 | + | CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o gordon-linux-amd64 ./main.go | |
| 97 | + | CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o gordon-linux-arm64 ./main.go | |
| 98 | + | ||
| 99 | + | - name: Upload artifacts | |
| 100 | + | uses: actions/upload-artifact@v4 | |
| 101 | + | with: | |
| 102 | + | name: binaries | |
| 103 | + | path: gordon-linux-* | |
| 104 | + | retention-days: 7 | |
| @@ -0,0 +1,104 @@ | |||||
| 1 | + | name: CI | |||
| 2 | + | ||||
| 3 | + | on: | |||
| 4 | + | push: | |||
| 5 | + | branches: [main] | |||
| 6 | + | paths: | |||
| 7 | + | - '**.go' | |||
| 8 | + | - 'go.mod' | |||
| 9 | + | - 'go.sum' | |||
| 10 | + | - '.golangci.yml' | |||
| 11 | + | - 'Makefile' | |||
| 12 | + | - '.github/workflows/**' | |||
| 13 | + | - '!**.md' | |||
| 14 | + | - '!docs/**' | |||
| 15 | + | - '!LICENSE' | |||
| 16 | + | pull_request: | |||
| 17 | + | paths: | |||
| 18 | + | - '**.go' | |||
| 19 | + | - 'go.mod' | |||
| 20 | + | - 'go.sum' | |||
| 21 | + | - '.golangci.yml' | |||
| 22 | + | - 'Makefile' | |||
| 23 | + | - '.github/workflows/**' | |||
| 24 | + | - '!**.md' | |||
| 25 | + | - '!docs/**' | |||
| 26 | + | - '!LICENSE' | |||
| 27 | + | ||||
| 28 | + | jobs: | |||
| 29 | + | lint: | |||
| 30 | + | name: Lint | |||
| 31 | + | runs-on: ubuntu-latest | |||
| 32 | + | steps: | |||
| 33 | + | - uses: actions/checkout@v4 | |||
| 34 | + | ||||
| 35 | + | - uses: actions/setup-go@v5 | |||
| 36 | + | with: | |||
| 37 | + | go-version: stable | |||
| 38 | + | ||||
| 39 | + | - name: Cache Go modules | |||
| 40 | + | uses: actions/cache@v4 | |||
| 41 | + | with: | |||
| 42 | + | path: ~/go/pkg/mod | |||
| 43 | + | key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} | |||
| 44 | + | restore-keys: | | |||
| 45 | + | ${{ runner.os }}-go-mod- | |||
| 46 | + | ||||
| 47 | + | - name: Install golangci-lint | |||
| 48 | + | run: | | |||
| 49 | + | curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b /usr/local/bin v2.1.6 | |||
| 50 | + | ||||
| 51 | + | - name: Run golangci-lint | |||
| 52 | + | run: golangci-lint run --timeout=5m | |||
| 53 | + | ||||
| 54 | + | test: | |||
| 55 | + | name: Test | |||
| 56 | + | runs-on: ubuntu-latest | |||
| 57 | + | steps: | |||
| 58 | + | - uses: actions/checkout@v4 | |||
| 59 | + | ||||
| 60 | + | - uses: actions/setup-go@v5 | |||
| 61 | + | with: | |||
| 62 | + | go-version: stable | |||
| 63 | + | ||||
| 64 | + | - name: Cache Go modules | |||
| 65 | + | uses: actions/cache@v4 | |||
| 66 | + | with: | |||
| 67 | + | path: ~/go/pkg/mod | |||
| 68 | + | key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} | |||
| 69 | + | restore-keys: | | |||
| 70 | + | ${{ runner.os }}-go-mod- | |||
| 71 | + | ||||
| 72 | + | - name: Cache Go build cache | |||
| 73 | + | uses: actions/cache@v4 | |||
| 74 | + | with: | |||
| 75 | + | path: ~/.cache/go-build | |||
| 76 | + | key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }} | |||
| 77 | + | restore-keys: | | |||
| 78 | + | ${{ runner.os }}-go-build- | |||
| 79 | + | ||||
| 80 | + | - name: Run tests | |||
| 81 | + | run: go test -race -v ./... | |||
| 82 | + | ||||
| 83 | + | build: | |||
| 84 | + | name: Build | |||
| 85 | + | runs-on: ubuntu-latest | |||
| 86 | + | needs: [lint, test] | |||
| 87 | + | steps: | |||
| 88 | + | - uses: actions/checkout@v4 | |||
| 89 | + | ||||
| 90 | + | - uses: actions/setup-go@v5 | |||
| 91 | + | with: | |||
| 92 | + | go-version: stable | |||
| 93 | + | ||||
| 94 | + | - name: Build binaries | |||
| 95 | + | run: | | |||
| 96 | + | CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o gordon-linux-amd64 ./main.go | |||
| 97 | + | CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -o gordon-linux-arm64 ./main.go | |||
| 98 | + | ||||
| 99 | + | - name: Upload artifacts | |||
| 100 | + | uses: actions/upload-artifact@v4 | |||
| 101 | + | with: | |||
| 102 | + | name: binaries | |||
| 103 | + | path: gordon-linux-* | |||
| 104 | + | retention-days: 7 | |||
A .github/workflows/release.yml +31 -0
| @@ -0,0 +1,31 @@ | |||
| 1 | + | name: Release | |
| 2 | + | ||
| 3 | + | on: | |
| 4 | + | push: | |
| 5 | + | tags: | |
| 6 | + | - 'v*' | |
| 7 | + | ||
| 8 | + | permissions: | |
| 9 | + | contents: write | |
| 10 | + | ||
| 11 | + | jobs: | |
| 12 | + | release: | |
| 13 | + | name: Release | |
| 14 | + | runs-on: ubuntu-latest | |
| 15 | + | steps: | |
| 16 | + | - uses: actions/checkout@v4 | |
| 17 | + | with: | |
| 18 | + | fetch-depth: 0 | |
| 19 | + | ||
| 20 | + | - uses: actions/setup-go@v5 | |
| 21 | + | with: | |
| 22 | + | go-version: stable | |
| 23 | + | ||
| 24 | + | - name: Run GoReleaser | |
| 25 | + | uses: goreleaser/goreleaser-action@v6 | |
| 26 | + | with: | |
| 27 | + | distribution: goreleaser | |
| 28 | + | version: "~> v2" | |
| 29 | + | args: release --clean | |
| 30 | + | env: | |
| 31 | + | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| @@ -0,0 +1,31 @@ | |||||
| 1 | + | name: Release | |||
| 2 | + | ||||
| 3 | + | on: | |||
| 4 | + | push: | |||
| 5 | + | tags: | |||
| 6 | + | - 'v*' | |||
| 7 | + | ||||
| 8 | + | permissions: | |||
| 9 | + | contents: write | |||
| 10 | + | ||||
| 11 | + | jobs: | |||
| 12 | + | release: | |||
| 13 | + | name: Release | |||
| 14 | + | runs-on: ubuntu-latest | |||
| 15 | + | steps: | |||
| 16 | + | - uses: actions/checkout@v4 | |||
| 17 | + | with: | |||
| 18 | + | fetch-depth: 0 | |||
| 19 | + | ||||
| 20 | + | - uses: actions/setup-go@v5 | |||
| 21 | + | with: | |||
| 22 | + | go-version: stable | |||
| 23 | + | ||||
| 24 | + | - name: Run GoReleaser | |||
| 25 | + | uses: goreleaser/goreleaser-action@v6 | |||
| 26 | + | with: | |||
| 27 | + | distribution: goreleaser | |||
| 28 | + | version: "~> v2" | |||
| 29 | + | args: release --clean | |||
| 30 | + | env: | |||
| 31 | + | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |||