Skip to content

Commit a714c12

Browse files
committed
Add linting, CI and releasing
1 parent 09c9e01 commit a714c12

File tree

7 files changed

+218
-0
lines changed

7 files changed

+218
-0
lines changed

.github/dependabot.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
3+
version: 2
4+
5+
updates:
6+
- package-ecosystem: "gomod"
7+
directory: "/"
8+
schedule:
9+
interval: "weekly"

.github/workflows/deps.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
3+
# https://github.com/actions/go-dependency-submission
4+
name: Dependency Submission
5+
on:
6+
push:
7+
branches:
8+
- master
9+
10+
permissions:
11+
contents: write
12+
13+
jobs:
14+
main:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: actions/setup-go@v5
19+
with:
20+
go-version: "stable"
21+
- uses: actions/go-dependency-submission@v2
22+
with:
23+
go-mod-path: go.mod

.github/workflows/go-cross.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
3+
name: Go Matrix
4+
5+
on:
6+
push:
7+
branches:
8+
- master
9+
pull_request:
10+
workflow_dispatch:
11+
12+
jobs:
13+
cross:
14+
name: Go
15+
runs-on: ${{ matrix.os }}
16+
env:
17+
CGO_ENABLED: 0
18+
19+
strategy:
20+
matrix:
21+
go-version: [ "stable", "oldstable", "1.x" ]
22+
os: [ubuntu-latest, macos-latest, windows-latest]
23+
24+
steps:
25+
- name: Set up Go ${{ matrix.go-version }}
26+
uses: actions/setup-go@v5
27+
with:
28+
go-version: ${{ matrix.go-version }}
29+
cache: false
30+
31+
- name: Checkout code
32+
uses: actions/checkout@v4
33+
34+
- name: Cache Go modules
35+
uses: actions/cache@v4
36+
with:
37+
# In order:
38+
# * Module download cache
39+
# * Build cache (Linux)
40+
# * Build cache (Mac)
41+
# * Build cache (Windows)
42+
path: |
43+
~/go/pkg/mod
44+
~/.cache/go-build
45+
~/Library/Caches/go-build
46+
%LocalAppData%\go-build
47+
key: ${{ runner.os }}-${{ matrix.go-version }}-go-${{ hashFiles('**/go.sum') }}
48+
restore-keys: |
49+
${{ runner.os }}-${{ matrix.go-version }}-go-
50+
51+
- name: Test
52+
run: go test -v -cover ./...
53+
54+
- name: Build
55+
run: go build -ldflags "-s -w" -trimpath ./...

.github/workflows/main.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
3+
name: Main
4+
5+
on:
6+
push:
7+
branches:
8+
- master
9+
pull_request:
10+
workflow_dispatch:
11+
12+
jobs:
13+
14+
main:
15+
name: Main Process
16+
runs-on: ubuntu-latest
17+
env:
18+
GO_VERSION: "stable"
19+
GOLANGCI_LINT_VERSION: v2.2.1
20+
CGO_ENABLED: 0
21+
22+
steps:
23+
- name: Set up Go ${{ env.GO_VERSION }}
24+
uses: actions/setup-go@v5
25+
with:
26+
go-version: ${{ env.GO_VERSION }}
27+
cache: false
28+
29+
- name: Check out code
30+
uses: actions/checkout@v4
31+
with:
32+
fetch-depth: 0
33+
34+
- name: Cache Go modules
35+
uses: actions/cache@v4
36+
with:
37+
path: ~/go/pkg/mod
38+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
39+
restore-keys: |
40+
${{ runner.os }}-go-
41+
42+
- name: Check and get dependencies
43+
run: |
44+
go mod tidy
45+
git diff --exit-code go.mod
46+
git diff --exit-code go.sum
47+
48+
- name: Install golangci-lint ${{ env.GOLANGCI_LINT_VERSION }}
49+
run: |
50+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCI_LINT_VERSION}
51+
golangci-lint --version
52+
53+
- name: Lint
54+
run: golangci-lint run

.github/workflows/release.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
3+
name: goreleaser
4+
5+
on:
6+
push:
7+
tags:
8+
- 'v[0-9]+.[0-9]+.[0-9]+'
9+
workflow_dispatch:
10+
11+
jobs:
12+
goreleaser:
13+
name: Release ec_check
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Set up Go
23+
uses: actions/setup-go@v5
24+
with:
25+
go-version: "stable"
26+
27+
- name: Run GoReleaser
28+
uses: goreleaser/goreleaser-action@v6
29+
with:
30+
distribution: goreleaser
31+
version: latest
32+
args: release --clean
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.golangci.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
3+
version: "2"
4+
5+
linters:
6+
exclusions:
7+
rules:
8+
- linters:
9+
- errcheck
10+
source: cmd.Writer

.goreleaser.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
3+
before:
4+
hooks:
5+
- go mod tidy
6+
builds:
7+
- main: .
8+
binary: ec_check
9+
env:
10+
- CGO_ENABLED=0
11+
goos:
12+
- linux
13+
- windows
14+
- darwin
15+
archives:
16+
- name_template: >-
17+
{{- .Binary }}_
18+
{{- .Version }}_
19+
{{- title .Os }}_
20+
{{- if eq .Arch "amd64" }}x86_64
21+
{{- else if eq .Arch "386" }}i386
22+
{{- else }}{{ .Arch }}{{ end }}
23+
{{- if .Arm }}v{{ .Arm }}{{ end -}}
24+
snapshot:
25+
name_template: "{{ .Tag }}-next"
26+
changelog:
27+
disable: true
28+
release:
29+
github:
30+
owner: SwissLife-OSS
31+
name: ec_check
32+
gomod:
33+
proxy: false

0 commit comments

Comments
 (0)