Skip to content

Commit

Permalink
docs(changeset): fix publishing for go sdk (#679)
Browse files Browse the repository at this point in the history
* docs(changeset): fix publishing for go sdk

* run integration tests
  • Loading branch information
eddiechayes authored Apr 5, 2024
1 parent ceda170 commit 791e38b
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 11 deletions.
5 changes: 5 additions & 0 deletions generator/konfig-dash/.changeset/unlucky-games-work.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'konfig-cli': patch
---

fix publishing for go sdk
Original file line number Diff line number Diff line change
Expand Up @@ -1603,6 +1603,14 @@ function constructGoGenerationRequest({
)
}

const majorVersion = restOfConfig.version.split('.')[0]
const outputParentDir = path.basename(restOfConfig.outputDirectory)
if (parseInt(majorVersion) > 1 && outputParentDir !== `v${majorVersion}`) {
CliUx.ux.error(
`Go SDK output directory must end with the directory "v${majorVersion}". See https://go.dev/blog/v2-go-modules.`
)
}

const requestGo: GenerateRequestBodyType['generators']['go'] = {
files: createTemplateFilesObject(files, 'go', configDir),
...handleReadmeSnippet({ config: restOfConfig }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ const publishScripts = {
gitHost: string
skipTag?: boolean
}) => {
const majorVersion = version.split('.')[0]
return [
...(await generateGitTagCommands({
version,
Expand All @@ -145,7 +146,7 @@ const publishScripts = {
isSubmodule,
skipTag,
})),
`GOPROXY=proxy.golang.org go list -m ${gitHost}/${owner}/${repo}@v${version}`,
`GOPROXY=proxy.golang.org go list -m ${gitHost}/${owner}/${repo}/v${majorVersion}@v${version}`,
]
},
npm: async ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1020,8 +1020,11 @@ Map<String, Object> buildSupportFileBundle(List<OperationsMap> allOperations, Li
if (openAPI.getInfo() != null)
bundle.put("infoExtensions", openAPI.getInfo().getExtensions());

if (bundle.get("packageVersion") != null)
if (bundle.get("packageVersion") != null) {
bundle.put("packageVersionWithoutDashes", ((String) bundle.get("packageVersion")).replaceAll("-", ""));
bundle.put("packageMajorVersion", ((String) bundle.get("packageVersion")).split("\\.")[0]);
bundle.put("isMajorVersionGreaterThanOne", Integer.parseInt((String) bundle.get("packageMajorVersion")) > 1);
}
if (bundle.get("npmVersion") != null)
bundle.put("npmVersionWithoutDashes", ((String) bundle.get("npmVersion")).replaceAll("-", ""));
if (bundle.get("podVersion") != null)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module {{gitHost}}/{{gitUserId}}/{{gitRepoId}}{{#isGoSubmodule}}/{{packageName}}{{/isGoSubmodule}}
module {{gitHost}}/{{gitUserId}}/{{gitRepoId}}{{#isMajorVersionGreaterThanOne}}/v{{packageMajorVersion}}{{/isMajorVersionGreaterThanOne}}

go 1.13

Expand All @@ -8,4 +8,4 @@ require (
{{#withAWSV4Signature}}
github.com/aws/aws-sdk-go v1.34.14
{{/withAWSV4Signature}}
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ go 1.13
require (
github.com/stretchr/testify v1.4.0
golang.org/x/oauth2 v0.0.0-20210323180902-22b0adad7558
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ go 1.13
require (
github.com/stretchr/testify v1.4.0
golang.org/x/oauth2 v0.0.0-20210323180902-22b0adad7558
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

|Language|Version|Package Manager|README|Source|
|-|-|-|-|-|
|Go|6.0.0|[pkg.go.dev](https://pkg.go.dev/github.com/konfig-dev/newscatcher-go-sdk/go)|[README](https://github.com/konfig-dev/newscatcher-go-sdk/tree/HEAD/go#readme)|[Source](https://github.com/konfig-dev/newscatcher-go-sdk/tree/HEAD/go)|
|Go|1.0.0|[pkg.go.dev](https://pkg.go.dev/github.com/konfig-dev/newscatcher-go-sdk/go)|[README](https://github.com/konfig-dev/newscatcher-go-sdk/tree/HEAD/go#readme)|[Source](https://github.com/konfig-dev/newscatcher-go-sdk/tree/HEAD/go)|

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ go 1.13
require (
github.com/stretchr/testify v1.4.0
golang.org/x/oauth2 v0.0.0-20210323180902-22b0adad7558
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fixConfig:
href='https://newscatcherapi.com'>https://newscatcherapi.com</a>
generators:
go:
version: 6.0.0
version: 1.0.0
packageName: newscatcherapi
outputDirectory: go
git:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ go 1.13
require (
github.com/stretchr/testify v1.4.0
golang.org/x/oauth2 v0.0.0-20210323180902-22b0adad7558
)
)

0 comments on commit 791e38b

Please sign in to comment.