diff --git a/.github/MAINTENANCE.md b/.github/MAINTENANCE.md index d97d451..a0a89a1 100644 --- a/.github/MAINTENANCE.md +++ b/.github/MAINTENANCE.md @@ -33,7 +33,6 @@ The following Actions either need to be manually triggered or require significan 2. Update the [object](https://github.com/cdktf/cdktf-tf-module-stack/blob/b9939ad9f3bc6bc5bd7a4f348c953d776778506d/.projenrc.ts#L15-L29) 3. Run `npx projen` 4. Create a new PR with the title `chore(deps): update pinned versions of GitHub Actions` -- **`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. 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. diff --git a/.github/workflows/upgrade-cdktf.yml b/.github/workflows/upgrade-cdktf.yml index 9ee72e3..dc337b4 100644 --- a/.github/workflows/upgrade-cdktf.yml +++ b/.github/workflows/upgrade-cdktf.yml @@ -33,11 +33,14 @@ jobs: run: |- CDKTF_VERSION=$(yarn info cdktf --json | jq -r '.data.version') CDKTF_VERSION_SHORT=$(cut -d "." -f 2 <<< "$CDKTF_VERSION") + CONSTRUCTS_VERSION=$(yarn info cdktf --json | jq -r '.data.peerDependencies.constructs') + CONSTRUCTS_VERSION_EXACT=$(cut -d "^" -f 2 <<< "$CONSTRUCTS_VERSION") echo "value=$CDKTF_VERSION" >> $GITHUB_OUTPUT echo "short=$CDKTF_VERSION_SHORT" >> $GITHUB_OUTPUT + echo "constructs=$CONSTRUCTS_VERSION_EXACT" >> $GITHUB_OUTPUT - name: Run upgrade script if: steps.current_version.outputs.short != steps.latest_version.outputs.short - run: scripts/update-cdktf.sh ${{ steps.latest_version.outputs.value }} + run: scripts/update-cdktf.sh ${{ steps.latest_version.outputs.value }} ${{ steps.latest_version.outputs.constructs }} - name: Create draft pull request if: steps.current_version.outputs.short != steps.latest_version.outputs.short uses: peter-evans/create-pull-request@67ccf781d68cd99b580ae25a5c18a1cc84ffff1f diff --git a/.projenrc.ts b/.projenrc.ts index c2451f9..8c84a5c 100644 --- a/.projenrc.ts +++ b/.projenrc.ts @@ -28,7 +28,8 @@ const githubActionPinnedVersions = { "peter-evans/create-pull-request": "67ccf781d68cd99b580ae25a5c18a1cc84ffff1f", // v7.0.6 }; -/** JSII and TSII should always use the same major/minor version range */ +const constructsVersion = "10.0.25"; +/** JSII and TS should always use the same major/minor version range */ const typescriptVersion = "~5.5.0"; const project = new ConstructLibraryCdktf({ author: "HashiCorp", @@ -88,7 +89,7 @@ new Automerge(project); new UpgradeCDKTF(project); new UpgradeJSIIAndTypeScript(project, typescriptVersion); -project.addPeerDeps("cdktf@>=0.20.0", "constructs@^10.0.25"); +project.addPeerDeps("cdktf@>=0.20.0", `constructs@^${constructsVersion}`); project.addDevDeps( "semver", "@types/semver", diff --git a/projenrc/upgrade-cdktf.ts b/projenrc/upgrade-cdktf.ts index 3df1aff..b1080fd 100644 --- a/projenrc/upgrade-cdktf.ts +++ b/projenrc/upgrade-cdktf.ts @@ -54,8 +54,11 @@ export class UpgradeCDKTF { run: [ `CDKTF_VERSION=$(yarn info cdktf --json | jq -r '.data.version')`, `CDKTF_VERSION_SHORT=$(cut -d "." -f 2 <<< "$CDKTF_VERSION")`, + `CONSTRUCTS_VERSION=$(yarn info cdktf --json | jq -r '.data.peerDependencies.constructs')`, + `CONSTRUCTS_VERSION_EXACT=$(cut -d "^" -f 2 <<< "$CONSTRUCTS_VERSION")`, // strip the caret off the beginning `echo "value=$CDKTF_VERSION" >> $GITHUB_OUTPUT`, `echo "short=$CDKTF_VERSION_SHORT" >> $GITHUB_OUTPUT`, + `echo "constructs=$CONSTRUCTS_VERSION_EXACT" >> $GITHUB_OUTPUT`, ].join("\n"), // IMPORTANT: the above behavior changed in Yarn 2+; `yarn info` instead gives the version of the installed package // If/when we upgrade we'll likely want to switch to `yarn npm info`: https://yarnpkg.com/cli/npm/info @@ -63,7 +66,7 @@ export class UpgradeCDKTF { { name: "Run upgrade script", if: "steps.current_version.outputs.short != steps.latest_version.outputs.short", - run: "scripts/update-cdktf.sh ${{ steps.latest_version.outputs.value }}", + run: "scripts/update-cdktf.sh ${{ steps.latest_version.outputs.value }} ${{ steps.latest_version.outputs.constructs }}", }, { name: "Create draft pull request", diff --git a/scripts/update-cdktf.sh b/scripts/update-cdktf.sh index ebcee0a..af30b51 100755 --- a/scripts/update-cdktf.sh +++ b/scripts/update-cdktf.sh @@ -6,17 +6,24 @@ set -ex PROJECT_ROOT=$(cd "$(dirname "${BASH_SOURCE:-$0}")/.." && pwd) CDKTF_VERSION=$1 +CONSTRUCTS_VERSION=$2 if [ -z "$CDKTF_VERSION" ]; then - echo "Usage: $0 " + echo "Usage: $0 " + exit 1 +fi +if [ -z "$CONSTRUCTS_VERSION" ]; then + echo "Usage: $0 " exit 1 fi -echo "Updating to cdktf version $CDKTF_VERSION" +echo "Updating to cdktf version $CDKTF_VERSION and constructs version $CONSTRUCTS_VERSION" yarn sed -i "s/cdktfVersion: \".*\",/cdktfVersion: \"$CDKTF_VERSION\",/" "$PROJECT_ROOT/.projenrc.ts" sed -i "s/\"cdktf@.*\",/\"cdktf@>=$CDKTF_VERSION\",/" "$PROJECT_ROOT/.projenrc.ts" +sed -i "s/constructsVersion = \".*\";/constructsVersion = \"$CONSTRUCTS_VERSION\";/" "$PROJECT_ROOT/.projenrc.ts" CI=0 npx projen echo "Updating README" sed -i 's/`cdktf` >= .*/`cdktf` >= '"$CDKTF_VERSION"'/' "$PROJECT_ROOT/README.md" +sed -i 's/`constructs` >= .*/`constructs` >= '"$CONSTRUCTS_VERSION"'/' "$PROJECT_ROOT/README.md"