Skip to content

Commit

Permalink
feat: Preview in a different module path (#474)
Browse files Browse the repository at this point in the history
Co-authored-by: Wojciech Trocki <w.trocki@mongodb.com>
  • Loading branch information
lantoli and wtrocki authored Nov 7, 2024
1 parent 9b313e4 commit c8de2b3
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 2 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/autoupdate-preview.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ jobs:
run: |
export PATH=${PATH}:`go env GOPATH`/bin
make clean_and_generate
- name: Update Preview version
if: steps.verify-changed-files.outputs.files_changed == 'true'
working-directory: ./tools
run: make preview-version
- name: Run mock generation
working-directory: ./tools
if: steps.verify-changed-files.outputs.files_changed == 'true'
Expand All @@ -56,7 +60,7 @@ jobs:
## Using early preview changes
```sh
go get go.mongodb.org/atlas-sdk@dev-latest
go get github.com/mongodb/atlas-sdk-go@dev-latest
```
## Automated checks done for preview sdk
Expand Down
1 change: 0 additions & 1 deletion examples/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ go 1.22.0
toolchain go1.23.1

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

require (
github.com/hashicorp/go-retryablehttp v0.7.7
Expand Down
4 changes: 4 additions & 0 deletions tools/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ generate_tests:
new-version:
./releaser/scripts/new-version.sh

.PHONY: preview-version
preview-version:
./releaser/scripts/preview-version.sh

.PHONY: update-version
update-version:
## When manually updating major version
Expand Down
5 changes: 5 additions & 0 deletions tools/releaser/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ If the release contains breaking changes (it is a major release)
we should provide a list of breaking changes notes under `./breaking _changes/{major_version}.md` file.
This file is automatically generated during release.

## SDK Preview

Preview generates SDK version by substituting `github.com/mongodb/atlas-sdk-go` as module path.
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.

## Folder structure

`./scripts` - release scripts. Please do not edit them without testing them on the fork repository.
Expand Down
23 changes: 23 additions & 0 deletions tools/releaser/scripts/preview-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash
set -ueo pipefail

script_path=$(dirname "$0")
# shellcheck source=/dev/null
source "$script_path/extract-version.sh"
# shellcheck source=/dev/null
source "$script_path/version-paths.sh"

OLD_PACKAGE="go.mongodb.org/atlas-sdk/${SDK_MAJOR_VERSION}"
NEW_PACKAGE="github.com/mongodb/atlas-sdk-go"
examples_path="$script_path/../../../examples"

echo "Delete specific version $SDK_MAJOR_VERSION from examples go.mod"
(cd "$examples_path" && go mod edit -droprequire="$OLD_PACKAGE")

echo "Modifying all instances from $OLD_PACKAGE to $NEW_PACKAGE across the repository."
npm install
npm exec -c "replace-in-file '/$OLD_PACKAGE/g' '$NEW_PACKAGE' $VERSION_UPDATE_PATHS_PREVIEW --isRegex"

echo "Add preview version to examples go.mod"
(cd "$examples_path" && go get $NEW_PACKAGE)

3 changes: 3 additions & 0 deletions tools/releaser/scripts/version-paths.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/bin/bash

export VERSION_UPDATE_PATHS="../**/go.mod,../**/*.go,../tools/**/*.mustache,../.mockery.yaml,../**/*.md"

# don't change doc files to reduce Preview PR noise
export VERSION_UPDATE_PATHS_PREVIEW="../**/go.mod,../**/*.go,../tools/**/*.mustache,../.mockery.yaml"

0 comments on commit c8de2b3

Please sign in to comment.