From b4ebf10f547f1ba2d4f6e83f82e6b5355ee62ac7 Mon Sep 17 00:00:00 2001 From: Kevin Fox Date: Sat, 26 Oct 2024 08:54:45 -0700 Subject: [PATCH] Add releaser Signed-off-by: Kevin Fox --- .github/workflows/release.yaml | 29 ++++++++++++++++++ .github/workflows/test.yaml | 27 +++++++++++++++++ .goreleaser.yaml | 54 ++++++++++++++++++++++++++++++++++ main.go => cmd/main.go | 0 4 files changed, 110 insertions(+) create mode 100644 .github/workflows/release.yaml create mode 100644 .github/workflows/test.yaml create mode 100644 .goreleaser.yaml rename main.go => cmd/main.go (100%) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..01cd131 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,29 @@ +name: Release +on: + push: + tags: + - 'v*' + +permissions: + contents: write + packages: write + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v5 + - uses: ko-build/setup-ko@v0.6 + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v6 + with: + distribution: goreleaser + version: '~> v2' + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..e71dcfe --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,27 @@ +name: Test +on: + pull_request: {} + push: + branches: + - main + +jobs: + lint: + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: read + checks: write + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + - name: Lint + uses: golangci/golangci-lint-action@v6 + with: + version: v1.61 diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..8f4c243 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,54 @@ +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +# vim: set ts=2 sw=2 tw=0 fo=cnqoj + +version: 2 + +before: + hooks: + # You may remove this if you don't use go modules. + - go mod tidy + # you may remove this if you don't need go generate + - go generate ./... + +builds: + - env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + main: ./cmd + binary: k8s-spiffe-workload-jwt-exec-auth + +archives: + - format: tar.gz + # this name template makes the OS and Arch compatible with the results of `uname`. + name_template: >- + {{ .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end }} + # use zip for windows archives + format_overrides: + - goos: windows + format: zip + +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" + +kos: + - repository: ghcr.io/spiffe/k8s-spiffe-workload-jwt-exec-auth + tags: + - "{{.Version}}" + - latest + bare: true + preserve_import_paths: false + platforms: + - linux/amd64 + - linux/arm64 diff --git a/main.go b/cmd/main.go similarity index 100% rename from main.go rename to cmd/main.go