Skip to content

Commit 3391fe2

Browse files
authored
ci: auto update and release (#21)
1 parent 7991439 commit 3391fe2

File tree

5 files changed

+86
-0
lines changed

5 files changed

+86
-0
lines changed

.github/workflows/release.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- "**.go"
9+
- "**/go.mod"
10+
- "**/go.sum"
11+
workflow_dispatch: {}
12+
13+
permissions: read-all
14+
15+
jobs:
16+
releaser:
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: write
20+
steps:
21+
- uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
- id: version
25+
uses: anothrNick/[email protected]
26+
env:
27+
GITHUB_TOKEN: ${{ github.token }}
28+
WITH_V: true
29+
DRY_RUN: true
30+
- id: sha
31+
run: |
32+
GIT_SHA=$(git rev-parse HEAD)
33+
echo "sha=${GIT_SHA::7}" >> $GITHUB_OUTPUT
34+
- id: tag
35+
uses: anothrNick/[email protected]
36+
env:
37+
GITHUB_TOKEN: ${{ github.token }}
38+
WITH_V: true
39+
- uses: softprops/action-gh-release@v1
40+
with:
41+
tag_name: ${{ steps.version.outputs.new_tag }}
42+
name: ${{ steps.version.outputs.new_tag }}
43+
body: auto-generated release for commit ${{ steps.sha.outputs.sha }}

.github/workflows/update.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Update
2+
3+
on:
4+
schedule:
5+
- cron: 0 3 * * 1-5
6+
7+
permissions: read-all
8+
9+
jobs:
10+
updater:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
pull-requests: write
15+
steps:
16+
- uses: actions/checkout@v3
17+
with:
18+
fetch-depth: 0
19+
- uses: actions/setup-go@v3
20+
with:
21+
go-version-file: go.mod
22+
- uses: arduino/setup-task@v1
23+
- run: wget -O openapi.json https://api.aiven.io/doc/openapi.json
24+
- run: task generate
25+
env:
26+
AIVEN_TOKEN: ${{ secrets.AIVEN_TOKEN }}
27+
AIVEN_PROJECT_NAME: ${{ secrets.AIVEN_PROJECT_NAME }}
28+
- id: date
29+
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
30+
- uses: peter-evans/create-pull-request@v4
31+
with:
32+
author: GitHub <[email protected]>
33+
body: >
34+
automated changes by
35+
[update](https://github.com/aiven/go-client-codegen/blob/main/.github/workflows/update.yml)
36+
GitHub Actions workflow
37+
branch: update/${{ steps.date.outputs.date }}
38+
commit-message: "chore(update): bump openapi schema (${{ steps.date.outputs.date }})"
39+
title: "chore(update): bump openapi schema (${{ steps.date.outputs.date }})"

client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ func (d *aivenClient) do(ctx context.Context, method, path string, v any) (*http
143143

144144
func isEmpty(a any) bool {
145145
v := reflect.ValueOf(a)
146+
146147
return v.IsZero() || v.Kind() == reflect.Ptr && v.IsNil()
147148
}
148149

client_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ func TestNewClient(t *testing.T) {
3030
require.NoError(t, err)
3131

3232
found := 0
33+
3334
for _, to := range tokens {
3435
if strings.HasPrefix(token, to.TokenPrefix) {
3536
found++

generator/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ func exec() error {
258258
paramIndex := -1
259259
url := pathClean.ReplaceAllStringFunc(path.Path, func(_ string) string {
260260
paramIndex++
261+
261262
switch t := path.Parameters[paramIndex].Schema.Type; t {
262263
case SchemaTypeInteger:
263264
return "%d"
@@ -320,6 +321,7 @@ func exec() error {
320321
block = append(block, jen.Return(jen.Err()))
321322
} else {
322323
block = append(block, ifErr)
324+
323325
outReturn := jen.Id("out")
324326
if rsp.CamelName != schemaOut.CamelName {
325327
// Takes original name and turns to camel.

0 commit comments

Comments
 (0)