Skip to content

Commit

Permalink
add goreleaser
Browse files Browse the repository at this point in the history
  • Loading branch information
jokestax committed Dec 5, 2024
1 parent 0b59545 commit 31d2a11
Show file tree
Hide file tree
Showing 11 changed files with 108 additions and 65 deletions.
34 changes: 0 additions & 34 deletions .github/workflows/publish-ecr.yaml

This file was deleted.

35 changes: 35 additions & 0 deletions .github/workflows/release-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: release container image
on:
push:
tags:
- '*'
permissions:
packages: write

jobs:
gorelease:
name: build and push kubernetes-toolkit
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Login to Github Container Registry
uses: docker/login-action@v3
with:
registry: "ghcr.io"
username: ${{ github.actor }}
password: ${{ secrets.TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Release container image to Github
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
64 changes: 64 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
version: 2
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- darwin
goarch:
- amd64
- arm
- arm64
tags:
- netgo
flags:
- -trimpath
ldflags:
- -s -w -extldflags "-static"
- -X github.com/konstructio/kubernetes-toolkit/internal/common.Version={{.Version}}

dockers:
- image_templates:
- "ghcr.io/konstructio/kubernetes-toolkit:{{ .Tag }}-amd64"
goos: linux
goarch: amd64
use: buildx
build_flag_templates:
- "--platform=linux/amd64"
- "--label=org.opencontainers.image.title={{ .ProjectName }}"
- "--label=org.opencontainers.image.description={{ .ProjectName }} version {{ .Version }}. See release notes at https://github.com/patrickdappollonio/{{ .ProjectName }}/releases/tag/v{{ .RawVersion }}"
- "--label=org.opencontainers.image.url=https://github.com/konstructio/{{ .ProjectName }}"
- "--label=org.opencontainers.image.source=https://github.com/konstructio/{{ .ProjectName }}"
- "--label=org.opencontainers.image.version={{ .Version }}"
- '--label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}'
- "--label=org.opencontainers.image.revision={{ .FullCommit }}"

- image_templates:
- "ghcr.io/konstructio/kubernetes-toolkit:{{ .Tag }}-arm64"
goos: linux
goarch: arm64
use: buildx
build_flag_templates:
- "--platform=linux/arm64"
- "--label=org.opencontainers.image.title={{ .ProjectName }}"
- "--label=org.opencontainers.image.description={{ .ProjectName }} version {{ .Version }}. See release notes at https://github.com/patrickdappollonio/{{ .ProjectName }}/releases/tag/v{{ .RawVersion }}"
- "--label=org.opencontainers.image.url=https://github.com/konstructio/{{ .ProjectName }}"
- "--label=org.opencontainers.image.source=https://github.com/konstructio/{{ .ProjectName }}"
- "--label=org.opencontainers.image.version={{ .Version }}"
- '--label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}'
- "--label=org.opencontainers.image.revision={{ .FullCommit }}"

docker_manifests:
- name_template: "ghcr.io/konstructio/kubernetes-toolkit:v{{ .RawVersion }}"
image_templates:
- "ghcr.io/konstructio/kubernetes-toolkit:{{ .Tag }}-amd64"
- "ghcr.io/konstructio/kubernetes-toolkit:{{ .Tag }}-arm64"
- name_template: "ghcr.io/konstructio/kubernetes-toolkit:v{{ .Major }}"
image_templates:
- "ghcr.io/konstructio/kubernetes-toolkit:{{ .Tag }}-amd64"
- "ghcr.io/konstructio/kubernetes-toolkit:{{ .Tag }}-arm64"
- name_template: "ghcr.io/konstructio/kubernetes-toolkit:latest"
image_templates:
- "ghcr.io/konstructio/kubernetes-toolkit:{{ .Tag }}-amd64"
- "ghcr.io/konstructio/kubernetes-toolkit:{{ .Tag }}-arm64"

26 changes: 2 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,5 @@
FROM golang:alpine AS builder

ENV GO111MODULE=on \
CGO_ENABLED=0 \
GOOS=linux \
GOARCH=amd64

WORKDIR /build

# Download go dependencies
COPY go.mod .
COPY go.sum .
RUN go mod download

# Copy into the container
COPY . .

# Build the application
RUN go build -o kubernetes-toolkit .

# Build final image using nothing but the binary
FROM alpine:3.17.2

COPY --from=builder /build/kubernetes-toolkit /
COPY kubernetes-toolkit /usr/bin/

# Command to run
ENTRYPOINT ["/kubernetes-toolkit"]
ENTRYPOINT ["/usr/bin/kubernetes-toolkit"]
2 changes: 1 addition & 1 deletion cmd/createSecret.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cmd

import (
"github.com/kubefirst/kubernetes-toolkit/internal/kubernetes"
"github.com/konstructio/kubernetes-toolkit/internal/kubernetes"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/syncEcrToken.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cmd

import (
"github.com/kubefirst/kubernetes-toolkit/internal/kubernetes"
"github.com/konstructio/kubernetes-toolkit/internal/kubernetes"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/waitFor.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"time"

"github.com/hashicorp/vault/api"
"github.com/kubefirst/kubernetes-toolkit/internal/kubernetes"
"github.com/konstructio/kubernetes-toolkit/internal/kubernetes"
"github.com/minio/minio-go/v7"
"github.com/minio/minio-go/v7/pkg/credentials"
log "github.com/sirupsen/logrus"
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/kubefirst/kubernetes-toolkit
module github.com/konstructio/kubernetes-toolkit

go 1.20

Expand Down
2 changes: 1 addition & 1 deletion internal/kubernetes/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"os"
"path/filepath"

"github.com/kubefirst/kubernetes-toolkit/internal/common"
"github.com/konstructio/kubernetes-toolkit/internal/common"
log "github.com/sirupsen/logrus"
"github.com/spf13/afero"
"k8s.io/client-go/kubernetes"
Expand Down
2 changes: 1 addition & 1 deletion internal/kubernetes/ecr.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"fmt"

awsinternal "github.com/kubefirst/kubernetes-toolkit/internal/aws"
awsinternal "github.com/konstructio/kubernetes-toolkit/internal/aws"
log "github.com/sirupsen/logrus"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package main

import "github.com/kubefirst/kubernetes-toolkit/cmd"
import "github.com/konstructio/kubernetes-toolkit/cmd"

func main() {
cmd.Execute()
Expand Down

0 comments on commit 31d2a11

Please sign in to comment.