chore: add ubuntu latest to ci #19
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
name: CI Build & Release | |
on: | |
push: | |
branches: | |
- main | |
- test-ci-workflow | |
pull_request: | |
schedule: | |
- cron: "0 0 * * 0" # Every Sunday at midnight UTC for token refresh | |
jobs: | |
build: | |
strategy: | |
matrix: | |
os: [ubuntu-22.04, ubuntu-24.04] # Test on both versions | |
runs-on: ${{ matrix.os }} | |
steps: | |
# Step 1: Check out the code | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
# Step 2: Cache dependencies | |
- name: Cache dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
# Step 3: Set up Node.js | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 22 | |
cache: 'npm' | |
# Step 4: Install dependencies | |
- name: Install dependencies | |
run: npm install | |
# Step 5: Validate commit messages | |
- name: Validate commit messages | |
run: | | |
npx --no-install commitlint --from=$(git rev-list --max-parents=0 HEAD) --to=HEAD | |
# Step 6: Run linting | |
- name: Lint code | |
run: npm run lint | |
# Step 7: Run jsdom tests | |
- name: Run jsdom tests | |
run: npm run test | |
# Step 8: Run node tests | |
- name: Run node tests | |
run: npm run test:node | |
# Step 9: Run coverage | |
- name: Run coverage | |
run: npm run test:coverage | |
release: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Check out the code | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
# Step 2: Set up Git config | |
- name: Set up Git configuration | |
run: | | |
git config --global user.name "GitHub Actions" | |
git config --global user.email "actions@github.com" | |
# Step 3: Install dependencies | |
- name: Install dependencies | |
run: npm install | |
# Step 4: Generate changelog and bump version | |
- name: Generate changelog and bump version | |
run: npm run release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# Step 5: Push changes and tags | |
- name: Push changes and tags | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git config user.name "GitHub Actions" | |
git config user.email "actions@github.com" | |
git push origin main --follow-tags | |
# Step 6: Publish to NPM | |
- 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-latest | |
steps: | |
# Step 1: Checkout code | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
# Step 2: Set up Node.js | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 22 | |
# Step 3: Install dependencies | |
- name: Install dependencies | |
run: npm install | |
# Step 4: Run the token refresh script | |
- name: Refresh NPM Token | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
REPO_NAME: ${{ github.repository }} | |
run: node scripts/refresh-npm-token.js |