Skip to content

Commit c8de2b3

Browse files
lantoliwtrocki
andauthored
feat: Preview in a different module path (#474)
Co-authored-by: Wojciech Trocki <[email protected]>
1 parent 9b313e4 commit c8de2b3

File tree

6 files changed

+40
-2
lines changed

6 files changed

+40
-2
lines changed

.github/workflows/autoupdate-preview.yaml

Lines changed: 5 additions & 1 deletion
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'
@@ -56,7 +60,7 @@ jobs:
5660
## Using early preview changes
5761
5862
```sh
59-
go get go.mongodb.org/atlas-sdk@dev-latest
63+
go get github.com/mongodb/atlas-sdk-go@dev-latest
6064
```
6165
6266
## Automated checks done for preview sdk

examples/go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ go 1.22.0
55
toolchain go1.23.1
66

77
replace go.mongodb.org/atlas-sdk/v20241023002 => ../
8-
replace go.mongodb.org/atlas-sdk/v20241023002/auth/credentials => ../auth/credentials
98

109
require (
1110
github.com/hashicorp/go-retryablehttp v0.7.7

tools/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ generate_tests:
3737
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

tools/releaser/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ If the release contains breaking changes (it is a major release)
6363
we should provide a list of breaking changes notes under `./breaking _changes/{major_version}.md` file.
6464
This file is automatically generated during release.
6565

66+
## SDK Preview
67+
68+
Preview generates SDK version by substituting `github.com/mongodb/atlas-sdk-go` as module path.
69+
Version should never be committed to the main branch. This task should only be used in [Generate Preview SDK Github action](../../.github/workflows/autoupdate-preview.yaml) which creates a PR with latest changes.
70+
6671
## Folder structure
6772

6873
`./scripts` - release scripts. Please do not edit them without testing them on the fork repository.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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)
23+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
#!/bin/bash
22

33
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)