Skip to content

Commit

Permalink
ci: go releaser (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
aabouzaid committed Sep 12, 2023
1 parent b822290 commit fbf3086
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 24 deletions.
89 changes: 89 additions & 0 deletions .github/workflows/go-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Go CI
on:
push:
branches:
- main
pull_request:

permissions:
contents: read

jobs:
lint:
name: Lint Code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.21'
cache: false
- name: Run GolangCI Linter
uses: golangci/golangci-lint-action@v3
with:
version: v1.54

build:
name: Build Artifacts
needs: ["lint"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.21'
cache: false
- name: Setup Golang Caches
uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: release --clean --snapshot
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Cache Artifacts
uses: actions/cache@v3
with:
path: dist
key: dist

upload:
name: Upload Artifacts - ${{ matrix.os.name }}
needs: ["build"]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
os:
- name: Linux
id: linux
- name: MacOS
id: darwin
- name: Windows
id: windows
steps:
- name: Get Cached Artifacts
uses: actions/cache@v3
with:
path: dist
key: dist
# The upload-artifact action doesn't support multi upload 🤷‍♂️!
- name: Upload Artifacts - AMD
uses: actions/upload-artifact@v3
with:
name: merger-${{ matrix.os.id }}-amd
path: dist/kustomize-plugin-merger_${{ matrix.os.id }}_amd*/kustomize-plugin-merger*
- name: Upload Artifacts - ARM
uses: actions/upload-artifact@v3
with:
name: merger-${{ matrix.os.id }}-arm
path: dist/kustomize-plugin-merger_${{ matrix.os.id }}_arm*/kustomize-plugin-merger*
24 changes: 0 additions & 24 deletions .github/workflows/golangci-lint.yml

This file was deleted.

41 changes: 41 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
before:
hooks:
- go mod download
builds:
- env:
- CGO_ENABLED=0
goos:
- darwin
- linux
- windows
goarch:
- amd64
- arm64
upx:
- enabled: true
compress: "1"
archives:
- format_overrides:
- goos: windows
format: zip
dockers:
- image_templates:
- "ghcr.io/aabouzaid/kustomize-generator-merger:latest"
- "ghcr.io/aabouzaid/kustomize-generator-merger:{{ .Major }}"
- "ghcr.io/aabouzaid/kustomize-generator-merger:{{ .Major }}.{{ .Minor }}"
- "ghcr.io/aabouzaid/kustomize-generator-merger:{{ .Major }}.{{ .Minor }}.{{ .Patch }}"
build_flag_templates:
- "--pull"
# OCI annotations: https://github.com/opencontainers/image-spec/blob/main/annotations.md
- "--label=org.opencontainers.image.created={{ .Date }}"
- "--label=org.opencontainers.image.name={{ .ProjectName }}"
- "--label=org.opencontainers.image.revision={{ .FullCommit }}"
- "--label=org.opencontainers.image.version={{ .Version }}"
- "--label=org.opencontainers.image.source={{ .GitURL }}"
release:
github: {}
name_template: "{{ .Version }}"
prerelease: auto
mode: append
changelog:
skip: true
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM scratch
ENTRYPOINT ["/kustomize-plugin-merger"]
COPY kustomize-plugin-merger /

0 comments on commit fbf3086

Please sign in to comment.