Skip to content

Commit 416a69d

Browse files
authored
Initial commit
0 parents  commit 416a69d

File tree

14 files changed

+558
-0
lines changed

14 files changed

+558
-0
lines changed

.github/Brewfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
tap "golangci/tap"
2+
tap "vektra/tap"
3+
tap "kyoh86/tap"
4+
tap "sv-tools/apps"
5+
tap "goreleaser/tap"
6+
7+
# Fast linters runner for Go.
8+
brew "golangci/tap/golangci-lint"
9+
# Rich-Go will enrich `go test` outputs with text decorations
10+
brew "kyoh86/tap/richgo"
11+
# bumptag is a tool to increment a version and to create a git tag with an annotation.
12+
brew "sv-tools/apps/bumptag"
13+
# A mock code autogenerator for Go
14+
brew "vektra/tap/mockery"
15+
# Deliver Go binaries as fast and easily as possible
16+
brew "goreleaser/tap/goreleaser"

.github/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM scratch
2+
ENTRYPOINT ["/go-repo-template"]
3+
COPY go-repo-template /

.github/codecov.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
comment: false

.github/dependabot.yml

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

.github/goreleaser-cli.yml

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
project_name: go-repo-template
2+
3+
release:
4+
prerelease: auto
5+
6+
changelog:
7+
use: github
8+
9+
builds:
10+
- binary: "{{ .ProjectName }}"
11+
goos:
12+
- darwin
13+
- linux
14+
goarch:
15+
- amd64
16+
- arm64
17+
env:
18+
- CGO_ENABLED=0
19+
main: ./
20+
ldflags: -s -w -X main.version={{ .Tag }}
21+
22+
archives:
23+
- format: tar.gz
24+
wrap_in_directory: true
25+
name_template: "{{ .Binary }}-{{ .Tag }}-{{ .Os }}-{{ .Arch }}"
26+
27+
checksum:
28+
name_template: "{{ .ProjectName }}-{{ .Tag }}-checksums.txt"
29+
30+
signs:
31+
- artifacts: checksum
32+
33+
dockers:
34+
- image_templates: ["ghcr.io/sv-tools/{{ .ProjectName }}:{{ .Tag }}-amd64"]
35+
dockerfile: .github/Dockerfile
36+
use: buildx
37+
goarch: amd64
38+
build_flag_templates:
39+
- "--platform=linux/amd64"
40+
- "--label=org.opencontainers.image.title={{ .ProjectName }}"
41+
- "--label=org.opencontainers.image.description={{ .ProjectName }}"
42+
- "--label=org.opencontainers.image.url={{ .GitURL }}"
43+
- "--label=org.opencontainers.image.source={{ .GitURL }}"
44+
- "--label=org.opencontainers.image.version={{ .Tag }}"
45+
- '--label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}'
46+
- "--label=org.opencontainers.image.revision={{ .FullCommit }}"
47+
- "--label=org.opencontainers.image.licenses=MIT"
48+
- image_templates: ["ghcr.io/sv-tools/{{ .ProjectName }}:{{ .Tag }}-arm64v8"]
49+
dockerfile: .github/Dockerfile
50+
use: buildx
51+
goarch: arm64
52+
build_flag_templates:
53+
- "--platform=linux/arm64/v8"
54+
- "--label=org.opencontainers.image.title={{ .ProjectName }}"
55+
- "--label=org.opencontainers.image.description={{ .ProjectName }}"
56+
- "--label=org.opencontainers.image.url={{ .GitURL }}"
57+
- "--label=org.opencontainers.image.source={{ .GitURL }}"
58+
- "--label=org.opencontainers.image.version={{ .Tag }}"
59+
- '--label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}'
60+
- "--label=org.opencontainers.image.revision={{ .FullCommit }}"
61+
- "--label=org.opencontainers.image.licenses=MIT"
62+
- image_templates: ["svtools/{{ .ProjectName }}:{{ .Tag }}-amd64"]
63+
dockerfile: .github/Dockerfile
64+
use: buildx
65+
goarch: amd64
66+
build_flag_templates:
67+
- "--platform=linux/amd64"
68+
- "--label=org.opencontainers.image.title={{ .ProjectName }}"
69+
- "--label=org.opencontainers.image.description={{ .ProjectName }}"
70+
- "--label=org.opencontainers.image.url={{ .GitURL }}"
71+
- "--label=org.opencontainers.image.source={{ .GitURL }}"
72+
- "--label=org.opencontainers.image.version={{ .Tag }}"
73+
- '--label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}'
74+
- "--label=org.opencontainers.image.revision={{ .FullCommit }}"
75+
- "--label=org.opencontainers.image.licenses=MIT"
76+
- image_templates: ["svtools/{{ .ProjectName }}:{{ .Tag }}-arm64v8"]
77+
dockerfile: .github/Dockerfile
78+
use: buildx
79+
goarch: arm64
80+
build_flag_templates:
81+
- "--platform=linux/arm64/v8"
82+
- "--label=org.opencontainers.image.title={{ .ProjectName }}"
83+
- "--label=org.opencontainers.image.description={{ .ProjectName }}"
84+
- "--label=org.opencontainers.image.url={{ .GitURL }}"
85+
- "--label=org.opencontainers.image.source={{ .GitURL }}"
86+
- "--label=org.opencontainers.image.version={{ .Tag }}"
87+
- '--label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}'
88+
- "--label=org.opencontainers.image.revision={{ .FullCommit }}"
89+
- "--label=org.opencontainers.image.licenses=MIT"
90+
91+
docker_manifests:
92+
- name_template: "ghcr.io/sv-tools/{{ .ProjectName }}:{{ .Tag }}"
93+
image_templates:
94+
- "ghcr.io/sv-tools/{{ .ProjectName }}:{{ .Tag }}-amd64"
95+
- "ghcr.io/sv-tools/{{ .ProjectName }}:{{ .Tag }}-arm64v8"
96+
create_flags:
97+
- --amend
98+
- name_template: "ghcr.io/sv-tools/{{ .ProjectName }}:latest"
99+
image_templates:
100+
- "ghcr.io/sv-tools/{{ .ProjectName }}:{{ .Tag }}-amd64"
101+
- "ghcr.io/sv-tools/{{ .ProjectName }}:{{ .Tag }}-arm64v8"
102+
create_flags:
103+
- --amend
104+
- name_template: "ghcr.io/sv-tools/{{ .ProjectName }}:v{{ .Major }}"
105+
image_templates:
106+
- "ghcr.io/sv-tools/{{ .ProjectName }}:{{ .Tag }}-amd64"
107+
- "ghcr.io/sv-tools/{{ .ProjectName }}:{{ .Tag }}-arm64v8"
108+
create_flags:
109+
- --amend
110+
- name_template: "svtools/{{ .ProjectName }}:{{ .Tag }}"
111+
image_templates:
112+
- "svtools/{{ .ProjectName }}:{{ .Tag }}-amd64"
113+
- "svtools/{{ .ProjectName }}:{{ .Tag }}-arm64v8"
114+
create_flags:
115+
- --amend
116+
- name_template: "svtools/{{ .ProjectName }}:latest"
117+
image_templates:
118+
- "svtools/{{ .ProjectName }}:{{ .Tag }}-amd64"
119+
- "svtools/{{ .ProjectName }}:{{ .Tag }}-arm64v8"
120+
create_flags:
121+
- --amend
122+
- name_template: "svtools/{{ .ProjectName }}:v{{ .Major }}"
123+
image_templates:
124+
- "svtools/{{ .ProjectName }}:{{ .Tag }}-amd64"
125+
- "svtools/{{ .ProjectName }}:{{ .Tag }}-arm64v8"
126+
create_flags:
127+
- --amend
128+
129+
brews:
130+
- tap:
131+
owner: sv-tools
132+
name: homebrew-apps
133+
folder: Formula
134+
homepage: "{{ .GitURL }}"
135+
description: "{{ .ProjectName }}"
136+
license: MIT
137+
install: bin.install "{{ .ProjectName }}"
138+
test: assert_equal `#{bin}/{{ .ProjectName }} --version`, "{{ .ProjectName }} version v#{version}"

