Workflow file for this run
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
# SPDX-License-Identifier: CC-BY-4.0 OR GPL-3.0-or-later | |
# This file is part of Network Engineering Pro | |
# | |
# When a release is creeated or this workflow is manually triggered, it will: | |
# (1) confirm the CodeQL analysis was successful, (2) test JavaScript using | |
# Mocha framework, (3) lint all JavaScript with ESLint (if enabled), (4) check | |
# all formatting with Prettier (if enabled), (5) run builds using node 20.x and | |
# 22.x on ubuntu-22.04 and ubuntu-24.04, and then (6) publish a package to | |
# the npmjs registry. | |
# | |
# The workflow to upload static content to GitHub Pages (upload-npm.yml) will | |
# kick off upon successful completion of this workflow. | |
# | |
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages | |
name: Build/Test Webpack, Publish to npm | |
on: | |
release: | |
types: [created] | |
workflow_dispatch: | |
jobs: | |
check-codeql: | |
name: Check CodeQL Analysis | |
runs-on: ubuntu-24.04 | |
continue-on-error: true | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up GitHub CLI | |
run: sudo apt-get install gh | |
- name: Authenticate GitHub CLI | |
env: | |
GH_PAT: ${{ secrets.GH_PAT }} | |
run: echo "${{ secrets.GH_PAT }}" | gh auth login --with-token | |
- name: Check CodeQL Workflow | |
env: | |
GH_PAT: ${{ secrets.GH_PAT }} | |
run: | | |
gh run list --workflow "CodeQL" --json conclusion --jq '.[0].conclusion' > codeql_status.txt | |
CODEQL_STATUS=$(cat codeql_status.txt) | |
if [[ "$CODEQL_STATUS" != "success" ]]; then | |
echo "CodeQL Analysis did not succeed. Exiting..." | |
exit 1 | |
fi | |
rm codeql_status.txt | |
build: | |
needs: check-codeql | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-22.04, ubuntu-24.04] | |
node-version: [20.x, 22.x] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Cache Node.js modules | |
uses: actions/cache@v3 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-node-${{ matrix.node-version }}-build-${{ hashFiles('package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node-${{ matrix.node-version }}-build- | |
${{ runner.os }}-node-${{ matrix.node-version }}- | |
${{ runner.os }}-node- | |
- name: Install dependencies | |
run: npm ci | |
#- name: DEBUG - List files before build | |
#run: ls -la | |
- name: Create dist directory | |
run: mkdir -p dist | |
- name: Run tests using Mocha framework | |
run: npm test | |
continue-on-error: true | |
- name: Lint code and check formatting | |
run: npm run lint | |
continue-on-error: true | |
- name: Build project | |
run: npm run build | |
#- name: DEBUG - List files after build | |
#run: ls -la | |
- name: Ensure dist directory exists | |
run: mkdir -p dist | |
- name: Copy package.json to dist directory | |
run: cp package.json dist/ | |
#- name: DEBUG - List files in dist directory | |
#run: ls -la dist/ | |
publish-npm: | |
needs: build | |
runs-on: ubuntu-24.04 | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 22.x | |
registry-url: https://registry.npmjs.org/ | |
- name: Cache Node.js modules | |
uses: actions/cache@v3 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-node-20.x-publish-${{ hashFiles('package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node-20.x-publish- | |
${{ runner.os }}-node-20.x- | |
${{ runner.os }}-node- | |
- name: Install dependencies | |
run: npm ci | |
- name: Set up Git user | |
run: | | |
git config --global user.email "github@sl.neteng.cc" | |
git config --global user.name "SunDevil311" | |
- name: Ensure dist directory exists | |
run: mkdir -p dist | |
- name: Copy package.json to dist directory | |
run: cp package.json dist/ | |
#- name: DEBUG - List files in dist directory | |
#run: ls -la dist/ | |
- name: Publish package | |
working-directory: ./dist | |
run: npm publish --access public | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
# Increment version and push commit upon successful publish | |
# non-functional for unknown reasons | |
#- name: Increment version | |
# run: npm version patch | |
#- name: Push version commit | |
# env: | |
# GH_PAT: ${{ secrets.GH_PAT }} | |
# run: | | |
# git remote set-url origin https://x-access-token:${{ secrets.GH_PAT #}}@github.com/NetEng-Pro/dev-neteng-pro.git | |
# git push origin HEAD:master | |
# continue-on-error: true |