File tree Expand file tree Collapse file tree 3 files changed +16
-12
lines changed Expand file tree Collapse file tree 3 files changed +16
-12
lines changed Original file line number Diff line number Diff line change 2323 git config --global user.name "github-actions[bot]"
2424 git add .
2525 git commit --allow-empty -m "fix: update OpenAPI spec"
26+ - name : Set old commit for SDK API diff
27+ run : echo "API_DIFF_OLD_COMMIT=$(git rev-parse HEAD)" >> $GITHUB_ENV
2628 - name : Run generation
2729 working-directory : ./tools
2830 run : |
@@ -41,13 +43,13 @@ jobs:
4143 if : steps.verify-changed-files.outputs.files_changed == 'true'
4244 run : |
4345 git add . && git commit -m "fix: Generated SDK source code and docs"
46+ - name : Set new commit for SDK API diff
47+ if : steps.verify-changed-files.outputs.files_changed == 'true'
48+ run : echo "API_DIFF_NEW_COMMIT=$(git rev-parse HEAD)" >> $GITHUB_ENV
4449 - name : Release updates
4550 if : steps.verify-changed-files.outputs.files_changed == 'true'
4651 working-directory : ./tools
47- env :
48- GIT_BASE_REF : ${{ github.sha }}
49- run : |
50- make new-release
52+ run : make new-release
5153 - name : Ensure all markdown code is formatted
5254 if : steps.verify-changed-files.outputs.files_changed == 'true'
5355 working-directory : ./tools
Original file line number Diff line number Diff line change @@ -45,3 +45,8 @@ This enables us to verify new templates changes.
4545Templates are sourced from openapi generator :
4646
4747https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator/src/main/resources/go
48+
49+ # # Go API Diff
50+
51+ We use [go-apidiff](https://github.com/joelanford/go-apidiff) to detect if there are breaking changes and a new major version release is needed.
52+ In [Generate SDK Github action](../.github/workflows/autoupdate-prod.yaml), `API_DIFF_OLD_COMMIT` and `API_DIFF_NEW_COMMIT` are used to do the comparison.
Original file line number Diff line number Diff line change @@ -3,24 +3,21 @@ set -eu
33GOPATH=$( go env GOPATH)
44
55# Inputs:
6- # GIT_BASE_REF - The base REF of the git repository (git rev-parse origin/main)
7- # Usually "${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha }}"
6+ # API_DIFF_OLD_COMMIT: commit before the API changes to compare with. If not provided, script will fail with "unbound variable" error
7+ # API_DIFF_NEW_COMMIT: commit with the new API changes. If not provided, script will fail with "unbound variable" error
88# TARGET_BREAKING_CHANGES_FILE - file to save breaking changes
9+ TARGET_BREAKING_CHANGES_FILE=${TARGET_BREAKING_CHANGES_FILE:- " " }
910script_path=$( dirname " $0 " )
1011
1112echo " Installing go-apidiff"
1213go install github.com/joelanford/go-apidiff@latest > /dev/null
1314
14- current_ref=$( git rev-parse main || echo)
15- GIT_BASE_REF=${GIT_BASE_REF:- $current_ref }
16- TARGET_BREAKING_CHANGES_FILE=${TARGET_BREAKING_CHANGES_FILE:- " " }
17-
18- echo " Running breaking changes check for $GIT_BASE_REF "
15+ echo " Running breaking changes check comparing commits ${API_DIFF_OLD_COMMIT} and ${API_DIFF_NEW_COMMIT} "
1916
2017pushd " $script_path /../../../" || exit # # workaround for --repo-path="../" not working
2118echo " Changed directory to $( pwd) "
2219set +e
23- BREAKING_CHANGES=$( " $GOPATH /bin/go-apidiff" " $GIT_BASE_REF " " $( git rev-parse head ) " --compare-imports=" false" --print-compatible=" false" )
20+ BREAKING_CHANGES=$( " $GOPATH /bin/go-apidiff" " ${API_DIFF_OLD_COMMIT} " " ${API_DIFF_NEW_COMMIT} " --compare-imports=" false" --print-compatible=" false" )
2421set -e
2522popd || exit
2623
You can’t perform that action at this time.
0 commit comments