Skip to content

[polyglotpkg] Add support for Node:22 runtime environment for polyglot projects #4553

[polyglotpkg] Add support for Node:22 runtime environment for polyglot projects

[polyglotpkg] Add support for Node:22 runtime environment for polyglot projects #4553

Workflow file for this run

name: Build Project
on:
pull_request:
push:
branches:
- "main" # trigger the workflow for main branch
workflow_dispatch:
permissions:
actions: write
contents: write
jobs:
build:
strategy:
matrix:
java: ["17", "21", "24"]
maven: ["3.9.2"]
node: ["22.13.1"]
node_vmware_samples: ["22.13.1"]
os: ["ubuntu-22.04"]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout vmware/build-tools-for-vmware-aria repository
uses: actions/checkout@v6
with:
persist-credentials: false
- name: Use Node.js ${{ matrix.node }}
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node }}
- name: Setup Maven Action
uses: s4u/setup-maven-action@6c4e9964d4ecb8f1026310cd8618791fd51a8016 #v1.19.0
with:
java-version: ${{ matrix.java }}
java-distribution: "temurin"
maven-version: ${{ matrix.maven }}
- name: Install xmllint
run: sudo apt-get update && sudo apt-get install libxml2-utils
- name: Install run-script-os@1.1.6
run: npm install -g run-script-os@1.1.6
- name: Print versions
run: |
echo "-------------------------------------------"
echo "-----------< TOOLS AND VERSIONS >----------"
git --version
java -version 2>&1
mvn --version
echo "node version: $(node --version)"
echo "npm version: $(npm --version)"
pip3 --version
python --version
pwsh --version
gpg --version | head -n 1
openssl version
xmllint --version 2>&1 | head -n 1
echo "Installed global npm packages:"
npm list -g --depth=0
echo "-------------------------------------------"
echo "-------------------------------------------"
- name: Get IAC version
run: echo "IAC_VERSION=$(mvn help:evaluate -Dexpression=revision -q -DforceStdout)" >> $GITHUB_ENV
- name: Replace variables in settings.xml
run: |
sed -i "s/{{ IAC_VERSION }}/${{ env.IAC_VERSION }}/g" .m2/settings.xml
sed -i "s/{{ OSSRH_USERNAME }}/${{ secrets.OSSRH_USERNAME }}/g" .m2/settings.xml
sed -i "s/{{ OSSRH_PASSWORD }}/${{ secrets.OSSRH_PASSWORD }}/g" .m2/settings.xml
- name: Import GPG Key
if: ${{ github.ref == 'refs/heads/main' }}
uses: crazy-max/ghaction-import-gpg@e89d40939c28e39f97cf32126055eeae86ba74ec # v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
- name: Set default env GPG_PASSPHRASE
run: echo "GPG_PASSPHRASE=''" >> $GITHUB_ENV
- name: Set env GPG_PASSPHRASE if main
if: ${{ github.ref == 'refs/heads/main' }}
run: echo "GPG_PASSPHRASE=${{ secrets.GPG_PASSPHRASE }}" >> $GITHUB_ENV
- name: Set MVN_BUILD_COMMAND
run: |
if [ "${{ github.ref }}" = "refs/heads/main" ] && [ "${{ matrix.java }}" = "17" ]; then
MVN_BUILD_COMMAND="deploy"
else
MVN_BUILD_COMMAND="install"
fi
echo "MVN_BUILD_COMMAND is $MVN_BUILD_COMMAND"
echo "MVN_BUILD_COMMAND=$MVN_BUILD_COMMAND" >> $GITHUB_ENV
- name: Cache Maven dependencies
uses: actions/cache@v5
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
# Install or deploy maven packages
- name: Build plugins
run: mvn clean install -D modules.plugins -D java.version=${{ matrix.java }} --batch-mode -D gpg.passphrase=${{ env.GPG_PASSPHRASE }} -s $PWD/.m2/settings.xml
- name: Build plugins + tools
run: mvn ${{ env.MVN_BUILD_COMMAND }} -D modules.plugins -D modules.tools -D java.version=${{ matrix.java }} --batch-mode -D gpg.passphrase=${{ env.GPG_PASSPHRASE }} -s $PWD/.m2/settings.xml
- name: Build repository
if: ${{ matrix.java == 17 }}
run: mvn package -D modules.repository --batch-mode -D gpg.passphrase=${{ env.GPG_PASSPHRASE }} -s $PWD/.m2/settings.xml
# Test the packages on build-tools-for-vmware-aria-samples
- name: Checkout vmware-samples/build-tools-for-vmware-aria-samples repository
uses: actions/checkout@v6
with:
repository: vmware-samples/build-tools-for-vmware-aria-samples
ref: main
path: build-tools-for-vmware-aria-samples
- name: Use Node.js ${{ matrix.node_vmware_samples }}
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node_vmware_samples }}
- name: Build vmware-samples/build-tools-for-vmware-aria-samples project repository
run: |
pushd build-tools-for-vmware-aria-samples/
./switch_parent_version.sh ${{ env.IAC_VERSION }}
mvn clean package install -Pbundle-with-installer --batch-mode -s ../.m2/settings.xml
popd
rm -rf build-tools-for-vmware-aria-samples/
- name: Set artifact file name
if: ${{ !contains(env.IAC_VERSION, '-SNAPSHOT') && matrix.java == 17 }}
run: echo "ARTIFACT_FILE_NAME=build-tools-for-vmware-aria-${{ env.IAC_VERSION }}-${{ github.run_number }}" >> $GITHUB_ENV
- name: Package all artifacts
if: ${{ !contains(env.IAC_VERSION, '-SNAPSHOT') && matrix.java == 17 }}
run: |
cp maven/repository/target/iac-maven-repository.zip .
tar -zcvf "${{ env.ARTIFACT_FILE_NAME }}.zip" iac-maven-repository.zip docs/ "LICENSE.txt"
- name: Upload artifact
uses: actions/upload-artifact@v6
if: ${{ !contains(env.IAC_VERSION, '-SNAPSHOT') && matrix.java == 17 }}
with:
name: ${{ env.ARTIFACT_FILE_NAME }}
path: ${{ env.ARTIFACT_FILE_NAME }}.zip
results:
if: ${{ always() }}
runs-on: ubuntu-latest
name: Build Results
needs: [build]
steps:
- run: exit 1
if: >-
${{
contains(needs.*.result, 'failure')
|| contains(needs.*.result, 'cancelled')
}}