Skip to content

upgrade-jsii-typescript #2

upgrade-jsii-typescript

upgrade-jsii-typescript #2

name: upgrade-jsii-typescript
on:
schedule:
- cron: 07 13 * * 1-5
workflow_dispatch:
inputs:
version:
description: New JSII/TypeScript version (e.g. "5.4.0"), without carets or tildes
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 # v4.2.2
- name: Setup Node.js
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: "18"
- 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 # v7.0.1
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
if: always() && needs.version.outputs.should_upgrade
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Node.js
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: "18"
- name: Install
run: yarn install
- name: Install the new version of TypeScript in this project
env:
NEW_VERSION: ${{ needs.version.outputs.latest }}
run: yarn add -D typescript@~$NEW_VERSION
- name: Set the new version in the Projen template
env:
NEW_VERSION: ${{ needs.version.outputs.latest }}
run: |-
sed -i "s/typescriptVersion: \".*\",/typescriptVersion: \"~$NEW_VERSION\",/" ./projenrc.template.js
sed -i "s/jsiiVersion: \".*\",/jsiiVersion: \"~$NEW_VERSION\",/" ./projenrc.template.js
- name: Create Pull Request
uses: peter-evans/create-pull-request@67ccf781d68cd99b580ae25a5c18a1cc84ffff1f # v7.0.6
with:
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(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.GH_TOKEN_ACTIONS_UPDATER }}
author: team-tf-cdk <[email protected]>
committer: team-tf-cdk <[email protected]>
signoff: true
delete-branch: true