Skip to content

upgrade-node

upgrade-node #470

Workflow file for this run

# ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen".
name: upgrade-node
on:
schedule:
- cron: 52 4 * * *
workflow_dispatch:
inputs:
version:
description: "Node.js version to upgrade to, in the format: 12.34.56"
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 }}
major: ${{ steps.latest_version.outputs.major }}
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:
node-version: 18.12.0
- name: Install
run: yarn install
- name: Get current Node.js version
id: current_version
run: |-
ENGINES_NODE_VERSION=$(npm pkg get engines.node | tr -d '"')
CURRENT_VERSION=$(cut -d " " -f 2 <<< "$ENGINES_NODE_VERSION")
CURRENT_VERSION_MAJOR=$(cut -d "." -f 1 <<< "$CURRENT_VERSION")
CURRENT_VERSION_MINOR=$(cut -d "." -f 2 <<< "$CURRENT_VERSION")
echo "CURRENT_NODEJS_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV
echo "CURRENT_NODEJS_VERSION_MAJOR=$CURRENT_VERSION_MAJOR" >> $GITHUB_ENV
echo "CURRENT_NODEJS_VERSION_MINOR=$CURRENT_VERSION_MINOR" >> $GITHUB_ENV
echo "value=$CURRENT_VERSION" >> $GITHUB_OUTPUT
- name: Get the earliest supported Node.js version whose EOL date is at least a month away
if: ${{ ! inputs.version }}
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
with:
script: |-
const script = require('./projenrc/scripts/check-node-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_MAJOR=$(cut -d "." -f 1 <<< "$NEW_VERSION")
NEW_VERSION_MINOR=$(cut -d "." -f 2 <<< "$NEW_VERSION")
echo "NEW_NODEJS_VERSION=$NEW_VERSION" >> $GITHUB_ENV
echo "NEW_NODEJS_VERSION_MAJOR=$NEW_VERSION_MAJOR" >> $GITHUB_ENV
echo "NEW_NODEJS_VERSION_MINOR=$NEW_VERSION_MINOR" >> $GITHUB_ENV
- name: Output env variables for use in the next job
id: latest_version
run: |-
echo "value=$NEW_NODEJS_VERSION" >> $GITHUB_OUTPUT
echo "major=$NEW_NODEJS_VERSION_MAJOR" >> $GITHUB_OUTPUT
[[ "$NEW_NODEJS_VERSION_MAJOR" > "$CURRENT_NODEJS_VERSION_MAJOR" || ("$NEW_NODEJS_VERSION_MAJOR" == "$CURRENT_NODEJS_VERSION_MAJOR" && "$NEW_NODEJS_VERSION_MINOR" > "$CURRENT_NODEJS_VERSION_MINOR") ]] && IS_NEWER=true
echo "is_newer=$IS_NEWER" >> $GITHUB_OUTPUT
upgrade:
name: Upgrade Node.js
needs: version
runs-on: ubuntu-latest
permissions:
contents: read
env:
CI: "true"
CHECKPOINT_DISABLE: "1"
if: always() && needs.version.outputs.should_upgrade
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- name: Setup Node.js
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af
with:
node-version: ${{ needs.version.outputs.latest }}
- name: Install
run: yarn install
- name: Set the new minNodeVersion in .projenrc.ts
env:
NEW_NODEJS_VERSION: ${{ needs.version.outputs.value }}
run: 'sed -i "s/minNodeVersion: \".*\",/minNodeVersion: \"$NEW_NODEJS_VERSION\",/" ./.projenrc.ts'
- name: Activate Projen to propagate the new version everywhere
env:
CI: "false"
run: yarn projen
- name: Create Pull Request
uses: peter-evans/create-pull-request@67ccf781d68cd99b580ae25a5c18a1cc84ffff1f
with:
base: main
branch: auto/upgrade-node-${{ needs.version.outputs.major }}
commit-message: "chore!: increase minimum supported Node.js version to ${{ needs.version.outputs.major }} for this project only"
title: "chore!: increase minimum supported Node.js version to ${{ needs.version.outputs.major }} for this project only"
body: |-
This PR increases the minimum supported Node.js version to `${{ needs.version.outputs.latest }}` from `${{ needs.version.outputs.current }}` because version ${{ needs.version.outputs.current }} is less than 30 days away from EOL.
While this PR could be merged as-is, it is recommended that you scan the code (especially `.projenrc.ts`) to see if there are any comments indicating changes that can/should be made when upgrading Node, such as:
```// The following line can be removed when upgrading to Node ${{ needs.version.outputs.major }}```
labels: automerge,automated,security
token: ${{ secrets.PROJEN_GITHUB_TOKEN }}
author: team-tf-cdk <github-team-tf-cdk@hashicorp.com>
committer: team-tf-cdk <github-team-tf-cdk@hashicorp.com>
signoff: true
delete-branch: true