-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/new openapi invokes generation (#5)
* initial automated codegen workflow generates oapicodegenfromdocjson.go and version.go from openapi.json. triggered on tag creation. --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
1149ef5
commit 46ed2ea
Showing
3 changed files
with
15,883 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: Generate SDK and Version (Test) | ||
|
||
on: | ||
create: | ||
tags: | ||
- '*' | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
generate-sdk: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code at tag | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.ref }} | ||
fetch-depth: 0 | ||
persist-credentials: false | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: '1.20' | ||
|
||
- name: Install oapi-codegen | ||
run: go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen@latest | ||
|
||
- name: Generate oapicodegenfromdoc.go | ||
run: oapi-codegen -generate types,client,spec -package oapiclient -o ./sdk/oapicodegenfromdoc.json ./openapi/openapi.json | ||
|
||
- name: Generate version.go | ||
run: | | ||
cat <<EOF > ./sdk/version.go | ||
package oapiclient | ||
// Version of the SDK | ||
const Version = "${{ github.ref_name }}" | ||
EOF | ||
- name: Configure Git | ||
run: | | ||
git config user.name "github-actions[bot]" | ||
git config user.email "github-actions[bot]@users.noreply.github.com" | ||
- name: Commit changes | ||
run: | | ||
git add sdk/oapicodegenfromdocjson.go sdk/version.go | ||
git commit -m "Generate oapicodegenfromjson.go and version.go for version ${{ github.ref_name }}"" | ||
- name: Move Tag | ||
run: | | ||
git tag -d ${{ github.ref_name }} | ||
git push origin :refs/tags/${{ github.ref_name }} | ||
git tag ${{ github.ref_name }} | ||
git push origin --tags | ||
- name: Push changes | ||
uses: ad-m/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
branch: main |
Oops, something went wrong.