-
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.
Merge pull request #1 from juan-lee/goreleaser
Add GoReleaser
- Loading branch information
Showing
8 changed files
with
125 additions
and
14 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,40 @@ | ||
name: build | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- 'v*' | ||
pull_request: | ||
|
||
workflow_dispatch: | ||
|
||
jobs: | ||
nodify: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- name: Setup Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: '1.16' | ||
- name: Docker Login | ||
if: success() && startsWith(github.ref, 'refs/tags/v') | ||
env: | ||
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} | ||
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | ||
run: | | ||
echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin | ||
- name: Run GoReleaser | ||
uses: goreleaser/[email protected] | ||
with: | ||
version: latest | ||
args: release --rm-dist | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.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 |
---|---|---|
|
@@ -23,3 +23,4 @@ testbin/* | |
*.swp | ||
*.swo | ||
*~ | ||
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,47 @@ | ||
before: | ||
hooks: | ||
- go mod tidy | ||
- make TAG={{ .Tag }} release | ||
builds: | ||
- env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- linux | ||
goarch: | ||
- amd64 | ||
checksum: | ||
name_template: '{{ .ProjectName }}_checksums.txt' | ||
dockers: | ||
- image_templates: | ||
- "juanlee/nodify-controller:{{ .Tag }}" | ||
- "juanlee/nodify-controller:latest" | ||
dockerfile: Dockerfile | ||
extra_files: | ||
- go.mod | ||
- go.sum | ||
- main.go | ||
- api | ||
- controllers | ||
- image_templates: | ||
- "juanlee/nodify-daemon:{{ .Tag }}" | ||
- "juanlee/nodify-daemon:latest" | ||
dockerfile: Dockerfile.daemon | ||
extra_files: | ||
- daemon/go.mod | ||
- daemon/go.sum | ||
- daemon/main.go | ||
archives: | ||
- replacements: | ||
linux: Linux | ||
amd64: x86_64 | ||
snapshot: | ||
name_template: "{{ .Tag }}-{{ .ShortCommit }}" | ||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- '^docs:' | ||
- '^test:' | ||
release: | ||
extra_files: | ||
- glob: ./bin/nodify.yaml |
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,7 +1,11 @@ | ||
|
||
# Image URL to use all building/pushing image targets | ||
IMG ?= juanlee/nodify-controller:latest | ||
DAEMON_IMG ?= juanlee/nodify-daemon:latest | ||
TAG ?= dev | ||
REGISTRY ?= juanlee | ||
CONTROLLER_IMG ?= nodify-controller | ||
DAEMON_IMG ?= nodify-daemon | ||
CONTROLLER_URI ?= $(REGISTRY)/$(CONTROLLER_IMG):$(TAG) | ||
DAEMON_URI ?= $(REGISTRY)/$(DAEMON_IMG):$(TAG) | ||
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion) | ||
CRD_OPTIONS ?= "crd:trivialVersions=true,preserveUnknownFields=false" | ||
|
||
|
@@ -37,10 +41,12 @@ install: manifests kustomize | |
uninstall: manifests kustomize | ||
$(KUSTOMIZE) build config/crd | kubectl delete -f - | ||
|
||
set-images: manifests kustomize | ||
cd config/manager && $(KUSTOMIZE) edit set image controller=${CONTROLLER_URI} | ||
cd config/daemon && $(KUSTOMIZE) edit set image daemon=${DAEMON_URI} | ||
|
||
# Deploy controller in the configured Kubernetes cluster in ~/.kube/config | ||
deploy: manifests kustomize | ||
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG} | ||
cd config/daemon && $(KUSTOMIZE) edit set image daemon=${DAEMON_IMG} | ||
deploy: set-images | ||
$(KUSTOMIZE) build config/default | kubectl apply -f - | ||
kubectl rollout -n nodify-system restart deploy/nodify-controller-manager | ||
kubectl rollout -n nodify-system restart daemonset/nodify-nodify | ||
|
@@ -68,13 +74,18 @@ generate: controller-gen | |
|
||
# Build the docker image | ||
docker-build: test | ||
docker build -t ${IMG} . | ||
docker build -t ${DAEMON_IMG} -f Dockerfile.daemon . | ||
docker build -t ${CONTROLLER_URI} . | ||
docker build -t ${DAEMON_URI} -f Dockerfile.daemon . | ||
|
||
# Push the docker image | ||
docker-push: | ||
docker push ${IMG} | ||
docker push ${DAEMON_IMG} | ||
docker push ${CONTROLLER_URI} | ||
docker push ${DAEMON_URI} | ||
|
||
# Release | ||
release: set-images | ||
mkdir -p dist | ||
$(KUSTOMIZE) build config/default > bin/nodify.yaml | ||
|
||
# Download controller-gen locally if necessary | ||
CONTROLLER_GEN = $(shell pwd)/bin/controller-gen | ||
|
@@ -91,6 +102,11 @@ GOLANGCI_LINT = $(shell pwd)/bin/golangci-lint | |
golangci-lint: | ||
$(call go-get-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/[email protected]) | ||
|
||
# Download goreleaser locally if necessary | ||
GORELEASER = $(shell pwd)/bin/goreleaser | ||
goreleaser: | ||
$(call go-get-tool,$(GORELEASER),github.com/goreleaser/[email protected]) | ||
|
||
# go-get-tool will 'go get' any package $2 and install it to $1. | ||
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST)))) | ||
define go-get-tool | ||
|
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
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
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
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