Skip to content

Commit 6f7c37a

Browse files
authored
Merge pull request #2 from rog-golang-buddies/update-from-template
Update from template
2 parents 8f4552a + 924a1df commit 6f7c37a

23 files changed

+687
-38
lines changed

.github/dependabot.yml

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

.github/pull_request_template.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
## Description
2+
3+
_Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change_
4+
5+
Fixes # (issue)
6+
Dependent # (issue)
7+
## Current status
8+
9+
- [ ] Waiting for review
10+
- [ ] Waiting for comment resolution
11+
- [ ] Waiting for merge
12+
- [ ] Draft
13+
- [ ] Trivial PR (nominal cosmetic/typo/whitespace changes)
14+
15+
## Semantic Versioning
16+
Please delete options that are not relevant. Ensure same has been covered in the commit message as well.
17+
18+
- This is a `fix` change
19+
- This is a `feat` change
20+
- This is a `BREAKING CHANGE`
21+
22+
## Type of change
23+
24+
Please delete options that are not relevant.
25+
26+
- Bug fix (non-breaking change which fixes an issue)
27+
- New feature (non-breaking change which adds functionality)
28+
- Breaking change (fix or feature that would cause existing functionality to not work as expected)
29+
- This change requires a documentation update
30+
31+
## How Has This Been Tested?
32+
33+
_Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration_
34+
35+
### Automated
36+
37+
### Manual
38+
39+
## Checklist:
40+
- [ ] My commit message mentions fix, feat, BREAKING CHANGE accordingly to increase the semantic versioning
41+
- [ ] My code follows the style guidelines of this project
42+
- [ ] I have performed a self-review of my own code
43+
- [ ] I have commented my code, particularly in hard-to-understand areas
44+
- [ ] I have made corresponding changes to the documentation
45+
- [ ] I have checked my code/docs and corrected any misspellings

.github/workflows/gitleaks.yml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
1-
name: Gitleaks
2-
3-
on: [pull_request, push, workflow_dispatch]
4-
1+
name: gitleaks
2+
on: [push]
53
jobs:
64
gitleaks:
7-
name: Secret Scan
85
runs-on: ubuntu-latest
96
steps:
10-
- name: Check out the repo
7+
- name: Checkout
118
uses: actions/checkout@v2
129
- name: Run gitleaks
1310
run: docker run -v ${{ github.workspace }}:/path zricethezav/gitleaks:latest detect -v --source="/path" --redact
14-
1511
run-if-failed:
16-
name: Github Security Report (if gitleaks job fails)
12+
name: gen-report (if gitleaks fails)
1713
runs-on: ubuntu-latest
1814
needs: [gitleaks]
1915
if: always() && (needs.gitleaks.result == 'failure')
2016
permissions:
2117
security-events: write
2218
steps:
23-
- name: Check out the repo
19+
- name: Checkout
2420
uses: actions/checkout@v2
2521
- name: Generate gitleaks SARIF file
2622
# Exit 0 so we can get the failed report results from this step.

.github/workflows/golangci-lint.yml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
name: golangci-lint
2-
on:
3-
push:
4-
pull_request:
2+
on: [push]
53
permissions:
64
contents: read
75
# Optional: allow read access to pull request. Use with `only-new-issues` option.
86
# pull-requests: read
97
jobs:
10-
golangci:
11-
name: lint
8+
lint:
129
runs-on: ubuntu-latest
1310
steps:
1411
- uses: actions/setup-go@v3
1512
with:
1613
go-version: 1.17
17-
- uses: actions/checkout@v3
18-
- name: golangci-lint
14+
- name: Checkout
15+
uses: actions/checkout@v3
16+
- name: Run linters
1917
uses: golangci/golangci-lint-action@v3
2018
with:
2119
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version

.github/workflows/mkdocs.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: mkdocs
2+
on:
3+
push:
4+
branches:
5+
- main
6+
jobs:
7+
deploy:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v2
12+
- name: Setup Python
13+
uses: actions/setup-python@v2
14+
with:
15+
python-version: 3.x
16+
- name: Install mkdocs-material
17+
run: pip install mkdocs-material
18+
- name: Publish to gh-pages
19+
run: mkdocs gh-deploy --force

.github/workflows/release.yml

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,49 @@
1-
name: Release Package
1+
name: release
22
on:
33
push:
44
branches:
55
- main
66
jobs:
7-
build:
7+
semantic-release:
88
runs-on: ubuntu-latest
99
strategy:
1010
matrix:
1111
node-version:
1212
- 16.x
1313
steps:
14-
- name: Checkout
14+
-
15+
name: Checkout
1516
uses: actions/checkout@v3
1617
with:
1718
fetch-depth: 0
18-
- name: Release
19+
-
20+
name: Release
1921
env:
2022
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2123
run: npx semantic-release
24+
goreleaser:
25+
runs-on: ubuntu-latest
26+
needs: semantic-release
27+
steps:
28+
-
29+
name: Checkout
30+
uses: actions/checkout@v3
31+
with:
32+
fetch-depth: 0
33+
-
34+
name: Setup Go
35+
uses: actions/setup-go@v3
36+
with:
37+
go-version: "1.18.0"
38+
-
39+
name: Run GoReleaser
40+
uses: goreleaser/goreleaser-action@v3
41+
with:
42+
# either 'goreleaser' (default) or 'goreleaser-pro'
43+
distribution: goreleaser
44+
version: latest
45+
args: release -f .goreleaser.yaml --rm-dist
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
# Your GoReleaser Pro key, if you are using the 'goreleaser-pro' distribution
49+
# GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}

