Skip to content

Commit

Permalink
Merge pull request #25 from mgoltzsche/v2_goreleaser
Browse files Browse the repository at this point in the history
Merge master into v2 to enable goreleaser for v2 branch
  • Loading branch information
mgoltzsche authored Oct 18, 2021
2 parents e33800a + 7d0d639 commit 7d3ee40
Show file tree
Hide file tree
Showing 19 changed files with 288 additions and 286 deletions.
45 changes: 0 additions & 45 deletions .github/workflows/release-binary.yml

This file was deleted.

76 changes: 0 additions & 76 deletions .github/workflows/release-image.yml

This file was deleted.

58 changes: 58 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Release

on:
push:
# Publish `master` as Docker `latest` image.
branches:
- master
- v2
- v1

# Publish `v1.2.3` tags as releases.
tags:
- v*

jobs:
push:
runs-on: ubuntu-latest
if: github.event_name == 'push'

steps:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.17

- name: Check out code into the Go module directory
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up qemu
uses: docker/setup-qemu-action@v1
with:
platforms: all

- name: Extract Helm version
id: extract_helm_version
run: |
printf '::set-output name=helm_version::' &&
grep helm\.sh/helm/ go.mod | sed -E -e 's!helm\.sh/helm/v3|\s+|\+.*!!g; s!^v!!' | cut -d " " -f2 | grep -E .+
- name: Build & Test
run: make test check image e2e-test

- name: Log into GitHub registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin

- name: Log into DockerHub registry
run: echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login docker.io -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: v0.182.1
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HELM_VERSION: ${{ steps.extract_helm_version.outputs.helm_version }}
22 changes: 20 additions & 2 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,20 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Set up Go 1.14
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.14
go-version: 1.17

- name: Check out code into the Go module directory
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up qemu
uses: docker/setup-qemu-action@v1
with:
platforms: all

- name: Build
run: make khelm
Expand All @@ -36,3 +43,14 @@ jobs:

- name: e2e test
run: make e2e-test

