-
Notifications
You must be signed in to change notification settings - Fork 7
chore: Fixes breaking change log with goreleaser #499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
b929b7c
disable run generation
maastha 0c49104
remove depth
maastha f19f211
update openAPI to test
maastha 8427bca
undo model changes
maastha 424313f
undo model changes
maastha e585f64
undo model changes
maastha 8223a97
undo model changes
maastha 2e47bea
update script
maastha 18e331f
update script
maastha 2d52757
update script
maastha e757da9
update script
maastha 50a9f83
tmp
maastha 8097f06
tmp
maastha 7570fe4
tmp
maastha ae3738b
tmp
maastha 552595d
tmp
maastha 0f38843
tmp
maastha 821f8af
tmp
maastha 9d46a48
tmp
maastha cc38fea
doc update
maastha File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
---|---|---|
@@ -1,37 +1,45 @@ | ||
#!/bin/bash | ||
set -eu | ||
GOPATH=$(go env GOPATH) | ||
|
||
# Inputs: | ||
# API_DIFF_OLD_COMMIT: commit before the API changes to compare with. If not provided, script will fail with "unbound variable" error | ||
# API_DIFF_NEW_COMMIT: commit with the new API changes. If not provided, script will fail with "unbound variable" error | ||
# TARGET_BREAKING_CHANGES_FILE - file to save breaking changes | ||
TARGET_BREAKING_CHANGES_FILE=${TARGET_BREAKING_CHANGES_FILE:-""} | ||
script_path=$(dirname "$0") | ||
|
||
echo "Installing go-apidiff" | ||
go install github.com/joelanford/go-apidiff@latest > /dev/null | ||
# shellcheck source=/dev/null | ||
source "$script_path/extract-version.sh" | ||
BASE_VERSION="github.com/mongodb/atlas-sdk-go/$SDK_MAJOR_VERSION@$SDK_VERSION" | ||
|
||
echo "Running breaking changes check comparing commits ${API_DIFF_OLD_COMMIT} and ${API_DIFF_NEW_COMMIT}" | ||
echo "Installing gorelease" | ||
go install golang.org/x/exp/cmd/gorelease@latest >/dev/null | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. :FYI: Latest golang does have tools directive that allows us to define tools direclty in the go.mod. |
||
|
||
pushd "$script_path/../../../" || exit ## workaround for --repo-path="../" not working | ||
echo "Changed directory to $(pwd)" | ||
set +e | ||
BREAKING_CHANGES=$("$GOPATH/bin/go-apidiff" "${API_DIFF_OLD_COMMIT}" "${API_DIFF_NEW_COMMIT}" --compare-imports="false" --print-compatible="false") | ||
|
||
RAW_CHANGES=$(gorelease -base "$BASE_VERSION") | ||
echo "Changes detected from BASE_VERSION $BASE_VERSION:" | ||
echo "$RAW_CHANGES" | ||
|
||
BREAKING_CHANGES=$(echo "$RAW_CHANGES" | awk ' | ||
/## incompatible changes/ {print "### incompatible changes"; collecting=1; next} | ||
collecting && /^#/ {collecting=0} | ||
collecting && NF {print "- "$0} | ||
') | ||
|
||
set -e | ||
popd || exit | ||
|
||
if [ -z "$BREAKING_CHANGES" ]; then | ||
echo "No major breaking changes detected" | ||
echo "No major breaking changes detected" | ||
else | ||
echo "Detected major breaking changes in the release" | ||
if [ -z "$TARGET_BREAKING_CHANGES_FILE" ]; then | ||
echo "Breaking changes for the major release" | ||
echo "$BREAKING_CHANGES" | ||
else | ||
echo "Creating the breaking changes file with following breaking changes:" | ||
echo "$BREAKING_CHANGES" | ||
echo -e "# Breaking Changes\n## SDK changes\n$BREAKING_CHANGES\n## API Changelog\n https://www.mongodb.com/docs/atlas/reference/api-resources-spec/changelog" \ | ||
> "$script_path/../breaking_changes/${TARGET_BREAKING_CHANGES_FILE}.md" | ||
fi | ||
echo "Detected major breaking changes in the release" | ||
if [ -z "$TARGET_BREAKING_CHANGES_FILE" ]; then | ||
echo "Breaking changes for the major release" | ||
echo "$BREAKING_CHANGES" | ||
else | ||
echo "Creating the breaking changes file with following breaking changes:" | ||
echo "$BREAKING_CHANGES" | ||
echo -e "# Breaking Changes\n## SDK changes\n$BREAKING_CHANGES\n## API Changelog\n https://www.mongodb.com/docs/atlas/reference/api-resources-spec/changelog" \ | ||
>"$script_path/../breaking_changes/${TARGET_BREAKING_CHANGES_FILE}.md" | ||
fi | ||
fi |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does script do not have any inputs right now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no. The script now essentially uses the last release version (from extract-version.sh)