Skip to content

Commit 181da5f

Browse files
committed
Overhaul CI and add releases via goreleaser
1 parent 623ddcf commit 181da5f

File tree

5 files changed

+142
-31
lines changed

5 files changed

+142
-31
lines changed

.github/workflows/devstack.yml

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
name: devstack
2-
32
on:
4-
push:
53
pull_request:
64

75
jobs:

.github/workflows/go.yml

+38-7
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,53 @@
1-
name: go
1+
name: Build, Test and Release Binaries
22
on:
3-
push:
4-
pull_request:
3+
push
4+
5+
permissions:
6+
contents: write
7+
packages: write
58

69
jobs:
710
build:
811
runs-on: ubuntu-latest
9-
1012
steps:
1113
- name: Set up Go
1214
uses: actions/setup-go@v5
1315
with:
1416
go-version: 1.23.x
15-
1617
- uses: actions/checkout@v4
17-
18+
- name: golangci-lint
19+
uses: golangci/golangci-lint-action@v6
20+
with:
21+
args: --exclude-files ".*_test.go"
22+
version: latest
1823
- name: go build
1924
run: go build ./...
20-
2125
- name: go test
2226
run: go test -v ./...
27+
28+
release:
29+
if: startsWith(github.event.ref, 'refs/tags/v')
30+
needs: build
31+
runs-on: ubuntu-latest
32+
steps:
33+
- name: Checkout Repository
34+
uses: actions/checkout@v4
35+
- name: Login to GitHub Container Registry
36+
uses: docker/login-action@v3
37+
with:
38+
registry: ghcr.io
39+
username: ${{ github.actor }}
40+
password: ${{ secrets.GITHUB_TOKEN }}
41+
- name: Setup Go
42+
uses: actions/setup-go@v5
43+
with:
44+
go-version: 1.23.x
45+
46+
- name: Run Goreleaser
47+
if: ${{ github.event_name != 'pull_request' }}
48+
env:
49+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
uses: goreleaser/goreleaser-action@v5
51+
with:
52+
version: latest
53+
args: release --clean

.github/workflows/golangci-lint.yml

-22
This file was deleted.

.goreleaser

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
project_name: external-dns-openstack-webhook
2+
before:
3+
hooks:
4+
- go mod tidy
5+
- go mod download
6+
7+
builds:
8+
- id: external-dns-openstack-webhook
9+
dir: .
10+
main: ./cmd/webhook/
11+
binary: external-dns-openstack-webhook
12+
flags:
13+
- -tags=netgo
14+
- -v
15+
- -a
16+
ldflags:
17+
- -w -s
18+
- -X main.version={{ .Version }} -X main.commit={{ .Commit }}
19+
goos:
20+
- darwin
21+
- freebsd
22+
- linux
23+
goarch:
24+
- amd64
25+
- arm
26+
- arm64
27+
- riscv64
28+
goarm:
29+
- "5"
30+
- "6"
31+
- "7"
32+
ignore:
33+
- goos: darwin
34+
goarch: arm
35+
- goos: darwin
36+
goarch: riscv64
37+
38+
dockers:
39+
- ids:
40+
- external-dns-openstack-webhook
41+
image_templates:
42+
- ghcr.io/inovex/{{ .ProjectName }}:{{ .Version }}-amd64
43+
goos: linux
44+
goarch: amd64
45+
dockerfile: goreleaser.dockerfile
46+
build_flag_templates:
47+
- "--build-arg=BINARY_NAME={{ .ProjectName }}"
48+
- "--platform=linux/amd64"
49+
use: buildx
50+
- ids:
51+
- external-dns-openstack-webhook
52+
image_templates:
53+
- ghcr.io/inovex/{{ .ProjectName }}:{{ .Version }}-arm64
54+
goos: linux
55+
goarch: arm64
56+
dockerfile: goreleaser.dockerfile
57+
build_flag_templates:
58+
- "--build-arg=BINARY_NAME={{ .ProjectName }}"
59+
- "--platform=linux/arm64"
60+
use: buildx
61+
- ids:
62+
- external-dns-openstack-webhook
63+
image_templates:
64+
- ghcr.io/inovex/{{ .ProjectName }}:{{ .Version }}-riscv64
65+
goos: linux
66+
goarch: riscv64
67+
dockerfile: goreleaser.dockerfile
68+
build_flag_templates:
69+
- "--build-arg=BINARY_NAME={{ .ProjectName }}"
70+
- "--platform=linux/riscv64"
71+
use: buildx
72+
73+
docker_manifests:
74+
- name_template: "ghcr.io/inovex/{{ .ProjectName }}:{{ .Version }}"
75+
image_templates:
76+
- "ghcr.io/inovex/{{ .ProjectName }}:{{ .Version }}-amd64"
77+
- "ghcr.io/inovex/{{ .ProjectName }}:{{ .Version }}-arm64"
78+
- "ghcr.io/inovex/{{ .ProjectName }}:{{ .Version }}-riscv64"
79+
80+
archives:
81+
- name_template: "{{ .ProjectName }}-{{ .Version }}.{{ .Os }}-{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}"
82+
format: tar.gz
83+
wrap_in_directory: true
84+
85+
checksum:
86+
name_template: "{{ .ProjectName }}-{{ .Version }}_checksums.txt"
87+
algorithm: sha256
88+
89+
# Configuration for GitHub Releases
90+
release:
91+
github:
92+
owner: inovex
93+
name: external-dns-openstack-webhook
94+
footer: |
95+
## Docker Images
96+
- ghcr.io/inovex/external-dns-openstack-webhook:{{ trimprefix .Tag "v" }} (universal, multi-platform)
97+
- ghcr.io/inovex/external-dns-openstack-webhook:{{ trimprefix .Tag "v" }}-amd64
98+
- ghcr.io/inovex/external-dns-openstack-webhook:{{ trimprefix .Tag "v" }}-arm64
99+
- ghcr.io/inovex/external-dns-openstack-webhook:{{ trimprefix .Tag "v" }}-riscv64
100+
prerelease: auto
101+
replace_existing_draft: true

.goreleaser.dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM scratch
2+
COPY external-dns-openstack-webhook /external-dns-openstack-webhook
3+
ENTRYPOINT ["/external-dns-openstack-webhook"]

0 commit comments

Comments
 (0)