-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Bryce Palmer <everettraven@gmail.com>
- Loading branch information
1 parent
06a78bf
commit bf27c29
Showing
19 changed files
with
2,387 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
# Ignore everything | ||
* | ||
|
||
# But not these files: | ||
!.gitignore | ||
!*.mod | ||
!*.sum | ||
!README.md | ||
!Variables.mk | ||
!variables.env | ||
|
||
*tmp.mod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Project Development Dependencies. | ||
|
||
This is directory which stores Go modules with pinned buildable package that is used within this repository, managed by https://github.com/bwplotka/bingo. | ||
|
||
* Run `bingo get` to install all tools having each own module file in this directory. | ||
* Run `bingo get <tool>` to install <tool> that have own module file in this directory. | ||
* For Makefile: Make sure to put `include .bingo/Variables.mk` in your Makefile, then use $(<upper case tool name>) variable where <tool> is the .bingo/<tool>.mod. | ||
* For shell: Run `source .bingo/variables.env` to source all environment variable for each tool. | ||
* For go: Import `.bingo/variables.go` to for variable names. | ||
* See https://github.com/bwplotka/bingo or -h on how to add, remove or change binaries dependencies. | ||
|
||
## Requirements | ||
|
||
* Go 1.14+ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Auto generated binary variables helper managed by https://github.com/bwplotka/bingo v0.8. DO NOT EDIT. | ||
# All tools are designed to be build inside $GOBIN. | ||
BINGO_DIR := $(dir $(lastword $(MAKEFILE_LIST))) | ||
GOPATH ?= $(shell go env GOPATH) | ||
GOBIN ?= $(firstword $(subst :, ,${GOPATH}))/bin | ||
GO ?= $(shell which go) | ||
|
||
# Below generated variables ensure that every time a tool under each variable is invoked, the correct version | ||
# will be used; reinstalling only if needed. | ||
# For example for golangci-lint variable: | ||
# | ||
# In your main Makefile (for non array binaries): | ||
# | ||
#include .bingo/Variables.mk # Assuming -dir was set to .bingo . | ||
# | ||
#command: $(GOLANGCI_LINT) | ||
# @echo "Running golangci-lint" | ||
# @$(GOLANGCI_LINT) <flags/args..> | ||
# | ||
GOLANGCI_LINT := $(GOBIN)/golangci-lint-v1.55.2 | ||
$(GOLANGCI_LINT): $(BINGO_DIR)/golangci-lint.mod | ||
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies. | ||
@echo "(re)installing $(GOBIN)/golangci-lint-v1.55.2" | ||
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=golangci-lint.mod -o=$(GOBIN)/golangci-lint-v1.55.2 "github.com/golangci/golangci-lint/cmd/golangci-lint" | ||
|
||
GORELEASER := $(GOBIN)/goreleaser-v1.22.0 | ||
$(GORELEASER): $(BINGO_DIR)/goreleaser.mod | ||
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies. | ||
@echo "(re)installing $(GOBIN)/goreleaser-v1.22.0" | ||
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=goreleaser.mod -o=$(GOBIN)/goreleaser-v1.22.0 "github.com/goreleaser/goreleaser" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module _ // Fake go.mod auto-created by 'bingo' for go -moddir compatibility with non-Go projects. Commit this file, together with other .mod files. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT | ||
|
||
go 1.21.3 | ||
|
||
require github.com/golangci/golangci-lint v1.55.2 // cmd/golangci-lint |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT | ||
|
||
go 1.21.3 | ||
|
||
require github.com/goreleaser/goreleaser v1.22.0 |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Auto generated binary variables helper managed by https://github.com/bwplotka/bingo v0.8. DO NOT EDIT. | ||
# All tools are designed to be build inside $GOBIN. | ||
# Those variables will work only until 'bingo get' was invoked, or if tools were installed via Makefile's Variables.mk. | ||
GOBIN=${GOBIN:=$(go env GOBIN)} | ||
|
||
if [ -z "$GOBIN" ]; then | ||
GOBIN="$(go env GOPATH)/bin" | ||
fi | ||
|
||
|
||
GOLANGCI_LINT="${GOBIN}/golangci-lint-v1.55.2" | ||
|
||
GORELEASER="${GOBIN}/goreleaser-v1.22.0" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: lint | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
merge_group: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version-file: "go.mod" | ||
|
||
- name: Run golangci linting checks | ||
run: make lint GOLANGCI_LINT_ARGS="--out-format github-actions" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: release | ||
|
||
on: | ||
workflow_dispatch: | ||
merge_group: | ||
push: | ||
branches: | ||
- 'main' | ||
tags: | ||
- 'v*' | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
goreleaser: | ||
name: goreleaser | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code into the Go module directory | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Install Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version-file: "go.mod" | ||
|
||
- name: Docker Login | ||
if: ${{ github.event_name != 'pull_request' }} | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Set the release related variables | ||
run: | | ||
if [[ $GITHUB_REF == refs/tags/* ]]; then | ||
# Release tags. | ||
echo IMAGE_TAG="${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | ||
echo GORELEASER_ARGS="--clean" >> $GITHUB_ENV | ||
echo ENABLE_RELEASE_PIPELINE=true >> $GITHUB_ENV | ||
elif [[ $GITHUB_REF == refs/heads/* ]]; then | ||
# Branch build. | ||
echo IMAGE_TAG="$(echo "${GITHUB_REF#refs/heads/}" | sed -r 's|/+|-|g')" >> $GITHUB_ENV | ||
echo GORELEASER_ARGS="--clean --skip-validate" >> $GITHUB_ENV | ||
elif [[ $GITHUB_REF == refs/pull/* ]]; then | ||
# PR build. | ||
echo IMAGE_TAG="pr-$(echo "${GITHUB_REF}" | sed -E 's|refs/pull/([^/]+)/?.*|\1|')" >> $GITHUB_ENV | ||
else | ||
echo IMAGE_TAG="$(git describe --tags --always)" >> $GITHUB_ENV | ||
fi | ||
- name: Run goreleaser | ||
run: make release | ||
env: | ||
GITHUB_TOKEN: ${{ github.token }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: unit | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
merge_group: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
unit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: actions/setup-go@v4 | ||
with: | ||
go-version-file: "go.mod" | ||
|
||
- name: Run unit tests | ||
run: make unit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
buoy | ||
buoy | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
before: | ||
hooks: | ||
- go mod tidy | ||
- go mod download | ||
builds: | ||
- id: buoy | ||
main: main.go | ||
binary: buoy | ||
asmflags: "{{ .Env.GO_BUILD_ASMFLAGS }}" | ||
gcflags: "{{ .Env.GO_BUILD_GCFLAGS }}" | ||
ldflags: "{{ .Env.GO_BUILD_LDFLAGS }}" | ||
mod_timestamp: "{{ .CommitTimestamp }}" | ||
goos: | ||
- linux | ||
- darwin | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
- ppc64le | ||
- s390x | ||
release: | ||
disable: '{{ ne .Env.ENABLE_RELEASE_PIPELINE "true" }}' | ||
changelog: | ||
use: github-native | ||
skip: '{{ ne .Env.ENABLE_RELEASE_PIPELINE "true" }}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,29 @@ | ||
include .bingo/Variables.mk | ||
|
||
export GIT_VERSION ?= $(shell git describe --tags --always --dirty) | ||
export VERSION_PKG ?= $(shell go list -m)/internal/cli | ||
export GO_BUILD_ASMFLAGS ?= all=-trimpath=${PWD} | ||
export GO_BUILD_LDFLAGS ?= -s -w -X "$(VERSION_PKG).version=$(GIT_VERSION)" | ||
export GO_BUILD_GCFLAGS ?= all=-trimpath=${PWD} | ||
|
||
export IMAGE_REPO ?= docker.io/bpalmer/buoy | ||
export IMAGE_TAG ?= devel | ||
|
||
build: | ||
go build -o buoy main.go | ||
go build \ | ||
-asmflags '$(GO_BUILD_ASMFLAGS)' \ | ||
-ldflags '$(GO_BUILD_LDFLAGS)' \ | ||
-gcflags '$(GO_BUILD_GCFLAGS)' \ | ||
-o buoy main.go | ||
|
||
export ENABLE_RELEASE_PIPELINE ?= false | ||
export GORELEASER_ARGS ?= --snapshot --clean | ||
release: $(GORELEASER) | ||
$(GORELEASER) $(GORELEASER_ARGS) | ||
|
||
GOLANGCI_LINT_ARGS ?= | ||
lint: $(GOLANGCI_LINT) | ||
$(GOLANGCI_LINT) run $(GOLANGCI_LINT_ARGS) | ||
unit: | ||
go test ./... | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.