Skip to content

Commit

Permalink
ci: auto update and release (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
Serpentiel authored Feb 20, 2024
1 parent 7991439 commit 3391fe2
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Release

on:
push:
branches:
- main
paths:
- "**.go"
- "**/go.mod"
- "**/go.sum"
workflow_dispatch: {}

permissions: read-all

jobs:
releaser:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- id: version
uses: anothrNick/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}
WITH_V: true
DRY_RUN: true
- id: sha
run: |
GIT_SHA=$(git rev-parse HEAD)
echo "sha=${GIT_SHA::7}" >> $GITHUB_OUTPUT
- id: tag
uses: anothrNick/[email protected]
env:
GITHUB_TOKEN: ${{ github.token }}
WITH_V: true
- uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.version.outputs.new_tag }}
name: ${{ steps.version.outputs.new_tag }}
body: auto-generated release for commit ${{ steps.sha.outputs.sha }}
39 changes: 39 additions & 0 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Update

on:
schedule:
- cron: 0 3 * * 1-5

permissions: read-all

jobs:
updater:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-go@v3
with:
go-version-file: go.mod
- uses: arduino/setup-task@v1
- run: wget -O openapi.json https://api.aiven.io/doc/openapi.json
- run: task generate
env:
AIVEN_TOKEN: ${{ secrets.AIVEN_TOKEN }}
AIVEN_PROJECT_NAME: ${{ secrets.AIVEN_PROJECT_NAME }}
- id: date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
- uses: peter-evans/create-pull-request@v4
with:
author: GitHub <[email protected]>
body: >
automated changes by
[update](https://github.com/aiven/go-client-codegen/blob/main/.github/workflows/update.yml)
GitHub Actions workflow
branch: update/${{ steps.date.outputs.date }}
commit-message: "chore(update): bump openapi schema (${{ steps.date.outputs.date }})"
title: "chore(update): bump openapi schema (${{ steps.date.outputs.date }})"
1 change: 1 addition & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ func (d *aivenClient) do(ctx context.Context, method, path string, v any) (*http

func isEmpty(a any) bool {
v := reflect.ValueOf(a)

return v.IsZero() || v.Kind() == reflect.Ptr && v.IsNil()
}

Expand Down
1 change: 1 addition & 0 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func TestNewClient(t *testing.T) {
require.NoError(t, err)

found := 0

for _, to := range tokens {
if strings.HasPrefix(token, to.TokenPrefix) {
found++
Expand Down
2 changes: 2 additions & 0 deletions generator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ func exec() error {
paramIndex := -1
url := pathClean.ReplaceAllStringFunc(path.Path, func(_ string) string {
paramIndex++

switch t := path.Parameters[paramIndex].Schema.Type; t {
case SchemaTypeInteger:
return "%d"
Expand Down Expand Up @@ -320,6 +321,7 @@ func exec() error {
block = append(block, jen.Return(jen.Err()))
} else {
block = append(block, ifErr)

outReturn := jen.Id("out")
if rsp.CamelName != schemaOut.CamelName {
// Takes original name and turns to camel.
Expand Down

0 comments on commit 3391fe2

Please sign in to comment.