-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Add magefile, ko and goreleaser (#14)
* Add serviceMonitor to helm chart * Add support for magefile * Update release github action * Update CI for add new env vars * Test github action for mage release * Update magefile for ko login * Test with Github Actions for magefile * Add some testing flows for magefile * Test release CI * More test for all platform supports * Add RELEASE_TOKEN for creating release on GH * fix: Add RELEASE_TOKEN for creating release on GH * Test with ko-goreleaser-magefile stack again * Update github workflows for verify and release flows --------- Co-authored-by: alperencelik <[email protected]>
- Loading branch information
1 parent
de2a0a8
commit efb9830
Showing
14 changed files
with
680 additions
and
32 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 |
---|---|---|
@@ -1,33 +1,38 @@ | ||
name: docker-build | ||
name: Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- "main" | ||
|
||
env: | ||
TEST_TAG: alperencelik/kubemox:test | ||
LATEST_TAG: alperencelik/kubemox:latest | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
docker: | ||
release: | ||
permissions: | ||
packages: write | ||
contents: write | ||
id-token: write | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.21 | ||
|
||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
- name: Build and push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
platforms: linux/amd64,linux/arm64 | ||
push: true | ||
tags: ${{ env.LATEST_TAG }} | ||
|
||
- name: Set environment variables | ||
run: | | ||
echo "BUILD_IMAGE=golang:1.21" >> $GITHUB_ENV | ||
echo "KO_DOCKER_REPO=alperencelik/kubemox" >> $GITHUB_ENV | ||
- name: Run mage.go Release | ||
run: go run mage.go Release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.RELEASE_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: verify | ||
|
||
on: | ||
pull_request: | ||
types: [opened, edited, synchronize, reopened] | ||
branches: | ||
- main | ||
|
||
jobs: | ||
verify: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.21 | ||
|
||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Run mage.go | ||
run: go run mage.go |
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,100 @@ | ||
linters-settings: | ||
errcheck: | ||
ignore: github.com/go-kit/log:.* | ||
dupl: | ||
threshold: 100 | ||
funlen: | ||
lines: -1 # the number of lines (code + empty lines) is not a right metric and leads to code without empty line or one-liner. | ||
statements: 50 | ||
goconst: | ||
min-len: 2 | ||
min-occurrences: 3 | ||
gocritic: | ||
enabled-tags: | ||
- diagnostic | ||
- experimental | ||
- opinionated | ||
- performance | ||
- style | ||
gocyclo: | ||
min-complexity: 15 | ||
gofmt: | ||
rewrite-rules: | ||
- pattern: 'interface{}' | ||
replacement: 'any' | ||
goimports: | ||
local-prefixes: github.com/golangci/golangci-lint | ||
gomnd: | ||
# don't include the "operation" and "assign" | ||
checks: | ||
- argument | ||
- case | ||
- condition | ||
- return | ||
ignored-numbers: | ||
- '0' | ||
- '1' | ||
- '2' | ||
- '3' | ||
ignored-functions: | ||
- strings.SplitN | ||
|
||
govet: | ||
check-shadowing: true | ||
settings: | ||
printf: | ||
funcs: | ||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof | ||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf | ||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf | ||
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf | ||
lll: | ||
line-length: 140 | ||
misspell: | ||
locale: US | ||
nolintlint: | ||
allow-unused: false # report any unused nolint directives | ||
require-explanation: false # don't require an explanation for nolint directives | ||
require-specific: false # don't require nolint directives to be specific about which linter is being skipped | ||
revive: | ||
rules: | ||
- name: unexported-return | ||
disabled: true | ||
- name: unused-parameter | ||
|
||
linters: | ||
disable-all: true | ||
enable: | ||
- bodyclose | ||
- dogsled | ||
- dupl | ||
- errcheck | ||
- exportloopref | ||
- gochecknoinits | ||
- goconst | ||
- gocritic | ||
- gocyclo | ||
- gofmt | ||
- goimports | ||
- goprintffuncname | ||
- gosec | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
- lll | ||
- misspell | ||
- nakedret | ||
- nolintlint | ||
- revive | ||
- staticcheck | ||
- stylecheck | ||
- typecheck | ||
- unconvert | ||
- unparam | ||
- unused | ||
- whitespace | ||
|
||
run: | ||
timeout: 5m | ||
skip-dirs: | ||
- test # test 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,101 @@ | ||
project_name: kubemox | ||
|
||
before: | ||
hooks: | ||
- go mod tidy | ||
- /bin/bash -c 'if [ -n "$(git --no-pager diff --exit-code go.mod go.sum)" ]; then exit 1; fi' | ||
|
||
builds: | ||
- id: kubemox | ||
binary: kubemox | ||
main: cmd/main.go | ||
env: | ||
- CGO_ENABLED=0 | ||
flags: | ||
- -trimpath | ||
ldflags: | ||
- -extldflags "-static" | ||
- -s | ||
- -w | ||
goos: | ||
- darwin | ||
- linux | ||
- windows | ||
goarch: | ||
- amd64 | ||
- arm | ||
- arm64 | ||
ignore: | ||
- goos: openbsd | ||
goarch: arm | ||
goarm: 6 | ||
mod_timestamp: '{{ .CommitTimestamp }}' | ||
|
||
kos: | ||
- id: kubemox-image | ||
build: kubemox | ||
main: ./cmd/... | ||
base_image: ghcr.io/distroless/static:latest | ||
platforms: | ||
- all | ||
ldflags: | ||
- -extldflags "-static" | ||
- -s | ||
- -w | ||
tags: | ||
- latest | ||
- '{{ .Tag }}' | ||
env: | ||
- CGO_ENABLED=0 | ||
flags: | ||
- -trimpath | ||
sbom: none | ||
bare: true | ||
preserve_import_paths: false | ||
base_import_paths: false | ||
|
||
archives: | ||
- id: with-version | ||
name_template: >- | ||
{{ .ProjectName }}_ | ||
{{- .Version }}_ | ||
{{- title .Os }}_ | ||
{{- if eq .Arch "amd64" }}x86_64 | ||
{{- else if eq .Arch "386" }}i386 | ||
{{- else }}{{ .Arch }}{{ end }} | ||
format: tar.gz | ||
format_overrides: | ||
- goos: windows | ||
format: zip | ||
files: | ||
- README.md | ||
- id: without-version | ||
name_template: >- | ||
{{ .ProjectName }}_ | ||
{{- title .Os }}_ | ||
{{- if eq .Arch "amd64" }}x86_64 | ||
{{- else if eq .Arch "386" }}i386 | ||
{{- else }}{{ .Arch }}{{ end }} | ||
format: tar.gz | ||
format_overrides: | ||
- goos: windows | ||
format: zip | ||
files: | ||
- README.md | ||
|
||
checksum: | ||
name_template: '{{ .ProjectName }}_{{ .Version }}_checksums.txt' | ||
|
||
snapshot: | ||
name_template: SNAPSHOT-{{ .Commit }} | ||
|
||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- '^docs:' | ||
- '^test:' | ||
- '^demo:' | ||
- 'README' | ||
- Merge pull request | ||
- Merge branch |
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 @@ | ||
defaultBaseImage: ghcr.io/distroless/static:latest | ||
|
||
builds: | ||
- id: kubemox | ||
dir: cmd | ||
main: main.go | ||
env: | ||
- CGO_ENABLED=0 | ||
ldflags: | ||
- -extldflags "-static" | ||
- -s | ||
- -w | ||
- "{{ .Env.LDFLAGS }}" | ||
sbom: none |
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,65 @@ | ||
apiVersion: proxmox.alperen.cloud/v1alpha1 | ||
kind: VirtualMachineSet | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: virtualmachineset | ||
app.kubernetes.io/instance: virtualmachineset-sample | ||
app.kubernetes.io/part-of: kubemox | ||
app.kubernetes.io/managed-by: kustomize | ||
app.kubernetes.io/created-by: kubemox | ||
name: kubernetes-master | ||
spec: | ||
# Number of VMs to be created | ||
replicas: 1 | ||
nodeName: lowtower | ||
template: | ||
# Name of the template to be cloned | ||
name: fedora-template | ||
# CPU cores to be allocated to the VM | ||
cores: 4 | ||
# CPU sockets to be allocated to the VM | ||
socket: 1 | ||
# Memory to be allocated to the VM | ||
memory: 4096 # As MB | ||
# Disk used by the VM | ||
disk: | ||
- storage: nvme | ||
size: 50 # As GB | ||
type: scsi | ||
# Network interfaces used by the VM | ||
network: | ||
- model: virtio | ||
bridge: vmbr0 | ||
--- | ||
apiVersion: proxmox.alperen.cloud/v1alpha1 | ||
kind: VirtualMachineSet | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: virtualmachineset | ||
app.kubernetes.io/instance: virtualmachineset-sample | ||
app.kubernetes.io/part-of: kubemox | ||
app.kubernetes.io/managed-by: kustomize | ||
app.kubernetes.io/created-by: kubemox | ||
name: kubernetes-worker | ||
spec: | ||
# Number of VMs to be created | ||
replicas: 2 | ||
nodeName: lowtower | ||
template: | ||
# Name of the template to be cloned | ||
name: fedora-template | ||
# CPU cores to be allocated to the VM | ||
cores: 8 | ||
# CPU sockets to be allocated to the VM | ||
socket: 1 | ||
# Memory to be allocated to the VM | ||
memory: 32768 # As MB | ||
# Disk used by the VM | ||
disk: | ||
- storage: nvme | ||
size: 50 # As GB | ||
type: scsi | ||
# Network interfaces used by the VM | ||
network: | ||
- model: virtio | ||
bridge: vmbr0 |
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.