Skip to content

Commit

Permalink
fix: adjust to new release step
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielMSchmidt committed Jan 18, 2024
1 parent de50451 commit 88a36de
Show file tree
Hide file tree
Showing 13 changed files with 247 additions and 150 deletions.
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.

29 changes: 22 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,14 @@ 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`,
`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`,
`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 +424,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 +511,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

0 comments on commit 88a36de

Please sign in to comment.