diff --git a/.github/MAINTENANCE.md b/.github/MAINTENANCE.md index a0a89a1..db1b689 100644 --- a/.github/MAINTENANCE.md +++ b/.github/MAINTENANCE.md @@ -15,6 +15,8 @@ Dependency upgrades (for security purposes as well as a best practice) can be di The following Actions exist to automate various dependency upgrades: +- [upgrade-jsii-typescript](https://github.com/cdktf/cdktf-tf-module-stack/actions/workflows/upgrade-jsii-typescript.yml): This is a custom workflow (source [here](https://github.com/cdktf/cdktf-tf-module-stack/blob/main/projenrc/upgrade-jsii-typescript.ts)) that checks the [JSII support timeline](https://github.com/aws/jsii-compiler/blob/main/README.md#gear-maintenance--support) daily via [this](https://github.com/cdktf/cdktf-tf-module-stack/blob/main/scripts/check-jsii-versions.js) script to see if the current version is less than 30 days away from EOS, and if so, creates a PR upgrading to the next supported version. The code for the upgrade itself lives in [this](https://github.com/cdktf/cdktf-tf-module-stack/blob/main/scripts/update-jsii-typescript.sh) script. This process is 100% automated; as long as the build succeeds and any tests pass, the PR will be automatically merged without any human intervention. + - This workflow can also be manually triggered, optionally taking a hard-coded JSII/TypeScript version as input in case we ever want to upgrade to a newer version without waiting until the old one is less than 30 days away from EOS. - [upgrade-main](https://github.com/cdktf/cdktf-tf-module-stack/actions/workflows/upgrade-main.yml): This is a Projen built-in/default workflow that handles automated dependency updates. It currently runs on a weekly basis, which can be configured [here](https://github.com/cdktf/cdktf-tf-module-stack/blob/b9939ad9f3bc6bc5bd7a4f348c953d776778506d/.projenrc.ts#L49). Projen will upgrade itself as part of this process. This process is 100% automated; as long as the build succeeds and any tests pass, the PR that is generated will be automatically merged without any human intervention. Dependabot is also [configured](https://github.com/cdktf/cdktf-tf-module-stack/blob/main/.github/dependabot.yml) to check for new security updates daily and, if found, make changes to the lockfile only. This is because Dependabot can sometimes address security issues in dependencies more quickly than Projen due to its atomic nature. While you could tweak the Dependabot settings, note that Projen and Dependabot do not generally play nicely together; in particular, Dependabot cannot make changes to `package.json` because Projen would just override these changes (hence the reason why Dependabot is currently limited to lockfile-only). If you wanted to fully automate dependency management using Dependabot, you would want to disable Projen's [automatic updates](https://projen.io/docs/api/typescript#projen.typescript.TypeScriptProjectOptions.property.depsUpgrade). @@ -24,7 +26,6 @@ Dependabot is also [configured](https://github.com/cdktf/cdktf-tf-module-stack/b The following Actions either need to be manually triggered or require significant manual effort as part of the upgrade process: - [upgrade-cdktf](https://github.com/cdktf/cdktf-tf-module-stack/actions/workflows/upgrade-cdktf.yml): This is a custom workflow (source [here](https://github.com/cdktf/cdktf-tf-module-stack/blob/main/projenrc/upgrade-cdktf.ts)) that runs four times a day and checks whether there is a new minor version of CDKTF itself (e.g. `0.19`, `0.20`, `0.21`, etc.), using the latest version published to npm as the source of truth. If a new version is found, it runs [this](https://github.com/cdktf/cdktf-tf-module-stack/blob/main/scripts/update-cdktf.sh) script to update the CDKTF version in all the right places, and then it creates a draft PR. The reason for the draft status is because a few steps related to the upgrade cannot be automated and must be done manually by an engineer; these are outlined step-by-step in the PR body. Once the steps are completed, the PR can be marked as ready for review & approved in order to complete the upgrade. -- [upgrade-jsii-typescript](https://github.com/cdktf/cdktf-tf-module-stack/actions/workflows/upgrade-jsii-typescript.yml): This is a custom workflow (source [here](https://github.com/cdktf/cdktf-tf-module-stack/blob/main/projenrc/upgrade-jsii-typescript.ts)) that must be manually triggered because there currently is no programmatic way to determine when a JSII version is no longer supported. This means that somebody should be monitoring the [JSII support timeline](https://github.com/aws/jsii-compiler/blob/main/README.md#gear-maintenance--support) to determine when it's time to upgrade. The script takes as input the desired new version, and all the steps afterwards are fully automated. The code for the upgrade itself lives in [this](https://github.com/cdktf/cdktf-tf-module-stack/blob/main/scripts/update-jsii-typescript.sh) script. ### Not Automated diff --git a/.github/workflows/upgrade-jsii-typescript.yml b/.github/workflows/upgrade-jsii-typescript.yml index 978b475..5023c01 100644 --- a/.github/workflows/upgrade-jsii-typescript.yml +++ b/.github/workflows/upgrade-jsii-typescript.yml @@ -2,48 +2,101 @@ name: upgrade-jsii-typescript on: + schedule: + - cron: 36 15 * * * workflow_dispatch: inputs: - new_version: + version: description: New JSII/TypeScript version (e.g. "5.5.0"), without carets or tildes - required: true - default: 5.6.0 + required: false type: string concurrency: group: ${{ github.workflow }}-${{ github.ref }} jobs: + version: + name: Determine version to upgrade to + runs-on: ubuntu-latest + permissions: + contents: read + outputs: + current: ${{ steps.current_version.outputs.value }} + latest: ${{ steps.latest_version.outputs.value }} + short: ${{ steps.latest_version.outputs.short }} + should_upgrade: ${{ steps.latest_version.outputs.is_newer }} + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 + - name: Setup Node.js + uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af + with: {} + - name: Install + run: yarn install + - name: Get current JSII version + id: current_version + run: |- + CURRENT_VERSION=$(npm list jsii --depth=0 --json | jq -r '.dependencies.jsii.version') + CURRENT_VERSION_SHORT=$(cut -d "." -f 1,2 <<< "$CURRENT_VERSION") + CURRENT_VERSION_MAJOR=$(cut -d "." -f 1 <<< "$CURRENT_VERSION") + CURRENT_VERSION_MINOR=$(cut -d "." -f 2 <<< "$CURRENT_VERSION") + echo "CURRENT_JSII_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV + echo "CURRENT_JSII_VERSION_SHORT=$CURRENT_VERSION_SHORT" >> $GITHUB_ENV + echo "CURRENT_JSII_VERSION_MAJOR=$CURRENT_VERSION_MAJOR" >> $GITHUB_ENV + echo "CURRENT_JSII_VERSION_MINOR=$CURRENT_VERSION_MINOR" >> $GITHUB_ENV + echo "value=$CURRENT_VERSION" >> $GITHUB_OUTPUT + - name: Get the earliest supported JSII version whose EOS date is at least a month away + if: ${{ ! inputs.version }} + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea + with: + script: |- + const script = require('./scripts/check-jsii-versions.js') + await script({github, context, core}) + - name: Save the manually-input version to environment variables for comparison + if: ${{ inputs.version }} + env: + NEW_VERSION: ${{ inputs.version }} + run: |- + NEW_VERSION_SHORT=$(cut -d "." -f 1,2 <<< "$NEW_VERSION") + NEW_VERSION_MAJOR=$(cut -d "." -f 1 <<< "$NEW_VERSION") + NEW_VERSION_MINOR=$(cut -d "." -f 2 <<< "$NEW_VERSION") + echo "NEW_JSII_VERSION=$NEW_VERSION" >> $GITHUB_ENV + echo "NEW_JSII_VERSION_SHORT=$NEW_VERSION_SHORT" >> $GITHUB_ENV + echo "NEW_JSII_VERSION_MAJOR=$NEW_VERSION_MAJOR" >> $GITHUB_ENV + echo "NEW_JSII_VERSION_MINOR=$NEW_VERSION_MINOR" >> $GITHUB_ENV + - name: Output env variables for use in the next job + id: latest_version + run: |- + echo "value=$NEW_JSII_VERSION" >> $GITHUB_OUTPUT + echo "short=$NEW_JSII_VERSION_SHORT" >> $GITHUB_OUTPUT + [[ "$NEW_JSII_VERSION_MAJOR" > "$CURRENT_JSII_VERSION_MAJOR" || ("$NEW_JSII_VERSION_MAJOR" == "$CURRENT_JSII_VERSION_MAJOR" && "$NEW_JSII_VERSION_MINOR" > "$CURRENT_JSII_VERSION_MINOR") ]] && IS_NEWER=true + echo "is_newer=$IS_NEWER" >> $GITHUB_OUTPUT upgrade: name: Upgrade JSII & TypeScript + needs: version runs-on: ubuntu-latest permissions: contents: read env: CI: "true" CHECKPOINT_DISABLE: "1" - NEW_VERSION: ${{ inputs.new_version }} + if: always() && needs.version.outputs.should_upgrade steps: - name: Checkout uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 - name: Setup Node.js uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af + with: {} - name: Install run: yarn install - name: Run upgrade script - run: scripts/update-jsii-typescript.sh $NEW_VERSION - - name: Get values for pull request - id: latest_version - run: |- - NEW_VERSION_SHORT=$(cut -d "." -f 1,2 <<< "$NEW_VERSION") - echo "value=$NEW_VERSION" >> $GITHUB_OUTPUT - echo "short=$NEW_VERSION_SHORT" >> $GITHUB_OUTPUT + run: scripts/update-jsii-typescript.sh ${{ needs.version.outputs.latest }} - name: Create Pull Request uses: peter-evans/create-pull-request@67ccf781d68cd99b580ae25a5c18a1cc84ffff1f with: - commit-message: "chore: upgrade jsii & typescript to v${{ steps.latest_version.outputs.short }}" - branch: auto/upgrade-jsii-ts-${{ steps.latest_version.outputs.short }} base: main - title: "chore: upgrade jsii & typescript to v${{ steps.latest_version.outputs.short }}" - body: "This PR increases the version of JSII and TypeScript to `~${{ steps.latest_version.outputs.value }}`, presumably because the previous version is close to EOL or no longer supported. Support timeline: https://github.com/aws/jsii-compiler/blob/main/README.md#gear-maintenance--support" + branch: auto/upgrade-jsii-ts-${{ needs.version.outputs.short }} + commit-message: "chore(deps): upgrade jsii & typescript to v${{ needs.version.outputs.short }}" + title: "chore(deps): upgrade jsii & typescript to v${{ needs.version.outputs.short }}" + body: "This PR increases the version of JSII and TypeScript to `~${{ needs.version.outputs.latest }}` because the previous version is close to EOL or no longer supported. Support timeline: https://github.com/aws/jsii-compiler/blob/main/README.md#gear-maintenance--support" labels: auto-approve,automerge,automated token: ${{ secrets.PROJEN_GITHUB_TOKEN }} author: team-tf-cdk diff --git a/.projen/deps.json b/.projen/deps.json index def7f59..e17d94d 100644 --- a/.projen/deps.json +++ b/.projen/deps.json @@ -19,10 +19,6 @@ "version": "ts5.5", "type": "build" }, - { - "name": "@types/semver", - "type": "build" - }, { "name": "@typescript-eslint/eslint-plugin", "version": "^8", @@ -103,10 +99,6 @@ "name": "projen", "type": "build" }, - { - "name": "semver", - "type": "build" - }, { "name": "ts-jest", "type": "build" diff --git a/.projen/tasks.json b/.projen/tasks.json index 6f2e9ab..7a9734b 100644 --- a/.projen/tasks.json +++ b/.projen/tasks.json @@ -358,13 +358,13 @@ }, "steps": [ { - "exec": "npx npm-check-updates@16 --upgrade --target=minor --peer --no-deprecated --dep=dev,peer,prod,optional --filter=@types/jest,@types/semver,eslint-config-prettier,eslint-import-resolver-typescript,eslint-plugin-import,eslint-plugin-prettier,jest,jsii-diff,jsii-docgen,jsii-pacmak,prettier,projen,semver,ts-jest,ts-node" + "exec": "npx npm-check-updates@16 --upgrade --target=minor --peer --no-deprecated --dep=dev,peer,prod,optional --filter=@types/jest,eslint-config-prettier,eslint-import-resolver-typescript,eslint-plugin-import,eslint-plugin-prettier,jest,jsii-diff,jsii-docgen,jsii-pacmak,prettier,projen,ts-jest,ts-node" }, { "exec": "yarn install --check-files" }, { - "exec": "yarn upgrade @cdktf/provider-null @cdktf/provider-random @types/jest @types/node @types/semver @typescript-eslint/eslint-plugin @typescript-eslint/parser commit-and-tag-version constructs eslint-config-prettier eslint-import-resolver-typescript eslint-plugin-import eslint-plugin-prettier eslint jest jest-junit jsii-diff jsii-docgen jsii-pacmak jsii-rosetta jsii prettier projen semver ts-jest ts-node typescript cdktf" + "exec": "yarn upgrade @cdktf/provider-null @cdktf/provider-random @types/jest @types/node @typescript-eslint/eslint-plugin @typescript-eslint/parser commit-and-tag-version constructs eslint-config-prettier eslint-import-resolver-typescript eslint-plugin-import eslint-plugin-prettier eslint jest jest-junit jsii-diff jsii-docgen jsii-pacmak jsii-rosetta jsii prettier projen ts-jest ts-node typescript cdktf" }, { "exec": "npx projen" diff --git a/.projenrc.ts b/.projenrc.ts index 1fe47a0..1165c70 100644 --- a/.projenrc.ts +++ b/.projenrc.ts @@ -91,8 +91,6 @@ new UpgradeJSIIAndTypeScript(project, typescriptVersion); project.addPeerDeps("cdktf@>=0.20.0", `constructs@^${constructsVersion}`); project.addDevDeps( - "semver", - "@types/semver", "@cdktf/provider-null@>=10.0.0", "@cdktf/provider-random@>=11.0.0" ); diff --git a/package.json b/package.json index 11ef0a7..e0c9213 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,6 @@ "@cdktf/provider-random": ">=11.0.0", "@types/jest": "^29", "@types/node": "ts5.5", - "@types/semver": "^7.7.0", "@typescript-eslint/eslint-plugin": "^8", "@typescript-eslint/parser": "^8", "cdktf": "0.20.0", @@ -66,7 +65,6 @@ "jsii-rosetta": "~5.5.0", "prettier": "^2.8.8", "projen": "^0.91.18", - "semver": "^7.7.1", "ts-jest": "^29", "ts-node": "10.9.2", "typescript": "~5.5.0" diff --git a/projenrc/upgrade-jsii-typescript.ts b/projenrc/upgrade-jsii-typescript.ts index bb89f9b..f74df7b 100644 --- a/projenrc/upgrade-jsii-typescript.ts +++ b/projenrc/upgrade-jsii-typescript.ts @@ -5,13 +5,11 @@ import { javascript } from "projen"; import { JobPermission } from "projen/lib/github/workflows-model"; -import * as semver from "semver"; /** * Helper script for upgrading JSII and TypeScript in the right way. - * This currently isn't automated (the workflow must be manually run) - * because there is no way to programmatically determine the EOL date - * of a JSII version range. This can be found at: + * Auto-updates to the next version a month before the previous JSII version goes EOS + * Can also be triggered manually with a hard-coded version of JSII/TypeScript as input * https://github.com/aws/jsii-compiler/blob/main/README.md#gear-maintenance--support */ export class UpgradeJSIIAndTypeScript { @@ -20,15 +18,13 @@ export class UpgradeJSIIAndTypeScript { if (!workflow) throw new Error("no workflow defined"); const plainVersion = typescriptVersion.replace("~", ""); - const defaultVersion = semver.inc(plainVersion, "minor"); - workflow.on({ + schedule: [{ cron: "36 15 * * *" }], // Runs once a day workflowDispatch: { inputs: { - newVersion: { + version: { description: `New JSII/TypeScript version (e.g. "${plainVersion}"), without carets or tildes`, - required: true, - default: defaultVersion, + required: false, type: "string", }, }, @@ -40,49 +36,143 @@ export class UpgradeJSIIAndTypeScript { }; workflow.addJobs({ - upgrade: { - name: "Upgrade JSII & TypeScript", + version: { + name: "Determine version to upgrade to", runsOn: ["ubuntu-latest"], steps: [ { name: "Checkout", - uses: "actions/checkout@v3", + uses: "actions/checkout", }, { name: "Setup Node.js", - uses: "actions/setup-node@v3", + uses: "actions/setup-node", + with: { + "node-version": project.minNodeVersion, + }, }, { name: "Install", run: "yarn install", }, { - name: "Run upgrade script", - run: "scripts/update-jsii-typescript.sh $NEW_VERSION", + name: "Get current JSII version", + id: "current_version", + run: [ + `CURRENT_VERSION=$(npm list jsii --depth=0 --json | jq -r '.dependencies.jsii.version')`, + `CURRENT_VERSION_SHORT=$(cut -d "." -f 1,2 <<< "$CURRENT_VERSION")`, + `CURRENT_VERSION_MAJOR=$(cut -d "." -f 1 <<< "$CURRENT_VERSION")`, + `CURRENT_VERSION_MINOR=$(cut -d "." -f 2 <<< "$CURRENT_VERSION")`, + `echo "CURRENT_JSII_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV`, + `echo "CURRENT_JSII_VERSION_SHORT=$CURRENT_VERSION_SHORT" >> $GITHUB_ENV`, + `echo "CURRENT_JSII_VERSION_MAJOR=$CURRENT_VERSION_MAJOR" >> $GITHUB_ENV`, + `echo "CURRENT_JSII_VERSION_MINOR=$CURRENT_VERSION_MINOR" >> $GITHUB_ENV`, + `echo "value=$CURRENT_VERSION" >> $GITHUB_OUTPUT`, + ].join("\n"), }, { - name: "Get values for pull request", - id: "latest_version", + name: "Get the earliest supported JSII version whose EOS date is at least a month away", + if: "${{ ! inputs.version }}", + uses: "actions/github-script", + with: { + script: [ + `const script = require('./scripts/check-jsii-versions.js')`, + `await script({github, context, core})`, + ].join("\n"), + }, + }, + { + // In an ideal world this is where we'd validate that the manually-input version actually exists + // In practice, I couldn't figure out how to do this properly and it wasn't worth the effort + // name: "Check if the manually-input version actually exists (has been published to NPM)", + name: "Save the manually-input version to environment variables for comparison", + if: "${{ inputs.version }}", + env: { + NEW_VERSION: "${{ inputs.version }}", + }, run: [ + // My command line skillz aren't good enough to figure out how to make the below work (error if the version doesn't exist) + // `yarn info jsii versions --json | jq -e 'select(.data | index("$NEW_VERSION"))`, `NEW_VERSION_SHORT=$(cut -d "." -f 1,2 <<< "$NEW_VERSION")`, - `echo "value=$NEW_VERSION" >> $GITHUB_OUTPUT`, - `echo "short=$NEW_VERSION_SHORT" >> $GITHUB_OUTPUT`, + `NEW_VERSION_MAJOR=$(cut -d "." -f 1 <<< "$NEW_VERSION")`, + `NEW_VERSION_MINOR=$(cut -d "." -f 2 <<< "$NEW_VERSION")`, + `echo "NEW_JSII_VERSION=$NEW_VERSION" >> $GITHUB_ENV`, + `echo "NEW_JSII_VERSION_SHORT=$NEW_VERSION_SHORT" >> $GITHUB_ENV`, + `echo "NEW_JSII_VERSION_MAJOR=$NEW_VERSION_MAJOR" >> $GITHUB_ENV`, + `echo "NEW_JSII_VERSION_MINOR=$NEW_VERSION_MINOR" >> $GITHUB_ENV`, + ].join("\n"), + }, + { + name: "Output env variables for use in the next job", + id: "latest_version", + run: [ + `echo "value=$NEW_JSII_VERSION" >> $GITHUB_OUTPUT`, + `echo "short=$NEW_JSII_VERSION_SHORT" >> $GITHUB_OUTPUT`, + `[[ "$NEW_JSII_VERSION_MAJOR" > "$CURRENT_JSII_VERSION_MAJOR" || ("$NEW_JSII_VERSION_MAJOR" == "$CURRENT_JSII_VERSION_MAJOR" && "$NEW_JSII_VERSION_MINOR" > "$CURRENT_JSII_VERSION_MINOR") ]] && IS_NEWER=true`, + `echo "is_newer=$IS_NEWER" >> $GITHUB_OUTPUT`, ].join("\n"), }, + ], + outputs: { + current: { + stepId: "current_version", + outputName: "value", + }, + latest: { + stepId: "latest_version", + outputName: "value", + }, + short: { + stepId: "latest_version", + outputName: "short", + }, + should_upgrade: { + stepId: "latest_version", + outputName: "is_newer", + }, + }, + permissions: { + contents: JobPermission.READ, + }, + }, + upgrade: { + name: "Upgrade JSII & TypeScript", + runsOn: ["ubuntu-latest"], + needs: ["version"], + if: "always() && needs.version.outputs.should_upgrade", + steps: [ + { + name: "Checkout", + uses: "actions/checkout", + }, + { + name: "Setup Node.js", + uses: "actions/setup-node", + with: { + "node-version": project.minNodeVersion, + }, + }, + { + name: "Install", + run: "yarn install", + }, + { + name: "Run upgrade script", + run: "scripts/update-jsii-typescript.sh ${{ needs.version.outputs.latest }}", + }, { name: "Create Pull Request", - uses: "peter-evans/create-pull-request@v3", + uses: "peter-evans/create-pull-request", with: { - "commit-message": - "chore: upgrade jsii & typescript to v${{ steps.latest_version.outputs.short }}", - branch: - "auto/upgrade-jsii-ts-${{ steps.latest_version.outputs.short }}", base: "main", + branch: "auto/upgrade-jsii-ts-${{ needs.version.outputs.short }}", + "commit-message": + "chore(deps): upgrade jsii & typescript to v${{ needs.version.outputs.short }}", title: - "chore: upgrade jsii & typescript to v${{ steps.latest_version.outputs.short }}", + "chore(deps): upgrade jsii & typescript to v${{ needs.version.outputs.short }}", body: [ - "This PR increases the version of JSII and TypeScript to `~${{ steps.latest_version.outputs.value }}`, ", - "presumably because the previous version is close to EOL or no longer supported. Support timeline: ", + "This PR increases the version of JSII and TypeScript to `~${{ needs.version.outputs.latest }}` ", + "because the previous version is close to EOL or no longer supported. Support timeline: ", "https://github.com/aws/jsii-compiler/blob/main/README.md#gear-maintenance--support", ].join(" "), labels: "auto-approve,automerge,automated", @@ -97,7 +187,6 @@ export class UpgradeJSIIAndTypeScript { env: { CI: "true", CHECKPOINT_DISABLE: "1", - NEW_VERSION: "${{ inputs.new_version }}", // should be newVersion but Projen converts it to snake_case }, permissions: { contents: JobPermission.READ, diff --git a/scripts/check-jsii-versions.js b/scripts/check-jsii-versions.js new file mode 100755 index 0000000..a964cf0 --- /dev/null +++ b/scripts/check-jsii-versions.js @@ -0,0 +1,42 @@ +/** + * Copyright (c) HashiCorp, Inc. + * SPDX-License-Identifier: MPL-2.0 + */ +const today = new Date(); +const oneMonthFromToday = new Date(); +oneMonthFromToday.setDate(today.getDate() + 30); +// console.debug("oneMonthFromToday", oneMonthFromToday.toDateString()); + +/** Return the earliest supported version whose EOS date is at least a month away */ +async function getEarliestSupportedVersion() { + // https://github.com/aws/jsii-compiler/blob/main/releases.json + const response = await fetch("https://raw.githubusercontent.com/aws/jsii-compiler/main/releases.json"); + const data = await response.json(); + const activelySupportedVersions = Object.entries(data.maintenance).filter(([version, supportEndDate]) => { + return new Date(supportEndDate) > oneMonthFromToday; + }).sort((a, b) => { + // Very naive sorting function: treat "5.4" like (int) 54, "5.5" like (int) 55, etc. and compare accordingly + return parseInt(a[0].replace(".", ""), 10) > parseInt(b[0].replace(".", ""), 10); + }); + + console.debug("Actively supported versions with an EOS date at least 1 month away") + console.debug(Object.fromEntries(activelySupportedVersions)); + + return activelySupportedVersions[0][0]; +} + +async function getDesiredVersion() { + const earliestSupportedVersion = await getEarliestSupportedVersion(); + console.debug("earliestSupportedVersion", earliestSupportedVersion); + + return earliestSupportedVersion; +} + +module.exports = async ({github, context, core}) => { + const version = await getDesiredVersion(); + + core.exportVariable('NEW_JSII_VERSION', version + ".0"); // e.g. "5.4.0" + core.exportVariable('NEW_JSII_VERSION_SHORT', version); // e.g. "5.4" + core.exportVariable('NEW_JSII_VERSION_MAJOR', version.split(".")[0]); // e.g. "5" + core.exportVariable('NEW_JSII_VERSION_MINOR', version.split(".")[1]); // e.g. "4" +} diff --git a/yarn.lock b/yarn.lock index 17588e9..cf9cd6e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -889,11 +889,6 @@ resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.4.tgz#56e2cc26c397c038fab0e3a917a12d5c5909e901" integrity sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA== -"@types/semver@^7.7.0": - version "7.7.0" - resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.7.0.tgz#64c441bdae033b378b6eef7d0c3d77c329b9378e" - integrity sha512-k107IF4+Xr7UHjwDc7Cfd6PRQfbdkiRabXGRjo07b4WyPahFBZCZ1sE+BNxYIJPPg73UkfOsVOLwqVc/6ETrIA== - "@types/stack-utils@^2.0.0": version "2.0.3" resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.3.tgz#6209321eb2c1712a7e7466422b8cb1fc0d9dd5d8"