.github/goreleaser-lib.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
project_name: go-repo-template
2+
3+
release:
4+
prerelease: auto
5+
6+
changelog:
7+
use: github
8+
9+
builds:
10+
- skip: true

.github/workflows/checks.yaml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: "Code Analysis"
2+
3+
on:
4+
push:
5+
tags:
6+
- v*
7+
branches:
8+
- main
9+
pull_request:
10+
schedule:
11+
- cron: "0 0 * * 0"
12+
13+
concurrency:
14+
group: ${{ format('{0}-{1}', github.workflow, github.head_ref) }}
15+
cancel-in-progress: true
16+
17+
env:
18+
GO: "1.17"
19+
20+
jobs:
21+
CodeQL:
22+
runs-on: ubuntu-latest
23+
24+
permissions:
25+
security-events: write
26+
27+
steps:
28+
- name: Checkout repository
29+
uses: actions/checkout@v3
30+
31+
- name: Initialize CodeQL
32+
uses: github/codeql-action/init@v2
33+
with:
34+
languages: go
35+
36+
- name: Perform CodeQL Analysis
37+
uses: github/codeql-action/analyze@v2
38+
39+
UnitTests:
40+
runs-on: ubuntu-latest
41+
42+
steps:
43+
- name: Checkout repository
44+
uses: actions/checkout@v3
45+
46+
- name: Install Go
47+
uses: actions/setup-go@v3
48+
with:
49+
go-version: ${{ env.GO }}
50+
51+
- name: Run Unit Tests
52+
run: go test -race -cover -coverprofile=coverage.out -covermode=atomic
53+
54+
- name: Codecov
55+
uses: codecov/[email protected]
56+
with:
57+
file: ./coverage.out
58+
59+
GolangCI-Lint:
60+
runs-on: ubuntu-latest
61+
62+
steps:
63+
- name: Checkout repository
64+
uses: actions/checkout@v3
65+
66+
- name: Install Go
67+
uses: actions/setup-go@v3
68+
with:
69+
go-version: ${{ env.GO }}
70+
71+
- name: Run GolangCi-Lint
72+
uses: golangci/[email protected]
73+
with:
74+
version: latest
75+
skip-build-cache: true

