Skip to content

Commit 7d9411a

Browse files
wtrockimatt-condon
andauthored
CLOUDP-204045: Fully automatic release procedure (#214)
Co-authored-by: Matt Condon <[email protected]>
1 parent f717ab3 commit 7d9411a

File tree

6 files changed

+61
-50
lines changed

6 files changed

+61
-50
lines changed

.github/workflows/autoupdate-prod.yaml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ jobs:
3232
- name: Release updates
3333
if: steps.verify-changed-files.outputs.files_changed == 'true'
3434
working-directory: ./tools
35+
env:
36+
GIT_BASE_REF: ${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha }}
3537
run: |
3638
make new-release
3739
- uses: peter-evans/create-pull-request@v5
@@ -64,14 +66,9 @@ jobs:
6466
## Manual Review Procedure
6567
6668
1. Review changes in the OpenAPI file (openapi/atlas-api.yaml)
67-
2. If we see any breaking changes [without a new resource version](https://github.com/mongodb/atlas-sdk-go/tree/main/tools/releaser#new-resource-version).
68-
- View the log of breaking changes in the `Detect Breaking Changes` action
69-
- Checkout PR locally and run `make update-version`
70-
- Provide breaking changes information in generated `./releaser/breaking_changes/{release_version}.md` file
71-
- Push your changes directly to the automation PR.
72-
3. If we have a major version release request feedback from additional reviewers if possible.
73-
4. Merge PR into the main branch
74-
5. After the merge automated release process will be triggered.
69+
2. Review breaking changes information in generated `./releaser/breaking_changes/{release_version}.md` file
70+
3. Merge PR into the main branch
71+
4. After the merge automated release process will be triggered.
7572
7673
7774

.github/workflows/breaking-changes.yaml

Lines changed: 0 additions & 24 deletions
This file was deleted.

tools/releaser/README.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,6 @@ In situations where we do not want to perform automatic release please remove ch
1919

2020
Manual release is possible by updating `./internal/core/version.go` file with minor version bump.
2121

22-
## Manual Major Release
23-
24-
For major releases (breaking changes) introduced outside new Resource Version.
25-
26-
1. Run `make update-version` command
27-
2. Provide list of breaking changes in [BREAKING_CHANGES.md](https://github.com/mongodb/atlas-sdk-go/blob/main/BREAKING_CHANGES.md)
28-
2922
## Automation Process Internals
3023

3124
Automation reads Resource Version in the `version.go` file and in the OpenAPI `versions.json`
@@ -37,17 +30,20 @@ For the new Resource Version introduced in the versions.json
3730
- Reset the minor version
3831
- Replace all occurrences of the Major version in the repository
3932
- Update versions in versions.go
33+
- Generate breaking changes file
4034

41-
### New Generation
35+
### New SDK Generation without change in Rersource version
4236

4337
- Issue new Minor release
4438
- Update versions in versions.go
4539

46-
### Manual Breaking Changes Release
40+
### Breaking Changes Release
41+
42+
In situations when breaking changes are present automation will recognize them and automatically create major version bump.
4743

48-
- Read versions in versions.go
4944
- Automatically bump the Major version in versions.go
5045
- Replace all occurrences of the Major version in the repository
46+
- Generate breaking changes file
5147

5248
## Release Notes
5349

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
set +e
3+
GOPATH=$(go env GOPATH)
4+
5+
# Inputs:
6+
# GIT_BASE_REF - The base REF of the git repository
7+
# Usually "${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha }}"
8+
# TARGET_BREAKING_CHANGES_FILE - file to save breaking changes
9+
script_path=$(dirname "$0")
10+
11+
echo "Installing go-apidiff"
12+
go install github.com/joelanford/go-apidiff@latest
13+
14+
echo "Running breaking changes check"
15+
BREAKING_CHANGES=$("$GOPATH/bin/go-apidiff" "$GIT_BASE_REF" --compare-imports="false" --print-compatible="false" --repo-path="../")
16+
17+
if [ -z "$BREAKING_CHANGES" ]; then
18+
echo "No breaking changes detected"
19+
else
20+
if [ -z "$TARGET_BREAKING_CHANGES_FILE" ]; then
21+
echo "Breaking changes detected"
22+
echo "$BREAKING_CHANGES"
23+
else
24+
echo "Creating breaking changes file"
25+
echo -e "# Breaking Changes \n ## SDK changes\n$BREAKING_CHANGES\n## API Changelog\n https://www.mongodb.com/docs/atlas/reference/api-resources-spec/changelog" \
26+
> "$script_path/../breaking_changes/${TARGET_BREAKING_CHANGES_FILE}.md"
27+
fi
28+
fi

tools/releaser/scripts/new-version.sh

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,28 @@ if [ "$NEW_RESOURCE_VERSION" == "$SDK_RESOURCE_VERSION" ]; then
1717
new_minor_version=$((SDK_MINOR_VERSION + 1))
1818
# Update the SDK_VERSION
1919
SDK_VERSION="${SDK_MAJOR_VERSION}.${new_minor_version}.0"
20+
21+
echo "Print breaking changes"
22+
# shellcheck source=/dev/null
23+
source "$script_path/breaking-changes.sh"
24+
if [ -n "$BREAKING_CHANGES" ]; then
25+
echo "BREAKING CHANGES DETECTED FOR NON MAJOR VERSION BUMP"
26+
# shellcheck source=/dev/null
27+
source "$script_path/update-version.sh"
28+
exit 0;
29+
fi
2030
else
2131
# Update the SDK_VERSION
2232
echo "Resource Version is not up to date. Changing major version."
23-
NEW_MAJOR_VERSION="${NEW_RESOURCE_VERSION}001"
24-
SDK_VERSION="v${NEW_MAJOR_VERSION}.0.0"
33+
NEW_MAJOR_VERSION="v${NEW_RESOURCE_VERSION}001"
34+
SDK_VERSION="${NEW_MAJOR_VERSION}.0.0"
35+
echo "generate breaking changes file"
36+
export TARGET_BREAKING_CHANGES_FILE=${NEW_MAJOR_VERSION}
37+
# shellcheck source=/dev/null
38+
source "$script_path/breaking-changes.sh"
39+
2540
echo "Modifying all instances of version from $SDK_RESOURCE_VERSION to $NEW_RESOURCE_VERSION across the repository."
2641
npm exec -c "replace-in-file /$SDK_MAJOR_VERSION/g $NEW_MAJOR_VERSION $VERSION_UPDATE_PATHS --isRegex"
27-
echo "Creating empty breaking changes file for $NEW_MAJOR_VERSION"
28-
echo -e "# Breaking Changes \n https://www.mongodb.com/docs/atlas/reference/api-resources-spec/changelog" \
29-
> "$script_path/../breaking_changes/${NEW_MAJOR_VERSION}.md"
3042
fi
3143

3244
echo "Creating new version.go file with $SDK_VERSION and resource version: $NEW_RESOURCE_VERSION"

tools/releaser/scripts/update-version.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,15 @@ source "$script_path/version-paths.sh"
1111
echo "Current Resource Version: $NEW_RESOURCE_VERSION"
1212

1313
major_version_breaking_changes="${SDK_MAJOR_VERSION: -3}"
14+
# Remove leading zeros from the variable
15+
major_version_breaking_changes=${major_version_breaking_changes#00}
1416
major_version_bump=$((major_version_breaking_changes+1))
1517
major_version_bump=$(printf "%03d" "$major_version_bump")
1618
BUMPED_MAJOR_VERSION="v${SDK_RESOURCE_VERSION}${major_version_bump}"
1719

1820
echo "Modifying $SDK_MAJOR_VERSION to $BUMPED_MAJOR_VERSION Resource Version across the repository."
1921
npm exec -c "replace-in-file /$SDK_MAJOR_VERSION/g $BUMPED_MAJOR_VERSION $VERSION_UPDATE_PATHS --isRegex"
2022

21-
echo "Creating empty breaking changes file for $BUMPED_MAJOR_VERSION"
22-
echo "# Breaking Changes" > "$script_path/../breaking_changes/${BUMPED_MAJOR_VERSION}.md"
23-
2423
## Explicitly update version.go file
2524
export SDK_VERSION="${BUMPED_MAJOR_VERSION}.0.0"
2625
export NEW_RESOURCE_VERSION="${SDK_RESOURCE_VERSION}"
@@ -29,3 +28,6 @@ echo "Updating version.go file: $SDK_VERSION"
2928
target_file_path="$script_path/../../../internal/core/version.go"
3029
envsubst < "$script_path/../templates/VERSION.tmpl" > "$target_file_path"
3130

31+
export TARGET_BREAKING_CHANGES_FILE=${BUMPED_MAJOR_VERSION}
32+
# shellcheck source=/dev/null
33+
source "$script_path/breaking-changes.sh"

0 commit comments

Comments
 (0)