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

fix: adjust to new release step #394

Merged
merged 2 commits into from
Jan 19, 2024
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
7 changes: 1 addition & 6 deletions .eslintrc.json

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

15 changes: 12 additions & 3 deletions .github/workflows/release.yml

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

2 changes: 1 addition & 1 deletion .gitignore

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

5 changes: 4 additions & 1 deletion .npmignore

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

2 changes: 1 addition & 1 deletion .projen/deps.json

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

3 changes: 2 additions & 1 deletion .projen/tasks.json

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

2 changes: 1 addition & 1 deletion .projenrc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const project = new cdk.JsiiProject({
pullRequestTemplate: false,
jsiiVersion: "~5.2.0",
typescriptVersion: "~5.2.0", // should always be the same major/minor as JSII
peerDeps: ["projen@^0.77.2", "constructs@^10.3.0"],
peerDeps: ["projen@^0.79.2", "constructs@^10.3.0"],
deps: ["change-case", "fs-extra"],
devDeps: ["@types/fs-extra", "glob"],
bundledDeps: ["change-case", "fs-extra"],
Expand Down
51 changes: 45 additions & 6 deletions API.md

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

18 changes: 10 additions & 8 deletions package.json

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

27 changes: 20 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,12 @@ export class CdktfProviderProject extends cdk.JsiiProject {
"sed -i 's/# CDKTF prebuilt bindings for/# CDKTF Go bindings for/' .repo/dist/go/*/README.md",
// @see https://stackoverflow.com/a/49511949
// eslint-disable-next-line prettier/prettier
`sed -i -e '/## ${isDeprecated ? 'Deprecated' : 'Available'} Packages/,/### Go/!b' -e '/### Go/!d;p; s/### Go/## Go Package/' -e 'd' .repo/dist/go/*/README.md`,
// prettier-ignore
`sed -i -e '/## ${isDeprecated ? "Deprecated" : "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:
// eslint-disable-next-line prettier/prettier
`sed -i 's/### Go/## ${isDeprecated ? 'Deprecated' : 'Go'} Package/' .repo/dist/go/*/README.md`,
// prettier-ignore
`sed -i 's/### Go/## ${isDeprecated ? "Deprecated" : "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' .repo/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`,
Expand Down Expand Up @@ -420,15 +422,16 @@ export class CdktfProviderProject extends cdk.JsiiProject {
this.github?.tryFindWorkflow("release") as any
).jobs.release.steps;
const gitRemoteJob = releaseJobSteps.find((it) => it.id === "git_remote");
assert(
gitRemoteJob.run ===
'echo "latest_commit=$(git ls-remote origin -h ${{ github.ref }} | cut -f1)" >> $GITHUB_OUTPUT',
prettyAssertEqual(
gitRemoteJob.run,
'echo "latest_commit=$(git ls-remote origin -h ${{ github.ref }} | cut -f1)" >> $GITHUB_OUTPUT\ncat $GITHUB_OUTPUT',
"git_remote step in release workflow did not match expected string, please check if the workaround still works!"
);
const previousCommand = gitRemoteJob.run;
const previousCommand = gitRemoteJob.run.replace("\n", " && ");

const cancelCommand =
'echo "latest_commit=release_cancelled" >> $GITHUB_OUTPUT'; // this cancels the release via a non-matching SHA;
gitRemoteJob.run = `node ./scripts/should-release.js && ${previousCommand} || ${cancelCommand}`;
gitRemoteJob.run = `node ./scripts/should-release.js && $(${previousCommand}) || ${cancelCommand}`;
gitRemoteJob.name +=
" or cancel via faking a SHA if release was cancelled";
}
Expand Down Expand Up @@ -506,3 +509,13 @@ export class CdktfProviderProject extends cdk.JsiiProject {
});
}
}

function prettyAssertEqual<T>(subject: T, expected: T, message?: string): void {
if (subject !== expected) {
throw new Error(
`${message ?? "Assertion failed"}: expected ${JSON.stringify(
expected
)} but got ${JSON.stringify(subject)}`
);
}
}
Loading