.github/workflows/release.yaml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: "New Release"
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: "Tag name in semver format. Example: v0.0.1"
8+
required: true
9+
push:
10+
tags:
11+
- "v[0-9]+.[0-9]+.[0-9]+"
12+
13+
permissions:
14+
contents: write
15+
16+
env:
17+
GO: "1.17"
18+
19+
jobs:
20+
bump-version:
21+
if: github.event_name == 'workflow_dispatch'
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v3
26+
with:
27+
fetch-depth: 0
28+
29+
- name: Configure Git
30+
run: |
31+
git config user.name "sv-tools-bot"
32+
git config user.email "[email protected]"
33+
git fetch --all
34+
35+
- name: Create Tag
36+
run: |
37+
docker run --rm -v $PWD:/mount -w /mount svtools/bumptag:latest ${{ github.event.inputs.version }}
38+
39+
- name: Push Tag
40+
run: git push origin --tags
41+
42+
release-cli:
43+
if: github.event_name == 'push'
44+
runs-on: ubuntu-latest
45+
env:
46+
DOCKER_CLI_EXPERIMENTAL: "enabled"
47+
steps:
48+
- name: Checkout code
49+
uses: actions/checkout@v3
50+
51+
- name: Install Go
52+
uses: actions/setup-go@v3
53+
with:
54+
go-version: ${{ env.GO }}
55+
56+
- name: Prepare gpg
57+
run: |
58+
gpgconf --kill gpg-agent
59+
gpg --quiet --batch --yes --decrypt --passphrase="${{ secrets.GPG_PASSPHRASE }}" --output .github/sv-tools-bot.asc .github/sv-tools-bot.asc.gpg
60+
gpg --batch --yes --import .github/sv-tools-bot.asc
61+
rm .github/sv-tools-bot.asc
62+
63+
- name: Allow arm Docker builds # https://github.com/linuxkit/linuxkit/tree/master/pkg/binfmt
64+
run: sudo docker run --privileged linuxkit/binfmt:v0.8
65+
66+
- name: Docker Login
67+
uses: docker/login-action@v2
68+
with:
69+
registry: ghcr.io
70+
username: sv-tools-bot
71+
password: ${{ secrets.BOT_TOKEN }}
72+
73+
- name: Docker Login
74+
uses: docker/login-action@v2
75+
with:
76+
username: svtools
77+
password: ${{ secrets.DOCKER_HUB_TOKEN }}
78+
79+
- name: Run GoReleaser
80+
uses: goreleaser/goreleaser-action@v3
81+
with:
82+
version: latest
83+
args: release --rm-dist --config .github/goreleaser-cli.yml
84+
env:
85+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
86+
87+
- name: Clear
88+
if: always()
89+
run: rm -f ${HOME}/.docker/config.json
90+
91+
release-lib:
92+
if: github.event_name == 'push'
93+
runs-on: ubuntu-latest
94+
steps:
95+
- name: Checkout code
96+
uses: actions/checkout@v3
97+
98+
- name: Install Go
99+
uses: actions/setup-go@v3
100+
with:
101+
go-version: ${{ env.GO }}
102+
103+
- name: Run GoReleaser
104+
uses: goreleaser/goreleaser-action@v3
105+
with:
106+
version: latest
107+
args: release --rm-dist --config .github/goreleaser-lib.yml
108+
env:
109+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Binaries for programs and plugins
2+
*.exe
3+
*.exe~
4+
*.dll
5+
*.so
6+
*.dylib
7+
8+
# Test binary, built with `go test -c`
9+
*.test
10+
11+
# Output of the go coverage tool, specifically when used with LiteIDE
12+
*.out
13+
14+
# Dependency directories (remove the comment below to include it)
15+
# vendor/
16+
17+
.github/Brewfile.lock.json

0 commit comments

Comments
 (0)