Skip to content

Bump actions/setup-node from 6 to 7 (#558) #1392

Bump actions/setup-node from 6 to 7 (#558)

Bump actions/setup-node from 6 to 7 (#558) #1392

Workflow file for this run

name: CI Build
on:
# Dry run for main pushes:
workflow_dispatch:
push:
branches: ["main"]
paths-ignore: ["**/*.md"]
# Publish to npm:
tags:
- "v*.*.*"
# Dry run for PRs:
pull_request:
branches: ["main"]
paths-ignore: ["**/*.md"]
env:
NODE_VERSION: "22.17.1"
permissions:
contents: write
jobs:
build:
name: Build
runs-on: "ubuntu-24.04"
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up NodeJS
uses: actions/setup-node@v7
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cache node modules
id: cache
uses: actions/cache@v5
with:
path: node_modules # npm cache files are stored in `~/.npm` on Linux/macOS
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package.json', '**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci
- name: Build
run: npm run build
# this will identify modifications to files under source control during the workflow run;
# untracked files will be included as well!
- name: Verify Changed Files
id: verify-changed-files
run: |
set -o pipefail
changed_files=$(echo -n "$(git diff --name-only HEAD && git ls-files --others --exclude-standard)"|tr '\n' ' ')
echo "changed_files=$changed_files" >> $GITHUB_OUTPUT
- name: Fail on Changed Files
if: steps.verify-changed-files.outputs.changed_files != ''
env:
CHANGED_FILES: ${{ steps.verify-changed-files.outputs.changed_files }}
run: |
echo "::error::Files have changed: $CHANGED_FILES"
exit 1
- name: Upload build artifacts
uses: actions/upload-artifact@v7
with:
name: dist-without-license
path: |
dist
!dist/*.txt
- name: Upload test coverage report
uses: actions/upload-artifact@v7
with:
name: test-coverage
path: |
test/coverage/lcov-report
- name: Create GitHub Release
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "${{ github.ref_name }}" \
dist/openhab.js \
dist/openhab.d.ts \
dist/@openhab-globals.js \
--title "${{ github.ref_name }}" \
--generate-notes
jsdoc:
name: Publish JSDoc
runs-on: "ubuntu-24.04"
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up NodeJS
uses: actions/setup-node@v7
with:
node-version: ${{ env.NODE_VERSION }}
- name: Cache node modules
id: cache
uses: actions/cache@v5
with:
path: node_modules # npm cache files are stored in `~/.npm` on Linux/macOS
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package.json', '**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci
- name: Build JSDoc
run: npm run docs
# pinning to SHA to mitigate possible supply chain attack
- name: Publish to GitHub Pages
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
uses: peaceiris/actions-gh-pages@84c30a85c19949d7eee79c4ff27748b70285e453 # v4.1.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs
publish:
name: Publish to npm
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
runs-on: "ubuntu-24.04"
needs: build
permissions:
id-token: write # Required for OIDC
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: "https://registry.npmjs.org"
# Ensure npm 11.5.1 or later is installed
- name: Update npm
run: npm install -g npm@^11.5.1
- name: Install Dependencies
run: npm ci
- name: Publish npm package
run: npm publish --access=public