Skip to content

Merge branch 'test-ci-workflow' #22

Merge branch 'test-ci-workflow'

Merge branch 'test-ci-workflow' #22

Workflow file for this run

name: CI Build & Release
on:
push:
branches:
- main
pull_request:
schedule:
- cron: "0 0 * * 0" # Every Sunday at midnight UTC for token refresh
jobs:
build:
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 22
cache: 'npm'
- name: Install dependencies
run: npm install
- name: Validate commit messages
run: |
npx --no-install commitlint --from=$(git rev-list --max-parents=0 HEAD) --to=HEAD
- name: Lint code
run: npm run lint
- name: Run jsdom tests
run: npm run test
- name: Run node tests
run: npm run test:node
- name: Run coverage
run: npm run test:coverage
release:
needs: build
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Git configuration
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 22
- name: Install dependencies
run: npm install
- name: Configure NPM registry
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
- name: Generate changelog and bump version
run: npm run release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Push changes and tags
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git push origin main --follow-tags
- name: Publish to NPM
if: github.ref == 'refs/heads/main'
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
refresh-token:
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 22
- name: Install dependencies
run: npm install
- name: Refresh NPM Token
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO_NAME: ${{ github.repository }}
run: node scripts/refresh-npm-token.js