From 36fe46e12e33000d88b256f1ca62c850eaab30b4 Mon Sep 17 00:00:00 2001 From: Wojciech Trocki Date: Tue, 24 Oct 2023 15:25:11 +0200 Subject: [PATCH] task: automatically update atlas sdk go (#2392) Co-authored-by: Gustavo Bazan --- .github/workflows/autoupdate-sdk.yaml | 35 +++++++++++++++++++++++++++ Makefile | 5 +--- scripts/update-sdk.sh | 23 ++++++++++++++++++ 3 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/autoupdate-sdk.yaml create mode 100755 scripts/update-sdk.sh diff --git a/.github/workflows/autoupdate-sdk.yaml b/.github/workflows/autoupdate-sdk.yaml new file mode 100644 index 0000000000..c434b01821 --- /dev/null +++ b/.github/workflows/autoupdate-sdk.yaml @@ -0,0 +1,35 @@ +name: Update SDK +on: + schedule: + - cron: 30 8 * * TUE + workflow_dispatch: + +jobs: + update-sdk: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - uses: actions/setup-go@v4 + with: + go-version-file: 'go.mod' + - name: update + run: | + go install github.com/icholy/gomajor@latest + make update-atlas-sdk + - name: Verify Changed files + uses: tj-actions/verify-changed-files@78dc414e915e0664bcf0d2b42465a86cd47bcc3c + id: verify-changed-files + with: + files: | + ./internal/**/* + - uses: peter-evans/create-pull-request@v5 + if: steps.verify-changed-files.outputs.files_changed == 'true' + + with: + title: "APIBot: Atlas GO SDK update" + commit-message: "build(deps): bump go.mongodb.org/atlas-sdk" + delete-branch: true + branch: atlas-sdk-update + body: | + Automatic update for MongoDB Atlas Go Client SDK diff --git a/Makefile b/Makefile index 4c8df6ce55..6a8f23b821 100644 --- a/Makefile +++ b/Makefile @@ -193,10 +193,7 @@ check-library-owners: ## Check that all the dependencies in go.mod has a owner i .PHONY: update-atlas-sdk update-atlas-sdk: ## Update the atlas-sdk dependency - @echo "==> Updating SDK to latest major version" - gomajor get go.mongodb.org/atlas-sdk/v20230201001@latest - go mod tidy - @echo "==> Done, remember to update build/ci/library_owners.json" + ./scripts/update-sdk.sh .PHONY: help .DEFAULT_GOAL := help diff --git a/scripts/update-sdk.sh b/scripts/update-sdk.sh new file mode 100755 index 0000000000..73fedca631 --- /dev/null +++ b/scripts/update-sdk.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +# Copyright 2023 MongoDB Inc +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -euo pipefail + +LATEST_SDK_RELEASE=$(curl -sSfL -X GET https://api.github.com/repos/mongodb/atlas-sdk-go/releases/latest | jq -r '.tag_name' | cut -d '.' -f 1) +echo "==> Updating SDK to latest major version $LATEST_SDK_RELEASE" +gomajor get "go.mongodb.org/atlas-sdk/$LATEST_SDK_RELEASE@latest" +go mod tidy +echo "Done, remember to update build/ci/library_owners.json"