- name: Extract Helm version
id: extract_helm_version
run: |
printf '::set-output name=helm_version::' &&
grep helm\.sh/helm/ go.mod | sed -E -e 's!helm\.sh/helm/v3|\s+|\+.*!!g; s!^v!!' | cut -d " " -f2 | grep -E .+
- name: Dry-run release
run: make snapshot
env:
HELM_VERSION: ${{ steps.extract_helm_version.outputs.helm_version }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@
/example/**/generated-manifest-without-secrets.yaml
/example/kpt/linkerd/dep
/example/kpt/cache-dependencies/chart/charts

dist/
21 changes: 21 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
linters:
enable:
- gofmt
- govet
- errcheck
- staticcheck
- unused
- gosimple
- structcheck
- varcheck
- ineffassign
- deadcode
- typecheck
- rowserrcheck
- gosec
- unconvert

skip-dirs:
- build
- vendor

90 changes: 90 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
project_name: khelm
dist: ./build/dist
before:
hooks:
- go mod tidy
builds:
- main: ./cmd/khelm
targets:
- linux_amd64
- linux_arm64
- darwin_amd64
- darwin_arm64
env:
- CGO_ENABLED=0
ldflags:
- -s -w -extldflags '-static' -X main.khelmVersion={{.Version}} -X main.helmVersion={{.Env.HELM_VERSION}}
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: '{{ incpatch .Version }}-dev-{{.ShortCommit}}'
changelog:
sort: asc
filters:
exclude:
- '^docs(\([^)]+\))?:'
- '^test(\([^)]+\))?:'
- '^chore(\([^)]+\))?:'
dockers:
- id: khelm-amd64-image
image_templates:
- docker.io/mgoltzsche/khelm:{{.Version}}-amd64
- ghcr.io/mgoltzsche/khelm:{{.Version}}-amd64
use: buildx
dockerfile: Dockerfile
build_flag_templates:
- "--pull"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.title={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--build-arg=KHELM_VERSION={{.Version}}"
- "--build-arg=HELM_VERSION={{.Env.HELM_VERSION}}"
- "--platform=linux/amd64"
- id: khelm-arm64-image
image_templates:
- docker.io/mgoltzsche/khelm:{{.Version}}-arm64v8
- ghcr.io/mgoltzsche/khelm:{{.Version}}-arm64v8
use: buildx
goarch: arm64
dockerfile: Dockerfile
build_flag_templates:
- "--pull"
- "--label=org.opencontainers.image.created={{.Date}}"
- "--label=org.opencontainers.image.title={{.ProjectName}}"
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
- "--label=org.opencontainers.image.version={{.Version}}"
- "--build-arg=KHELM_VERSION={{.Version}}"
- "--build-arg=HELM_VERSION={{.Env.HELM_VERSION}}"
- "--platform=linux/arm64/v8"
docker_manifests:
- id: khelm-multiarch-latest-dockerhub-image
name_template: docker.io/mgoltzsche/khelm:latest
image_templates:
- docker.io/mgoltzsche/khelm:{{.Version}}-amd64
- docker.io/mgoltzsche/khelm:{{.Version}}-arm64v8
- id: khelm-multiarch-latest-ghcr-image
name_template: ghcr.io/mgoltzsche/khelm:latest
image_templates:
- ghcr.io/mgoltzsche/khelm:{{.Version}}-amd64
- ghcr.io/mgoltzsche/khelm:{{.Version}}-arm64v8
- id: khelm-multiarch-major-dockerhub-image
name_template: docker.io/mgoltzsche/khelm:{{.Major}}
image_templates:
- docker.io/mgoltzsche/khelm:{{.Version}}-amd64
- docker.io/mgoltzsche/khelm:{{.Version}}-arm64v8
- id: khelm-multiarch-major-ghcr-image
name_template: ghcr.io/mgoltzsche/khelm:{{.Major}}
image_templates:
- ghcr.io/mgoltzsche/khelm:{{.Version}}-amd64
- ghcr.io/mgoltzsche/khelm:{{.Version}}-arm64v8
- id: khelm-multiarch-dockerhub-image
name_template: docker.io/mgoltzsche/khelm:{{.Version}}
image_templates:
- docker.io/mgoltzsche/khelm:{{.Version}}-amd64
- docker.io/mgoltzsche/khelm:{{.Version}}-arm64v8
- id: khelm-multiarch-ghcr-image
name_template: ghcr.io/mgoltzsche/khelm:{{.Version}}
image_templates:
- ghcr.io/mgoltzsche/khelm:{{.Version}}-amd64
- ghcr.io/mgoltzsche/khelm:{{.Version}}-arm64v8
23 changes: 8 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
FROM golang:1.14-alpine3.12 AS build
RUN apk add --update --no-cache git
ENV GO111MODULE=on CGO_ENABLED=0
COPY go.mod go.sum /go/src/github.com/mgoltzsche/khelm/
WORKDIR /go/src/github.com/mgoltzsche/khelm
RUN go mod download
COPY cmd/khelm /go/src/github.com/mgoltzsche/khelm/cmd/khelm
COPY internal /go/src/github.com/mgoltzsche/khelm/internal
COPY pkg /go/src/github.com/mgoltzsche/khelm/pkg
ARG KHELM_VERSION=dev-build
ARG HELM_VERSION=unknown-version
RUN go build -o khelm -ldflags "-X main.khelmVersion=$KHELM_VERSION -X main.helmVersion=$HELM_VERSION -s -w -extldflags '-static'" ./cmd/khelm && mv khelm /usr/local/bin/

FROM alpine:3.12
FROM alpine:3.14 AS khelm
RUN apk update --no-cache
RUN mkdir /helm && chown root:nobody /helm && chmod 1777 /helm
ENV HELM_REPOSITORY_CONFIG=/helm/repository/repositories.yaml
ENV HELM_REPOSITORY_CACHE=/helm/cache
COPY --from=build /usr/local/bin/khelm /usr/local/bin/khelmfn
COPY khelm /usr/local/bin/khelmfn
ENTRYPOINT ["/usr/local/bin/khelmfn"]

FROM khelm AS test
RUN khelmfn version

FROM khelm
Loading

0 comments on commit 7d3ee40

Please sign in to comment.