Skip to content

Commit 3f8d984

Browse files
authored
chore: Use a fix version for Preview (#443)
1 parent ce39965 commit 3f8d984

File tree

6 files changed

+59
-6
lines changed

6 files changed

+59
-6
lines changed

.github/workflows/autoupdate-preview.yaml

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ jobs:
3232
run: |
3333
export PATH=${PATH}:`go env GOPATH`/bin
3434
make clean_and_generate
35+
- name: Update Preview version
36+
if: steps.verify-changed-files.outputs.files_changed == 'true'
37+
working-directory: ./tools
38+
run: make preview-version
3539
- name: Run mock generation
3640
working-directory: ./tools
3741
if: steps.verify-changed-files.outputs.files_changed == 'true'
@@ -44,7 +48,7 @@ jobs:
4448
commit-message: "temp: client update"
4549
delete-branch: true
4650
draft: true
47-
branch: dev-latest
51+
branch: preview-latest
4852
body: |
4953
Automatic update for MongoDB Atlas Go Client based on *release candidate* OpenAPI file.
5054
**DO NOT MERGE THIS PR TO THE MAIN BRANCH**
@@ -56,9 +60,24 @@ jobs:
5660
## Using early preview changes
5761
5862
```sh
59-
go get go.mongodb.org/atlas-sdk/v20240805005@dev-latest
63+
go get github.com/mongodb/atlas-sdk-go@preview-latest
64+
```
65+
> NOTE: The version is fixed so you have to do the `go get` command every time you want to update the Preview version to the latest version.
66+
67+
After that you can use it as usual, e.g.:
68+
```go
69+
...
70+
import(
71+
adminPreview "github.com/mongodb/atlas-sdk-go/admin"
72+
...
73+
74+
params := &adminPreview.ListProjectsApiParams{ ...
75+
...
76+
6077
```
6178
79+
> NOTE: After you use it at least in one go file, run `go mod tidy` to have it in your go.mod file as a direct dependency.
80+
6281
## Automated checks done for preview sdk
6382
6483
1. Compilation and unit tests

.github/workflows/autoupdate-prod.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
- name: Release updates
5050
if: steps.verify-changed-files.outputs.files_changed == 'true'
5151
working-directory: ./tools
52-
run: make new-release
52+
run: make new-version
5353
- name: Ensure all markdown code is formatted
5454
if: steps.verify-changed-files.outputs.files_changed == 'true'
5555
working-directory: ./tools

tools/CONTRIBUTING.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,8 @@ https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-ge
5050

5151
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.
5252
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.
53+
54+
## SDK Preview
55+
56+
The [Generate Preview SDK Github action](../.github/workflows/autoupdate-preview.yaml) creates a PR with latest changes.
57+
It's created in package `github.com/mongodb/atlas-sdk-go` instead of `go.mongodb.org/atlas-sdk/vXXXXXXXXXXX` so no official release is needed for Preview and it makes it clear that it's not a regular version.

tools/Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,14 @@ generate_tests:
3333
rm -Rf ../test/generated/test*
3434
./scripts/generate_tests.sh
3535

36-
.PHONY: new-release
37-
new-release:
36+
.PHONY: new-version
37+
new-version:
3838
./releaser/scripts/new-version.sh
3939

40+
.PHONY: preview-version
41+
preview-version:
42+
./releaser/scripts/preview-version.sh
43+
4044
.PHONY: update-version
4145
update-version:
4246
## When manually updating major version
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
set -ueo pipefail
3+
4+
script_path=$(dirname "$0")
5+
# shellcheck source=/dev/null
6+
source "$script_path/extract-version.sh"
7+
# shellcheck source=/dev/null
8+
source "$script_path/version-paths.sh"
9+
10+
OLD_PACKAGE="go.mongodb.org/atlas-sdk/${SDK_MAJOR_VERSION}"
11+
NEW_PACKAGE="github.com/mongodb/atlas-sdk-go"
12+
examples_path="$script_path/../../../examples"
13+
14+
echo "Delete specific version $SDK_MAJOR_VERSION from examples go.mod"
15+
(cd "$examples_path" && go mod edit -droprequire="$OLD_PACKAGE")
16+
17+
echo "Modifying all instances from $OLD_PACKAGE to $NEW_PACKAGE across the repository."
18+
npm install
19+
npm exec -c "replace-in-file '/$OLD_PACKAGE/g' '$NEW_PACKAGE' $VERSION_UPDATE_PATHS_PREVIEW --isRegex"
20+
21+
echo "Add preview version to examples go.mod"
22+
(cd "$examples_path" && go get $NEW_PACKAGE)
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
#!/bin/bash
22

3-
export VERSION_UPDATE_PATHS="../**/*.go,../**/*.md,../tools/**/*.mustache,../**/go.mod,../.github/workflows/autoupdate-preview.yaml,../.mockery.yaml"
3+
export VERSION_UPDATE_PATHS="../**/go.mod,../**/*.go,../tools/**/*.mustache,../.mockery.yaml,../**/*.md"
4+
5+
# don't change doc files to reduce Preview PR noise
6+
export VERSION_UPDATE_PATHS_PREVIEW="../**/go.mod,../**/*.go,../tools/**/*.mustache,../.mockery.yaml"

0 commit comments

Comments
 (0)