Skip to content

Commit

Permalink
chore(vault-kubernetes-kms): add boilerplate code
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Morelly committed Jan 30, 2024
1 parent 4920922 commit f8e4165
Show file tree
Hide file tree
Showing 56 changed files with 1,458 additions and 2,426 deletions.
28 changes: 18 additions & 10 deletions .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ on:
push:
tags:
- '*'

pull_request:

permissions:
contents: write
packages: write
Expand All @@ -20,35 +21,42 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
-
name: Set up Go
-
uses: actions/setup-go@v5
with:
go-version: 1.19
go-version: '1.20'
cache: false
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

-
name: ghcr-login
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
# if tag release
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
if: startsWith(github.ref, 'refs/tags/v')
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# if no tag test release build
-
name: Run GoReleaser skip publishing
uses: goreleaser/goreleaser-action@v5
if: "!startsWith(github.ref, 'refs/tags/v')"
with:
version: latest
args: release --snapshot
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9 changes: 7 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ on:
- master
pull_request:

permissions:
contents: read
pull-requests: read
checks: write

jobs:
golangci:
name: lint
Expand All @@ -16,12 +21,12 @@ jobs:

- uses: actions/setup-go@v5
with:
go-version: '1.19'
go-version: '1.20'

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.50.0
version: v1.54.2
args: -c .golang-ci.yml -v --timeout=5m
env:
GO111MODULES: off
26 changes: 12 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
name: Test and coverage

on: [push, pull_request]
on:
pull_request:

jobs:
test:
strategy:
matrix:
go-version: [1.19.x]
os: [ubuntu-latest, macos-latest, windows-latest]

runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2

- run: go generate -tags tools tools/tools.go

- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
go-version: '1.20'
cache: false

- name: go get
run: go get ./...

- name: go mod tidy
run: go mod tidy

- name: Run coverage
run: go test -race -coverprofile="coverage.out" -covermode=atomic ./...
run: |
gotestsum -- -v -race -coverprofile="coverage.out" -covermode=atomic ./...
env:
# https://github.com/testcontainers/testcontainers-go/issues/1782
TESTCONTAINERS_RYUK_DISABLED: true

- name: Upload coverage to Codecov
if: matrix.os == 'ubuntu-latest'
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ coverage.out
/dist
.envrc
manpages/
dist/
dist/
nohup.out
42 changes: 0 additions & 42 deletions .gitlab-ci.yml

This file was deleted.

7 changes: 6 additions & 1 deletion .golang-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,9 @@ linters:
- wastedassign
- exhaustruct
- nolintlint
- wrapcheck
- wrapcheck
- depguard
- gomnd
- goerr113
- gochecknoglobals

71 changes: 10 additions & 61 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
env:
- GO111MODULE=on
- CGO_ENABLED=0

before:
hooks:
- ./scripts/manpages.sh
- ./scripts/completions.sh

builds:
-
binary: vault-kubernetes-kms
ldflags: -s -w -X main.version={{ .Version }}
ldflags: -s -w -X cmd/main.version={{ .Version }}
goos:
- linux
- darwin
goarch:
- amd64
- arm64

archives:
-
Expand All @@ -25,10 +17,13 @@ archives:
format_overrides:
- goos: windows
format: zip
replacements:
darwin: Darwin
linux: Linux
amd64: x86_64
name_template: >-
{{- .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end -}}

nfpms:
- builds:
Expand All @@ -37,39 +32,16 @@ nfpms:
homepage: https://github.com/FalcoSuessgott/vault-kubernetes-kms
maintainer: "Tom Morelly <tommorelly@gmail.com>"
description: "A general purpose golang CLI template for Github and Gitlab"
license: GPL-3.0
formats:
- apk
- deb
- rpm
bindir: /usr/bin
contents:
- src: ./manpages/vault-kubernetes-kms.1.gz
dst: /usr/share/man/man1/vault-kubernetes-kms.1.gz
file_info:
mode: 0644
- src: ./completions/vault-kubernetes-kms.bash
dst: /usr/share/bash-completion/completions/vault-kubernetes-kms
file_info:
mode: 0644
- src: ./completions/vault-kubernetes-kms.fish
dst: /usr/share/fish/vendor_completions.d/vault-kubernetes-kms.fish
file_info:
mode: 0644
- src: ./completions/vault-kubernetes-kms.zsh
dst: /usr/share/zsh/vendor-completions/_vault-kubernetes-kms
file_info:
mode: 0644
license: MIT

