diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c46588..2570f63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Changelog ## [Unreleased] +### Fixed +- Go: Only use major version in go module ([#86](https://github.com/cucumber/polyglot-release/pull/86)) ## [1.2.0] - 2022-11-09 ### Added diff --git a/polyglot-release b/polyglot-release index 46e5d83..f8a1daa 100755 --- a/polyglot-release +++ b/polyglot-release @@ -106,10 +106,12 @@ function pre_release_go() { check_for_tools "go" "jq" "sed" } function release_go() { + NEW_MAJOR_VERSION="$(echo "$NEW_VERSION" | sed -E 's/^([0-9]+)\.[0-9]+\.[0-9]+$/\1/')" + # The sed below also captures 3-digit versions MODULE_WITH_NEW_VERSION=$( go mod edit -json | jq -r '.Module.Path' | - sed -E "s/(.*)v[0-9]+.[0-9]+.[0-9]+$/\1v$NEW_VERSION/" + sed -E "s/(.*)v[0-9]+(\.[0-9]+\.[0-9]+)?$/\1v$NEW_MAJOR_VERSION/" ) go mod edit -module "$MODULE_WITH_NEW_VERSION" } diff --git a/tests/fixtures/go-three-digit-version/CHANGELOG.md b/tests/fixtures/go-three-digit-version/CHANGELOG.md new file mode 100644 index 0000000..5c5d610 --- /dev/null +++ b/tests/fixtures/go-three-digit-version/CHANGELOG.md @@ -0,0 +1,18 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/) +and this project adheres to [Semantic Versioning](http://semver.org/). + +## [Unreleased] + +### Fixed +- This is a test + +## [0.0.1] - 2000-01-01 + +## [0.0.0] - 2000-01-01 + +[Unreleased]: https://github.com/cucumber/polyglot-release/compare/v0.0.1...main +[0.0.1]: https://github.com/cucumber/polyglot-release/compare/v0.0.0...v0.0.1 diff --git a/tests/fixtures/go-three-digit-version/go.mod b/tests/fixtures/go-three-digit-version/go.mod new file mode 100644 index 0000000..2053071 --- /dev/null +++ b/tests/fixtures/go-three-digit-version/go.mod @@ -0,0 +1,3 @@ +module github.com/example/project/v0.0.1 + +go 1.18 diff --git a/tests/fixtures/go/go.mod b/tests/fixtures/go/go.mod index 2053071..e70a7b9 100644 --- a/tests/fixtures/go/go.mod +++ b/tests/fixtures/go/go.mod @@ -1,3 +1,3 @@ -module github.com/example/project/v0.0.1 +module github.com/example/project/v0 go 1.18 diff --git a/tests/only-release-go-three-digit-version.sh b/tests/only-release-go-three-digit-version.sh new file mode 100644 index 0000000..0a531c5 --- /dev/null +++ b/tests/only-release-go-three-digit-version.sh @@ -0,0 +1,2 @@ +# fixture: go-three-digit-version +polyglot-release 1.0.0 diff --git a/tests/only-release-go-three-digit-version.sh.expected.git-commits b/tests/only-release-go-three-digit-version.sh.expected.git-commits new file mode 100644 index 0000000..89e27e8 --- /dev/null +++ b/tests/only-release-go-three-digit-version.sh.expected.git-commits @@ -0,0 +1,25 @@ + +** +Prepare release v1.0.0 + +Created-by: polyglot-release v-develop + + +diff --git a/CHANGELOG.md b/CHANGELOG.md +--- a/CHANGELOG.md ++++ b/CHANGELOG.md +@@ -9,0 +10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ++## [1.0.0] - 2000-01-01 +@@ -15 +16 @@ and this project adheres to [Semantic Versioning](http://semver.org/). +-## [0.0.0] - 2000-01-01 ++## 0.0.0 - 2000-01-01 +@@ -17 +18,2 @@ and this project adheres to [Semantic Versioning](http://semver.org/). +-[Unreleased]: https://github.com/cucumber/polyglot-release/compare/v0.0.1...main ++[Unreleased]: https://github.com/cucumber/polyglot-release/compare/v1.0.0...main ++[1.0.0]: https://github.com/cucumber/polyglot-release/compare/v0.0.1...main +diff --git a/go.mod b/go.mod +--- a/go.mod ++++ b/go.mod +@@ -1 +1 @@ +-module github.com/example/project/v0.0.1 ++module github.com/example/project/v1 diff --git a/tests/only-release-go.sh.expected.git-commits b/tests/only-release-go.sh.expected.git-commits index f7867b8..cf17540 100644 --- a/tests/only-release-go.sh.expected.git-commits +++ b/tests/only-release-go.sh.expected.git-commits @@ -21,5 +21,5 @@ diff --git a/go.mod b/go.mod --- a/go.mod +++ b/go.mod @@ -1 +1 @@ --module github.com/example/project/v0.0.1 -+module github.com/example/project/v1.0.0 +-module github.com/example/project/v0 ++module github.com/example/project/v1