0.0.5 #10
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
name: Module CI/CD | |
on: | |
push: | |
tags: | |
- v0.** | |
jobs: | |
build-and-test: | |
name: Build and Test | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
strategy: | |
matrix: | |
node: [16, 18] # Test against multiple Node.js versions | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Clean npm cache | |
run: npm cache clean -f | |
- name: Cache Node.js modules | |
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: ${{ matrix.node }} | |
registry-url: 'https://registry.npmjs.org' | |
- name: Check npm version | |
run: npm --version | |
- name: Install dependencies | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: npm ci | |
- name: Build TypeScript | |
run: npm run build | |
- name: Lint and run tests | |
run: | | |
npm run lint | |
npm run test | |
deploy: | |
name: Deploy to NPM | |
needs: build-and-test # Make sure build and test pass before deploying | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Configure npm | |
run: | | |
echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}' > .npmrc | |
cat .npmrc | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Publish package | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
run: npm publish --registry=https://registry.npmjs.org/ --access public |