Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go: use only major version in the module name #86

Merged
merged 1 commit into from
Dec 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 7 additions & 3 deletions polyglot-release
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,16 @@ function pre_release_go() {
check_for_tools "go" "jq" "sed"
}
function release_go() {
MODULE_WITH_NEW_VERSION=$(
local new_major_version
new_major_version="$(echo "$NEW_VERSION" | sed -E 's/^([0-9]+)\.[0-9]+\.[0-9]+$/\1/')"
# The sed below also captures 3-digit versions
local module_with_new_version
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"
go mod edit -module "$module_with_new_version"
}
function post_release_go() {
# noop
Expand Down
18 changes: 18 additions & 0 deletions tests/fixtures/go-three-digit-version/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions tests/fixtures/go-three-digit-version/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/example/project/v0.0.1

go 1.18
2 changes: 1 addition & 1 deletion tests/fixtures/go/go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/example/project/v0.0.1
module github.com/example/project/v0

go 1.18
2 changes: 2 additions & 0 deletions tests/only-release-go-three-digit-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# fixture: go-three-digit-version
polyglot-release 1.0.0
25 changes: 25 additions & 0 deletions tests/only-release-go-three-digit-version.sh.expected.git-commits
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions tests/only-release-go.sh.expected.git-commits
Original file line number Diff line number Diff line change
Expand Up @@ -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