.github/workflows/tests.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: tests
2+
on: [push]
3+
jobs:
4+
test:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- name: Checkout
8+
uses: actions/checkout@v2
9+
- name: Setup Go
10+
uses: actions/setup-go@v2
11+
with:
12+
go-version: 1.18
13+
- name: Go Test
14+
run: go test -v ./...

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*.dll
55
*.so
66
*.dylib
7+
bin/
78

89
# Test binary, built with `go test -c`
910
*.test
@@ -14,4 +15,9 @@
1415
# Dependency directories (remove the comment below to include it)
1516
# vendor/
1617

17-
bin/
18+
# Code editor personal settings
19+
.vscode/
20+
.idea/
21+
22+
# Other
23+
.DS_Store

.goreleaser.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# This is an example .goreleaser.yml file with some sensible defaults.
2+
# Make sure to check the documentation at https://goreleaser.com
3+
4+
# The project name is used in the name of the Brew formula, archives, etc. If none is given, it will be inferred
5+
# from the name of the GitHub, GitLab, or Gitea release.
6+
# project_name: golang-template-repository
7+
before:
8+
hooks:
9+
# You may remove this if you don't use go modules.
10+
- go mod tidy
11+
# you may remove this if you don't need go generate
12+
- go generate ./...
13+
builds:
14+
- env: [CGO_ENABLED=0]
15+
goos:
16+
- linux
17+
- windows
18+
- darwin
19+
goarch:
20+
- amd64
21+
- arm64
22+
# ID of the build.
23+
# Defaults to the binary name, uncomment line below if needed
24+
# id: "golang-template-repository"
25+
dir: .
26+
main: ./cmd
27+
# uncomment this line to build binary at specific location# Binary name.
28+
# Can be a path (e.g. `bin/app`) to wrap the binary in a directory.
29+
# Default is the name of the project directory.
30+
# binary: ./bin/app
31+
archives:
32+
- replacements:
33+
darwin: Darwin
34+
linux: Linux
35+
windows: Windows
36+
386: i386
37+
amd64: x86_64
38+
checksum:
39+
name_template: 'checksums.txt'
40+
snapshot:
41+
name_template: "{{ incpatch .Version }}-next"
42+
changelog:
43+
sort: asc
44+
filters:
45+
exclude:
46+
- '^docs:'
47+
- '^test:'

.pre-commit-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ repos:
1212
rev: v1.47.2
1313
hooks:
1414
- id: golangci-lint
15+
- repo: https://github.com/zricethezav/gitleaks
16+
rev: v8.8.12
17+
hooks:
18+
- id: gitleaks
1519

1620
ci:
1721
autofix_commit_msg: |

Dockerfile

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
1-
FROM golang:1.18 as build
2-
WORKDIR /go/src/app
1+
FROM golang:1.18-alpine as builder
2+
3+
RUN apk update && apk upgrade && \
4+
apk add --no-cache make bash
5+
6+
WORKDIR /src
37
COPY . .
4-
RUN mkdir -p /go/bin && go build -ldflags="-w -s" -o /go/bin/app ./...
8+
9+
# Build executable
10+
RUN make build
511

612
# Using a distroless image from https://github.com/GoogleContainerTools/distroless
7-
# Image sourced from https://console.cloud.google.com/gcr/images/distroless/global/static
813
FROM gcr.io/distroless/static:nonroot
9-
COPY --from=build /go/bin/app /
10-
# numeric version of user nonroot:nonroot provided in image
14+
15+
# Copy executable from builder image
16+
COPY --from=builder /src/bin/app /
17+
18+
# Numeric version of user nonroot:nonroot provided in image
1119
USER 65532:65532
20+
21+
# Run the executable
1222
CMD ["/app"]

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
SHELL=/bin/bash -e -o pipefail
22
PWD = $(shell pwd)
3+
GO_BUILD= go build
4+
GOFLAGS= CGO_ENABLED=0
35

46
## help: Print this help message
57
.PHONY: help
@@ -37,4 +39,4 @@ fmt:
3739
## build: Build binary into bin/ directory
3840
.PHONY: build
3941
build:
40-
go build -ldflags="-w -s" -o bin/app ./...
42+
$(GOFLAGS) $(GO_BUILD) -a -v -ldflags="-w -s" -o bin/app cmd/main.go

0 commit comments

Comments
 (0)