8000 Add github actions to publish via goreleaser by Amir-Ahmad · Pull Request #1 · Amir-Ahmad/kogen · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Release

on:
workflow_dispatch:
push:
tags:
- "*"

permissions:
contents: write # needed to write releases
packages: write # needed for pushing to ghcr

jobs:
build:
name: Release
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: "1.25"

- name: Run Go tests
shell: bash
run: go test -v ./...

name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64,linux/arm64

name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: '~> v2'
args: release --clean
env:
< 10000 span class='blob-code-inner blob-code-marker ' data-code-marker="+"> GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
41 changes: 41 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build and Test

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build-and-test:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: "1.25"

- name: Run Go tests
shell: bash
run: go test -v ./...

name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64,linux/arm64

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: '~> v2'
args: release --snapshot --clean --skip=archive
52 changes: 52 additions & 0 deletions .goreleaser.yaml
8000
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json

project_name: kogen

version: 2

builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm64
binary: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}"
no_unique_dist_dir: true
ldflags:
- -s -w -X github.com/amir-ahmad/kogen/cmd.version={{.Version}} -X github.com/amir-ahmad/kogen/cmd.commit={{.ShortCommit}} -X github.com/amir-ahmad/kogen/cmd.date={{.Date}}

archives:
- formats: [tar.gz]
name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
format_overrides:
- goos: windows
formats: [zip]

dockers_v2:
- images:
- "ghcr.io/amir-ahmad/kogen"
tags:
- "v{{ .Version }}"
dockerfile: "argo-plugin/Dockerfile"
extra_files:
- "argo-plugin/plugin.yaml"
labels:
"org.opencontainers.image.description": "Kogen is a kubernetes manifest generator."
"org.opencontainers.image.created": "{{.Date}}"
"org.opencontainers.image.name": "{{.ProjectName}}"
"org.opencontainers.image.revision": "{{.FullCommit}}"
"org.opencontainers.image.version": "{{.Version}}"
"org.opencontainers.image.source": "{{.GitURL}}"

snapshot:
version_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
12 changes: 6 additions & 6 deletions Justfile
A0E5
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
@test-all:
RUN_REMOTE=0 gotestsum -f testname ./... -- -count=1

# Build binary for amd64 linux
@build-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o dist/kogen main.go
# Build binary
@build:
goreleaser build --snapshot --clean --single-target

# Build docker image for argo plugin
@docker-build:
docker build -t ghcr.io/amir-ahmad/kogen:scratch -f argo-plugin/Dockerfile .
# Build binary and docker images
build-all:
goreleaser release --snapshot --clean --skip=archive
5 changes: 4 additions & 1 deletion argo-plugin/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
FROM gcr.io/distroless/base:nonroot

ARG TARGETARCH
ARG TARGETPLATFORM

ENV HELM_CACHE_HOME=/tmp/helm-cache
ENV KOGEN_CACHE_DIR=/tmp/kogen-cache

Expand All @@ -8,6 +11,6 @@ USER 999

COPY argo-plugin/plugin.yaml /home/argocd/cmp-server/config/plugin.yaml

COPY dist/kogen /kogen
COPY "${TARGETPLATFORM}/kogen_linux_${TARGETARCH}" /kogen

ENTRYPOINT ["/kogen"]
0