Merge pull request #782 from sebbo2002/depfu/batch_dev/npm/2026-08-25 #1306
This file contains hidden or 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
| name: Test & Release | |
| on: | |
| push: | |
| branches-ignore: | |
| - 'gh-pages' | |
| - 'depfu/**' | |
| - 'dependabot/**' | |
| - 'template-updater/**' | |
| pull_request: null | |
| jobs: | |
| tests: | |
| name: Unit Tests | |
| runs-on: ubuntu-latest | |
| if: github.repository != 'sebbo2002/js-template' && (contains(toJson(github.event.commits.*.message), '[skip ci]') == false || github.ref == 'refs/heads/main') | |
| strategy: | |
| matrix: | |
| node: [22.x, 24.x, 25.x, current] | |
| steps: | |
| - name: ☁️ Checkout Project | |
| uses: actions/checkout@v7 | |
| - name: 🔧 Setup node.js | |
| uses: actions/setup-node@v7 | |
| with: | |
| node-version: ${{ matrix.node }} | |
| cache: 'npm' | |
| - name: 📦 Install dependencies | |
| run: npm ci | |
| - name: ⏳ Run tests | |
| run: npm run test | |
| coverage: | |
| name: Code Coverage / Lint | |
| runs-on: ubuntu-latest | |
| if: github.repository != 'sebbo2002/js-template' && (contains(toJson(github.event.commits.*.message), '[skip ci]') == false || github.ref == 'refs/heads/main') | |
| steps: | |
| - name: ☁️ Checkout Project | |
| uses: actions/checkout@v7 | |
| - name: 🔧 Setup node.js | |
| uses: actions/setup-node@v7 | |
| with: | |
| node-version: 24.x | |
| cache: 'npm' | |
| - name: 📦 Install dependencies | |
| run: npm ci | |
| - name: 🔍 Run linter | |
| run: npm run lint | |
| - name: ⚙️ Build project | |
| run: npm run build-all | |
| license-checker: | |
| name: License Checker | |
| runs-on: ubuntu-latest | |
| if: contains(toJson(github.event.commits.*.message), '[skip ci]') == false || github.ref == 'refs/heads/main' | |
| steps: | |
| - name: ☁️ Checkout Project | |
| uses: actions/checkout@v7 | |
| - name: 🔧 Setup node.js | |
| uses: actions/setup-node@v7 | |
| with: | |
| node-version: 24.x | |
| cache: 'npm' | |
| - name: 📦 Install dependencies | |
| run: npm ci | |
| - name: 🕵️♀️ Run license checker | |
| run: npm run license-check | |
| release: | |
| name: Release | |
| runs-on: ubuntu-latest | |
| concurrency: release | |
| permissions: | |
| contents: write | |
| id-token: write | |
| issues: write | |
| packages: write | |
| pages: write | |
| pull-requests: write | |
| needs: | |
| - coverage | |
| - tests | |
| - license-checker | |
| if: ${{ github.repository != 'sebbo2002/js-template' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop') }} | |
| steps: | |
| - name: ☁️ Checkout Project | |
| uses: actions/checkout@v7 | |
| - name: 🔧 Setup node.js | |
| uses: actions/setup-node@v7 | |
| with: | |
| node-version: 24.x | |
| cache: 'npm' | |
| - name: 📦 Ensure npm ≥ 11.5.1 | |
| run: | | |
| REQUIRED_VERSION="11.5.1" | |
| CURRENT_VERSION=$(npm -v) | |
| echo "Current npm version: $CURRENT_VERSION" | |
| SMALLEST=$(printf '%s\n' "$CURRENT_VERSION" "$REQUIRED_VERSION" | sort -V | head -n1) | |
| if [ "$CURRENT_VERSION" = "$REQUIRED_VERSION" ] || [ "$SMALLEST" = "$REQUIRED_VERSION" ]; then | |
| echo "npm version ($CURRENT_VERSION) meets the requirement ($REQUIRED_VERSION)." | |
| else | |
| echo "Updating npm to latest version..." | |
| npm install -g npm@latest | |
| fi | |
| - name: 📦 Install dependencies | |
| run: npm ci | |
| - name: 📂 Create docs folder | |
| run: mkdir ./docs | |
| - name: 🪄 Run semantic-release | |
| run: BRANCH=${GITHUB_REF#refs/heads/} npx semantic-release | |
| env: | |
| GH_REPO: ${{ github.repository }} | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GH_OWNER: ${{ github.repository_owner }} | |
| NPM_CONFIG_PROVENANCE: true | |
| npm_config_access: public | |
| - name: 🌎 Deploy GitHub Pages | |
| uses: peaceiris/actions-gh-pages@v4 | |
| if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./docs | |
| destination_dir: ./${GITHUB_REF#refs/heads/} | |
| - name: 🔃 Merge main back into develop | |
| if: ${{ github.ref == 'refs/heads/main' }} | |
| uses: everlytic/branch-merge@1.1.5 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| source_ref: 'main' | |
| target_branch: 'develop' | |
| commit_message_template: 'Merge branch {source_ref} into {target_branch} [skip ci]' |