let's try this #14
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: Run Tests | |
on: | |
push: | |
branches: [main] | |
tags: | |
- '*' | |
pull_request: | |
branches: [main] | |
jobs: | |
setup: | |
name: Basic Setup | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js 20 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: 'npm' | |
- name: Dependencies Cache | |
id: node-modules | |
uses: actions/cache@v4 | |
with: | |
path: node_modules | |
key: node_modules-${{ hashFiles('package-lock.json') }} | |
- name: Install Dependencies | |
run: npm ci | |
if: steps.node-modules.outputs.cache-hit != 'true' | |
- name: Purge Camo Image Badge Cache | |
uses: kevincobain2000/action-camo-purge@v1 | |
- name: Run ESLint | |
run: npm run lint | |
- name: Run Prettier | |
run: npm run prettier | |
build: | |
name: Build Bundle | |
needs: setup | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js 20 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: 'npm' | |
- name: Dependencies Cache | |
uses: actions/cache@v4 | |
with: | |
path: node_modules | |
key: node_modules-${{ hashFiles('package-lock.json') }} | |
- name: Build Cache | |
uses: actions/cache@v4 | |
with: | |
path: dist | |
key: build-${{ github.sha }} | |
- run: ls -la # Debugging line to see the directory structure | |
- name: Build Files | |
run: npm run build | |
test: | |
name: Run Tests | |
needs: build | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [16, 18, 20] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'npm' | |
- name: Dependencies Cache | |
uses: actions/cache@v4 | |
with: | |
path: node_modules | |
key: node_modules-${{ hashFiles('package-lock.json') }} | |
- name: Build Cache | |
uses: actions/cache@v4 | |
with: | |
path: dist | |
key: build-${{ github.sha }} | |
- name: Run Tests | |
run: npm test | |
- name: Check tree-shakeability | |
run: npx agadoo | |
publish-npm: | |
name: Publish to NPM | |
if: startsWith(github.ref, 'refs/tags/') | |
needs: test | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js 20 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
registry-url: 'https://registry.npmjs.org/' | |
cache: 'npm' | |
- name: Build Cache | |
uses: actions/cache@v4 | |
with: | |
path: dist | |
key: build-${{ github.sha }} | |
- name: NPM Publish | |
run: npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Github Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
generate_release_notes: true |