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

chore(ci): update required version of constructs when cdktf is upgraded #238

Merged
merged 1 commit into from
Jan 9, 2025
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
1 change: 0 additions & 1 deletion .github/MAINTENANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ The following Actions either need to be manually triggered or require significan
2. Update the [object](https://github.com/cdktf/cdktf-multi-stack-tfe/blob/10616ec183618c636849b09f034b1d0e45d59855/.projenrc.ts#L20-L31)
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-multi-stack-tfe/blob/10616ec183618c636849b09f034b1d0e45d59855/.projenrc.ts#L15) `.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.

Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/upgrade-cdktf.yml

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 @@ -13,7 +13,7 @@ import { UpgradeJSIIAndTypeScript } from "./projenrc/upgrade-jsii-typescript";

const cdktfVersion = ">=0.20.0";
const constructVersion = "^10.3.0";
/** JSII and TSII should always use the same major/minor version range */
/** JSII and TS should always use the same major/minor version range */
const typescriptVersion = "~5.5.0";
const name = "cdktf-multi-stack-tfe";

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ By using the software in this repository, you acknowledge that:
## Compatibility

- `cdktf` >= 0.20.0
- `constructs` >= 10.0.107
- `constructs` >= 10.3.0

## Usage

Expand Down
5 changes: 4 additions & 1 deletion projenrc/upgrade-cdktf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,19 @@ 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
},
{
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",
Expand Down
13 changes: 10 additions & 3 deletions scripts/update-cdktf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,23 @@ set -ex

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

if [ -z "$CDKTF_VERSION" ]; then
echo "Usage: $0 <cdktf-version>"
echo "Usage: $0 <cdktf-version> <constructs-version>"
exit 1
fi
if [ -z "$CONSTRUCTS_VERSION" ]; then
echo "Usage: $0 <cdktf-version> <constructs-version>"
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/const cdktfVersion = \".*\";/const cdktfVersion = \">=$CDKTF_VERSION\";/" "$PROJECT_ROOT/.projenrc.ts"
sed -i "s/cdktfVersion = \".*\";/cdktfVersion = \">=$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"
Loading