dockers:
- image_templates:
- 'FalcoSuessgott/{{.ProjectName}}:{{ .Tag }}-amd64'
- 'ghcr.io/FalcoSuessgott/{{.ProjectName}}:{{ .Tag }}-amd64'
dockerfile: Dockerfile
use: buildx
build_flag_templates:
- "--pull"
- "--label=io.artifacthub.package.readme-url=https://raw.githubusercontent.com/FalcoSuessgott/vault-kubernetes-kms/master/README.md"
- "--label=io.artifacthub.package.readme-url=https://raw.githubusercontent.com/FalcoSuessgott/vault-kubernetes-kms/main/README.md"
- "--label=io.artifacthub.package.maintainers=[{\"name\":\"Tom Morelly\",\"email\":\"tommorelly@gmail.com\"}]"
- "--label=io.artifacthub.package.license=MIT"
- "--label=org.opencontainers.image.description=A general purpose golang CLI template for Github and Gitlab"
Expand All @@ -79,43 +51,20 @@ dockers:
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.source={{.GitURL}}"
- "--platform=linux/amd64"
- image_templates:
- 'FalcoSuessgott/{{.ProjectName}}:{{ .Tag }}-arm64'
- 'ghcr.io/FalcoSuessgott/{{.ProjectName}}:{{ .Tag }}-arm64'
dockerfile: Dockerfile
use: buildx
build_flag_templates:
- "--pull"
- "--label=io.artifacthub.package.readme-url=https://raw.githubusercontent.com/FalcoSuessgott/vault-kubernetes-kms/master/README.md"
- "--label=io.artifacthub.package.logo-url=https://raw.githubusercontent.com/FalcoSuessgott/vault-kubernetes-kms/master/www/static/images/logo.png"
- "--label=io.artifacthub.package.maintainers=[{\"name\":\"Tom Morelly\",\"email\":\"tommorelly@gmail.com\"}]"
- "--label=io.artifacthub.package.license=MIT"
- "--label=org.opencontainers.image.description=A general purpose golang CLI template for Github and Gitlab"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.name={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--label=org.opencontainers.image.source={{.GitURL}}"
- "--platform=linux/arm64"
goarch: arm64

docker_manifests:
- name_template: 'FalcoSuessgott/{{.ProjectName}}:{{ .Tag }}'
image_templates:
- 'FalcoSuessgott/{{.ProjectName}}:{{ .Tag }}-amd64'
- 'FalcoSuessgott/{{.ProjectName}}:{{ .Tag }}-arm64'
- name_template: 'ghcr.io/FalcoSuessgott/{{.ProjectName}}:{{ .Tag }}'
image_templates:
- 'ghcr.io/FalcoSuessgott/{{.ProjectName}}:{{ .Tag }}-amd64'
- 'ghcr.io/FalcoSuessgott/{{.ProjectName}}:{{ .Tag }}-arm64'
- name_template: 'FalcoSuessgott/{{.ProjectName}}:latest'
image_templates:
- 'FalcoSuessgott/{{.ProjectName}}:{{ .Tag }}-amd64'
- 'FalcoSuessgott/{{.ProjectName}}:{{ .Tag }}-arm64'
- name_template: 'ghcr.io/FalcoSuessgott/{{.ProjectName}}:latest'
image_templates:
- 'ghcr.io/FalcoSuessgott/{{.ProjectName}}:{{ .Tag }}-amd64'
- 'ghcr.io/FalcoSuessgott/{{.ProjectName}}:{{ .Tag }}-arm64'

checksum:
name_template: "checksums.txt"
Expand Down
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
FROM alpine:3.19

COPY vault-kubernetes-kms /usr/bin/vault-kubernetes-kms

ENTRYPOINT ["/usr/bin/vault-kubernetes-kms"]
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 FalcoSuessgott
Copyright (c) 2024 FalcoSuessgott

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Loading

0 comments on commit f8e4165

Please sign in to comment.