Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/update-sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ jobs:
with:
go-version-file: 'cfn-resources/go.mod'
- name: Update files
run: make tools update-atlas-sdk
run: make tools update-atlas-sdk generate-mocks
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generate mocks in case mock versions changed

- name: Verify Changed files
uses: tj-actions/verify-changed-files@bbd436f8e34e14fee2a0f7bc5b14bcc6b40927cf
id: verify-changed-files
- name: Create PR
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f
if: steps.verify-changed-files.outputs.files_changed == 'true'
with:
token: ${{ secrets.APIX_BOT_PAT }}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to have PR checks run

title: "chore: Updates Atlas Go SDK"
commit-message: "build(deps): bump go.mongodb.org/atlas-sdk"
delete-branch: true
Expand Down
19 changes: 14 additions & 5 deletions cfn-resources/scripts/update-sdk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,24 @@

set -euo pipefail

CURRENT_SDK_RELEASE=$(grep 'go.mongodb.org/atlas-sdk/v' go.mod |
awk '{print $1}' |
sed 's/go.mongodb.org\/atlas-sdk\///' |
sort -V |
tail -n 1)
echo "CURRENT_SDK_RELEASE: $CURRENT_SDK_RELEASE"

LATEST_SDK_TAG=$(curl -sSfL -X GET https://api.github.com/repos/mongodb/atlas-sdk-go/releases/latest | jq -r '.tag_name')
echo "LATEST_SDK_TAG: $LATEST_SDK_TAG"

LATEST_SDK_RELEASE=$(echo "${LATEST_SDK_TAG}" | cut -d '.' -f 1)
echo "==> Updating SDK to latest major version ${LATEST_SDK_TAG}"
gomajor get "go.mongodb.org/atlas-sdk/${LATEST_SDK_RELEASE}@${LATEST_SDK_TAG}"
echo "LATEST_SDK_RELEASE: $LATEST_SDK_RELEASE"
echo "==> Updating SDK ${CURRENT_SDK_RELEASE} to latest major version ${LATEST_SDK_TAG}"

gomajor get --rewrite "go.mongodb.org/atlas-sdk/${CURRENT_SDK_RELEASE}" "go.mongodb.org/atlas-sdk/${LATEST_SDK_RELEASE}@${LATEST_SDK_TAG}"
go mod tidy

LATEST_SDK_STRIPPED_MAYOR_VERSION="${LATEST_SDK_RELEASE%%.*}"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LATEST_SDK_RELEASE is already in required format

echo "==> Adjusting version defined in mockery file to ${LATEST_SDK_STRIPPED_MAYOR_VERSION}"
perl -i -pe "s|go.mongodb.org/atlas-sdk/v[0-9]{11}/admin|go.mongodb.org/atlas-sdk/${LATEST_SDK_STRIPPED_MAYOR_VERSION}/admin|g" .mockery.yaml
echo "==> Adjusting version defined in mockery file to ${LATEST_SDK_RELEASE}"
perl -i -pe "s|go.mongodb.org/atlas-sdk/${CURRENT_SDK_RELEASE}/admin|go.mongodb.org/atlas-sdk/${LATEST_SDK_RELEASE}/admin|g" .mockery.yaml

echo "Done"
Loading