Skip to content
This repository was archived by the owner on Dec 10, 2025. It is now read-only.

Commit 496000f

Browse files
authored
chore(ci): update required version of constructs when cdktf is upgraded (#360)
1 parent c046c90 commit 496000f

5 files changed

Lines changed: 20 additions & 7 deletions

File tree

.github/MAINTENANCE.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ The following Actions either need to be manually triggered or require significan
3333
2. Update the [object](https://github.com/cdktf/cdktf-tf-module-stack/blob/b9939ad9f3bc6bc5bd7a4f348c953d776778506d/.projenrc.ts#L15-L29)
3434
3. Run `npx projen`
3535
4. Create a new PR with the title `chore(deps): update pinned versions of GitHub Actions`
36-
- **`constructs` library upgrades**: Because `constructs` is a peer dependency, the `upgrade-main` script described above will _never_ increment its version; this will always need to be done manually by [editing](https://github.com/cdktf/cdktf-tf-module-stack/blob/b9939ad9f3bc6bc5bd7a4f348c953d776778506d/.projenrc.ts#L91) `.projenrc.ts`. This could _in theory_ be (semi)automated like some of our other upgrade workflows described above for things like CDKTF, Node, and JSII, but in practice we currently have no logic or criteria that governs when `constructs` should be updated; as such, creating a custom workflow for it felt like more effort than it's really worth.
3736

3837
Also worth noting: Unlike many of our other Projen-based projects, this one does not have a script that automatically upgrades Node.js because this library does not enforce a `minNodeVersion`. If we did at some point want to start enforcing a `minNodeVersion`, we should copy over the `upgrade-node` script that our other Projen projects use.
3938

.github/workflows/upgrade-cdktf.yml

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.projenrc.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ const githubActionPinnedVersions = {
2828
"peter-evans/create-pull-request": "67ccf781d68cd99b580ae25a5c18a1cc84ffff1f", // v7.0.6
2929
};
3030

31-
/** JSII and TSII should always use the same major/minor version range */
31+
const constructsVersion = "10.0.25";
32+
/** JSII and TS should always use the same major/minor version range */
3233
const typescriptVersion = "~5.5.0";
3334
const project = new ConstructLibraryCdktf({
3435
author: "HashiCorp",
@@ -88,7 +89,7 @@ new Automerge(project);
8889
new UpgradeCDKTF(project);
8990
new UpgradeJSIIAndTypeScript(project, typescriptVersion);
9091

91-
project.addPeerDeps("cdktf@>=0.20.0", "constructs@^10.0.25");
92+
project.addPeerDeps("cdktf@>=0.20.0", `constructs@^${constructsVersion}`);
9293
project.addDevDeps(
9394
"semver",
9495
"@types/semver",

projenrc/upgrade-cdktf.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,19 @@ export class UpgradeCDKTF {
5454
run: [
5555
`CDKTF_VERSION=$(yarn info cdktf --json | jq -r '.data.version')`,
5656
`CDKTF_VERSION_SHORT=$(cut -d "." -f 2 <<< "$CDKTF_VERSION")`,
57+
`CONSTRUCTS_VERSION=$(yarn info cdktf --json | jq -r '.data.peerDependencies.constructs')`,
58+
`CONSTRUCTS_VERSION_EXACT=$(cut -d "^" -f 2 <<< "$CONSTRUCTS_VERSION")`, // strip the caret off the beginning
5759
`echo "value=$CDKTF_VERSION" >> $GITHUB_OUTPUT`,
5860
`echo "short=$CDKTF_VERSION_SHORT" >> $GITHUB_OUTPUT`,
61+
`echo "constructs=$CONSTRUCTS_VERSION_EXACT" >> $GITHUB_OUTPUT`,
5962
].join("\n"),
6063
// IMPORTANT: the above behavior changed in Yarn 2+; `yarn info` instead gives the version of the installed package
6164
// If/when we upgrade we'll likely want to switch to `yarn npm info`: https://yarnpkg.com/cli/npm/info
6265
},
6366
{
6467
name: "Run upgrade script",
6568
if: "steps.current_version.outputs.short != steps.latest_version.outputs.short",
66-
run: "scripts/update-cdktf.sh ${{ steps.latest_version.outputs.value }}",
69+
run: "scripts/update-cdktf.sh ${{ steps.latest_version.outputs.value }} ${{ steps.latest_version.outputs.constructs }}",
6770
},
6871
{
6972
name: "Create draft pull request",

scripts/update-cdktf.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,24 @@ set -ex
66

77
PROJECT_ROOT=$(cd "$(dirname "${BASH_SOURCE:-$0}")/.." && pwd)
88
CDKTF_VERSION=$1
9+
CONSTRUCTS_VERSION=$2
910

1011
if [ -z "$CDKTF_VERSION" ]; then
11-
echo "Usage: $0 <cdktf-version>"
12+
echo "Usage: $0 <cdktf-version> <constructs-version>"
13+
exit 1
14+
fi
15+
if [ -z "$CONSTRUCTS_VERSION" ]; then
16+
echo "Usage: $0 <cdktf-version> <constructs-version>"
1217
exit 1
1318
fi
1419

15-
echo "Updating to cdktf version $CDKTF_VERSION"
20+
echo "Updating to cdktf version $CDKTF_VERSION and constructs version $CONSTRUCTS_VERSION"
1621
yarn
1722
sed -i "s/cdktfVersion: \".*\",/cdktfVersion: \"$CDKTF_VERSION\",/" "$PROJECT_ROOT/.projenrc.ts"
1823
sed -i "s/\"cdktf@.*\",/\"cdktf@>=$CDKTF_VERSION\",/" "$PROJECT_ROOT/.projenrc.ts"
24+
sed -i "s/constructsVersion = \".*\";/constructsVersion = \"$CONSTRUCTS_VERSION\";/" "$PROJECT_ROOT/.projenrc.ts"
1925
CI=0 npx projen
2026

2127
echo "Updating README"
2228
sed -i 's/`cdktf` >= .*/`cdktf` >= '"$CDKTF_VERSION"'/' "$PROJECT_ROOT/README.md"
29+
sed -i 's/`constructs` >= .*/`constructs` >= '"$CONSTRUCTS_VERSION"'/' "$PROJECT_ROOT/README.md"

0 commit comments

Comments
 (0)