@@ -36,6 +36,7 @@ import (
36
36
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
37
37
"github.com/spf13/cobra"
38
38
39
+ "cuelang.org/go/cmd/cue/cmd/anduin"
39
40
"cuelang.org/go/internal/mod/modload"
40
41
"cuelang.org/go/internal/mod/semver"
41
42
"cuelang.org/go/internal/vcs"
@@ -134,22 +135,12 @@ func runModUpload(cmd *Command, args []string) error {
134
135
if err != nil {
135
136
return err
136
137
}
137
- if ! semver .IsValid (args [0 ]) {
138
- return fmt .Errorf ("invalid publish version %q; must be valid semantic version (see http://semver.org)" , args [0 ])
139
- }
140
- if semver .Canonical (args [0 ]) != args [0 ] {
141
- return fmt .Errorf ("publish version %q is not in canonical form" , args [0 ])
142
- }
143
-
144
- if major := mf .MajorVersion (); semver .Major (args [0 ]) != major {
145
- if _ , _ , ok := module .SplitPathVersion (mf .Module ); ok {
146
- return fmt .Errorf ("publish version %q does not match the major version %q declared in %q; must be %s.N.N" , args [0 ], major , modPath , major )
147
- } else {
148
- return fmt .Errorf ("publish version %q does not match implied major version %q in %q; must be %s.N.N" , args [0 ], major , modPath , major )
149
- }
138
+ transformedTag , err := anduin .ValidatePublishTag (args [0 ], mf .MajorVersion (), modPath )
139
+ if err != nil {
140
+ return err
150
141
}
151
142
152
- mv , err := module .NewVersion (mf .QualifiedModule (), args [ 0 ] )
143
+ mv , err := module .NewVersion (mf .QualifiedModule (), transformedTag )
153
144
if err != nil {
154
145
return fmt .Errorf ("cannot form module version: %v" , err )
155
146
}
0 commit comments