-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(ci): add workflow for upgrading jsii & typescript (#470)
- Loading branch information
Showing
8 changed files
with
379 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
# Copyright (c) HashiCorp, Inc. | ||
# SPDX-License-Identifier: MPL-2.0 | ||
|
||
set -ex | ||
|
||
PROJECT_ROOT=$(cd "$(dirname "${BASH_SOURCE:-$0}")/.." && pwd) | ||
NEW_VERSION=$1 | ||
|
||
if [ -z "$NEW_VERSION" ]; then | ||
echo "Usage: $0 <typescript-version>" | ||
exit 1 | ||
fi | ||
|
||
echo "Updating JSII & TypeScript version to $NEW_VERSION" | ||
yarn | ||
sed -i "s/typescriptVersion = \".*\";/typescriptVersion = \"~$NEW_VERSION\";/" "$PROJECT_ROOT/.projenrc.ts" | ||
CI=0 npx projen | ||
|
||
echo "Done" |
Oops, something went wrong.