Skip to content

Commit ac3c31b

Browse files
authored
Merge pull request #14 from gauravkghildiyal/setup-releaser
Setup goreleaser and bump goccy/go-graphviz to newer version
2 parents dc286b4 + 02c6c61 commit ac3c31b

File tree

6 files changed

+148
-23
lines changed

6 files changed

+148
-23
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
bin/
22
vendor/
33
.vscode/
4+
dist/

.goreleaser.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# https://goreleaser.com/
2+
#
3+
# For local testing, use:
4+
#
5+
# goreleaser release --snapshot --clean
6+
project_name: gwctl
7+
8+
before:
9+
hooks:
10+
# Ensure the project builds successfully before release.
11+
- make build
12+
13+
# Refer https://goreleaser.com/customization/builds/ for all available options.
14+
builds:
15+
- id: gwctl # Build ID for reference.
16+
main: ./main.go
17+
binary: gwctl # Binary name.
18+
env:
19+
- CGO_ENABLED=0 # Disable CGO for broader compatibility.
20+
goos:
21+
- linux
22+
- darwin
23+
- windows
24+
goarch:
25+
- 386
26+
- amd64
27+
- arm64
28+
ldflags:
29+
# Reduce the size of the binary. Ref: https://pkg.go.dev/cmd/link
30+
- -s -w
31+
# Embed versioning and build information in the binary.
32+
- -X sigs.k8s.io/gwctl/pkg/version.version={{.Version}}
33+
- -X sigs.k8s.io/gwctl/pkg/version.gitCommit={{.FullCommit}}
34+
- -X sigs.k8s.io/gwctl/pkg/version.buildDate={{.Date}}
35+
36+
archives:
37+
- format: tar.gz
38+
# This name template makes the OS and Arch compatible with the results of
39+
# uname.
40+
name_template: >-
41+
{{ .ProjectName }}_
42+
{{- title .Os }}_
43+
{{- if eq .Arch "amd64" }}x86_64
44+
{{- else if eq .Arch "386" }}i386
45+
{{- else }}{{ .Arch }}{{ end }}
46+
{{- if .Arm }}v{{ .Arm }}{{ end }}
47+
# Use zip for windows archives
48+
format_overrides:
49+
- goos: windows
50+
format: zip

RELEASE.md

Lines changed: 65 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,68 @@
11
# Release Process
22

3-
The Kubernetes Template Project is released on an as-needed basis. The process is as follows:
3+
## Releasing a major or minor version
44

