Skip to content

Commit

Permalink
feat: publish a top-level README in Go repositories
Browse files Browse the repository at this point in the history
  • Loading branch information
xiehan committed Dec 12, 2023
1 parent 5f67384 commit 455a7cf
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 4 deletions.
28 changes: 24 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ export class CdktfProviderProject extends cdk.JsiiProject {
const mavenName = `com.${mavenOrg}.${namespace}.providers.${getMavenName(
providerName
)}`;
const repositoryUrl = `github.com/${githubNamespace}/${namespace}-provider-${providerName.replace(
/-/g,
""
)}`;

const packageInfo: PackageInfo = {
npm: {
Expand All @@ -138,10 +142,7 @@ export class CdktfProviderProject extends cdk.JsiiProject {
mavenEndpoint,
},
publishToGo: {
moduleName: `github.com/${githubNamespace}/${namespace}-provider-${providerName.replace(
/-/g,
""
)}-go`,
moduleName: `${repositoryUrl}-go`,
gitUserEmail: "[email protected]",
gitUserName: "CDK for Terraform Team",
packageName: providerName.replace(/-/g, ""),
Expand Down Expand Up @@ -176,6 +177,25 @@ export class CdktfProviderProject extends cdk.JsiiProject {
name: "Remove copywrite hcl file",
run: "rm -f .repo/dist/go/.copywrite.hcl",
},
{
name: "Move the README file up a directory",
run: "mv .repo/dist/go/*/README.md .repo/dist/go/README.md",
continueOnError: true, // can be removed later once confirmed this works
},
{
name: "Remove some text from the README that doesn't apply to Go",
run: [
"sed -i 's/# CDKTF prebuilt bindings for/# CDKTF Go bindings for/' .repo/dist/go/README.md",
// @see https://stackoverflow.com/a/49511949
"sed -i -e '/## Available Packages/,/### Go/!b' -e '/### Go/!d;p; s/### Go/## Go Package/' -e 'd' .repo/dist/go/README.md",
// sed -e is black magic and for whatever reason the string replace doesn't work so let's try it again:
"sed -i 's/### Go/## Go Package/' .repo/dist/go/README.md",
// Just straight up delete these full lines and everything in between them:
"sed -i -e '/API.typescript.md/,/You can also visit a hosted version/!b' -e 'd' dist/go/README.md",
`sed -i 's|Find auto-generated docs for this provider here:|Find auto-generated docs for this provider [here](https://${repositoryUrl}/blob/main/docs/API.go.md).|' .repo/dist/go/README.md`,
].join("\n"),
continueOnError: true, // can be removed later once confirmed this works
},
{
name: "Collect go Artifact",
run: "mv .repo/dist dist",
Expand Down
33 changes: 33 additions & 0 deletions test/__snapshots__/index.test.ts.snap

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

0 comments on commit 455a7cf

Please sign in to comment.