5-
1. An issue is proposing a new release with a changelog since the last release
6-
1. All [OWNERS](OWNERS) must LGTM this release
7-
1. An OWNER runs `git tag -s $VERSION` and inserts the changelog and pushes the tag with `git push $VERSION`
8-
1. The release issue is closed
9-
1. An announcement email is sent to `[email protected]` with the subject `[ANNOUNCE] kubernetes-template-project $VERSION is released`
5+
**Prerequisites:**
6+
7+
* Install goreleaser:
8+
```bash
9+
go install github.com/goreleaser/goreleaser@latest
10+
```
11+
**Steps:**
12+
13+
1. Determine the release version:
14+
15+
- Identify the `MAJOR`, `MINOR`, and `PATCH` version numbers for the release.
16+
- For example:
17+
```bash
18+
MAJOR="1"
19+
MINOR="2"
20+
PATCH="3"
21+
```
22+
23+
2. Create a release branch:
24+
25+
26+
- Create a release branch using the format `release-${MAJOR}.${MINOR}`:
27+
28+
```bash
29+
git checkout -b release-${MAJOR}.${MINOR}
30+
```
31+
32+
- Push the release branch to the upstream repository:
33+
34+
```bash
35+
git push upstream release-${MAJOR}.${MINOR}
36+
```
37+
38+
3. Create and push a tag:
39+
40+
- Create a new tag using the format `v${MAJOR}.${MINOR}.${PATCH}`:
41+
42+
```bash
43+
git tag v${MAJOR}.${MINOR}.${PATCH}
44+
```
45+
46+
- Push the release branch to the upstream repository:
47+
48+
```bash
49+
git push upstream v${MAJOR}.${MINOR}.${PATCH}
50+
```
51+
52+
4. Build release artifacts:
53+
54+
- Use `goreleaser` to build the release artifacts:
55+
56+
```bash
57+
goreleaser release --clean --skip-publish
58+
```
59+
60+
This command generates the release artifacts in the `dist` directory.
61+
62+
5. **Create a GitHub release:**
63+
64+
- Go to the project's GitHub repository and navigate to the [New Releases
65+
page](https://github.com/kubernetes-sigs/gwctl/releases/new).
66+
- Select the newly created tag (`v${MAJOR}.${MINOR}.${PATCH}`) from the "Choose a tag" dropdown.
67+
- Attach the relevant release artifacts (`.tar.gz` and `.zip` files) from the `dist` directory.
68+
- Publish the release.

go.mod

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.22.2
44

55
require (
66
github.com/evanphx/json-patch v5.9.0+incompatible
7-
github.com/goccy/go-graphviz v0.1.3
7+
github.com/goccy/go-graphviz v0.2.9
88
github.com/google/go-cmp v0.6.0
99
github.com/spf13/cobra v1.8.0
1010
github.com/spf13/pflag v1.0.5
@@ -27,9 +27,11 @@ require (
2727
github.com/MakeNowJust/heredoc v1.0.0 // indirect
2828
github.com/chai2010/gettext-go v1.0.2 // indirect
2929
github.com/davecgh/go-spew v1.1.1 // indirect
30+
github.com/disintegration/imaging v1.6.2 // indirect
3031
github.com/emicklei/go-restful/v3 v3.12.0 // indirect
3132
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
3233
github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect
34+
github.com/flopp/go-findfont v0.1.0 // indirect
3335
github.com/fogleman/gg v1.3.0 // indirect
3436
github.com/go-errors/errors v1.4.2 // indirect
3537
github.com/go-logr/logr v1.4.1 // indirect
@@ -65,15 +67,16 @@ require (
6567
github.com/pmezard/go-difflib v1.0.0 // indirect
6668
github.com/russross/blackfriday/v2 v2.1.0 // indirect
6769
github.com/stretchr/testify v1.9.0 // indirect
70+
github.com/tetratelabs/wazero v1.8.1 // indirect
6871
github.com/xlab/treeprint v1.2.0 // indirect
6972
go.starlark.net v0.0.0-20230525235612-a134d8f9ddca // indirect
70-
golang.org/x/image v0.14.0 // indirect
73+
golang.org/x/image v0.21.0 // indirect
7174
golang.org/x/net v0.28.0 // indirect
7275
golang.org/x/oauth2 v0.20.0 // indirect
7376
golang.org/x/sync v0.8.0 // indirect
7477
golang.org/x/sys v0.23.0 // indirect
7578
golang.org/x/term v0.23.0 // indirect
76-
golang.org/x/text v0.17.0 // indirect
79+
golang.org/x/text v0.19.0 // indirect
7780
golang.org/x/time v0.5.0 // indirect
7881
google.golang.org/protobuf v1.34.1 // indirect
7982
gopkg.in/inf.v0 v0.9.1 // indirect

go.sum

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@ github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWR
1313
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
1414
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
1515
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
16-
github.com/corona10/goimagehash v1.0.2 h1:pUfB0LnsJASMPGEZLj7tGY251vF+qLGqOgEP4rUs6kA=
17-
github.com/corona10/goimagehash v1.0.2/go.mod h1:/l9umBhvcHQXVtQO1V6Gp1yD20STawkhRnnX0D1bvVI=
16+
github.com/corona10/goimagehash v1.1.0 h1:teNMX/1e+Wn/AYSbLHX8mj+mF9r60R1kBeqE9MkoYwI=
17+
github.com/corona10/goimagehash v1.1.0/go.mod h1:VkvE0mLn84L4aF8vCb6mafVajEb6QYMHl2ZJLn0mOGI=
1818
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
1919
github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY=
2020
github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
2121
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
2222
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
2323
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
24+
github.com/disintegration/imaging v1.6.2 h1:w1LecBlG2Lnp8B3jk5zSuNqd7b4DXhcjwek1ei82L+c=
25+
github.com/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44amcmDAg8hxG0Ewe4=
2426
github.com/emicklei/go-restful/v3 v3.12.0 h1:y2DdzBAURM29NFF94q6RaY4vjIH1rtwDapwQtU84iWk=
2527
github.com/emicklei/go-restful/v3 v3.12.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
2628
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
@@ -31,6 +33,8 @@ github.com/evanphx/json-patch/v5 v5.9.0 h1:kcBlZQbplgElYIlo/n1hJbls2z/1awpXxpRi0
3133
github.com/evanphx/json-patch/v5 v5.9.0/go.mod h1:VNkHZ/282BpEyt/tObQO8s5CMPmYYq14uClGH4abBuQ=
3234
github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d h1:105gxyaGwCFad8crR9dcMQWvV9Hvulu6hwUh4tWPJnM=
3335
github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d/go.mod h1:ZZMPRZwes7CROmyNKgQzC3XPs6L/G2EJLHddWejkmf4=
36+
github.com/flopp/go-findfont v0.1.0 h1:lPn0BymDUtJo+ZkV01VS3661HL6F4qFlkhcJN55u6mU=
37+
github.com/flopp/go-findfont v0.1.0/go.mod h1:wKKxRDjD024Rh7VMwoU90i6ikQRCr+JTHB5n4Ejkqvw=
3438
github.com/fogleman/gg v1.3.0 h1:/7zJX8F6AaYQc57WQCyN9cAIz+4bCJGO9B+dyW29am8=
3539
github.com/fogleman/gg v1.3.0/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
3640
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
@@ -47,8 +51,8 @@ github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+Gr
4751
github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ=
4852
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
4953
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls=
50-
github.com/goccy/go-graphviz v0.1.3 h1:Pkt8y4FBnBNI9tfSobpoN5qy1qMNqRXPQYvLhaSUasY=
51-
github.com/goccy/go-graphviz v0.1.3/go.mod h1:pMYpbAqJT10V8dzV1JN/g/wUlG/0imKPzn3ZsrchGCI=
54+
github.com/goccy/go-graphviz v0.2.9 h1:4yD2MIMpxNt+sOEARDh5jTE2S/jeAKi92w72B83mWGg=
55+
github.com/goccy/go-graphviz v0.2.9/go.mod h1:hssjl/qbvUXGmloY81BwXt2nqoApKo7DFgDj5dLJGb8=
5256
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
5357
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
5458
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
@@ -127,8 +131,8 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq
127131
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
128132
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f h1:y5//uYreIhSUg3J1GEMiLbxo1LJaP8RfCpH6pymGZus=
129133
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw=
130-
github.com/nfnt/resize v0.0.0-20160724205520-891127d8d1b5 h1:BvoENQQU+fZ9uukda/RzCAL/191HHwJA5b13R6diVlY=
131-
github.com/nfnt/resize v0.0.0-20160724205520-891127d8d1b5/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
134+
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 h1:zYyBkD/k9seD2A7fsi6Oo2LfFZAehjjQMERAvZLEDnQ=
135+
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8=
132136
github.com/onsi/ginkgo/v2 v2.17.1 h1:V++EzdbhI4ZV4ev0UTIj0PzhzOcReJFyJaLjtSF55M8=
133137
github.com/onsi/ginkgo/v2 v2.17.1/go.mod h1:llBI3WDLL9Z6taip6f33H76YcWtJv+7R3HigUjbIBOs=
134138
github.com/onsi/gomega v1.32.0 h1:JRYU78fJ1LPxlckP6Txi/EYqJvjtMrDC04/MM5XRHPk=
@@ -157,6 +161,8 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV
157161
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
158162
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
159163
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
164+
github.com/tetratelabs/wazero v1.8.1 h1:NrcgVbWfkWvVc4UtT4LRLDf91PsOzDzefMdwhLfA550=
165+
github.com/tetratelabs/wazero v1.8.1/go.mod h1:yAI0XTsMBhREkM/YDAK/zNou3GoiAce1P6+rp/wQhjs=
160166
github.com/xlab/treeprint v1.2.0 h1:HzHnuAF1plUN2zGlAFHbSQP2qJ0ZAD3XF5XD7OesXRQ=
161167
github.com/xlab/treeprint v1.2.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd/WEJu0=
162168
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
@@ -173,8 +179,9 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh
173179
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
174180
golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f h1:99ci1mjWVBWwJiEKYY6jWa4d2nTQVIEhZIptnrVb1XY=
175181
golang.org/x/exp v0.0.0-20240416160154-fe59bbe5cc7f/go.mod h1:/lliqkxwWAhPjf5oSOIJup2XcqJaw8RGS6k3TGEc7GI=
176-
golang.org/x/image v0.14.0 h1:tNgSxAFe3jC4uYqvZdTr84SZoM1KfwdC9SKIFrLjFn4=
177-
golang.org/x/image v0.14.0/go.mod h1:HUYqC05R2ZcZ3ejNQsIHQDQiwWM4JBqmm6MKANTp4LE=
182+
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
183+
golang.org/x/image v0.21.0 h1:c5qV36ajHpdj4Qi0GnE0jUc/yuo33OLFaa0d+crTD5s=
184+
golang.org/x/image v0.21.0/go.mod h1:vUbsLavqK/W303ZroQQVKQ+Af3Yl6Uz1Ppu5J/cLz78=
178185
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
179186
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
180187
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
@@ -214,8 +221,8 @@ golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU=
214221
golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk=
215222
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
216223
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
217-
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
218-
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
224+
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
225+
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
219226
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
220227
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
221228
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=

pkg/topology/gateway/graphviz.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package gateway
1818

1919
import (
2020
"bytes"
21+
"context"
2122
"log"
2223

2324
graphviz "github.com/goccy/go-graphviz"
@@ -31,7 +32,11 @@ import (
3132
// - Show policy nodes. Attempt to group policy nodes along with their target
3233
// nodes in a single subgraph so they get rendered closer together.
3334
func ToDot(gwctlGraph *topology.Graph) ([]byte, error) {
34-
g := graphviz.New()
35+
ctx := context.Background()
36+
g, err := graphviz.New(ctx)
37+
if err != nil {
38+
return nil, err
39+
}
3540
cGraph, err := g.Graph()
3641
if err != nil {
3742
return nil, err
@@ -49,7 +54,7 @@ func ToDot(gwctlGraph *topology.Graph) ([]byte, error) {
4954
// Create nodes.
5055
for _, nodeMap := range gwctlGraph.Nodes {
5156
for _, node := range nodeMap {
52-
cNode, err := cGraph.CreateNode(node.GKNN().String())
57+
cNode, err := cGraph.CreateNodeByName(node.GKNN().String())
5358
if err != nil {
5459
return nil, err
5560
}
@@ -90,7 +95,7 @@ func ToDot(gwctlGraph *topology.Graph) ([]byte, error) {
9095
u, v = v, u
9196
}
9297

93-
e, err := cGraph.CreateEdge(relation.Name, u, v)
98+
e, err := cGraph.CreateEdgeByName(relation.Name, u, v)
9499
if err != nil {
95100
return nil, err
96101
}
@@ -107,7 +112,7 @@ func ToDot(gwctlGraph *topology.Graph) ([]byte, error) {
107112
}
108113

109114
var buf bytes.Buffer
110-
if err := g.Render(cGraph, "dot", &buf); err != nil {
115+
if err := g.Render(ctx, cGraph, "dot", &buf); err != nil {
111116
return nil, err
112117
}
113118

0 commit comments

Comments
 (0)