add publishing job #3
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: Lint & Build | |
on: [push] | |
jobs: | |
lint_and_test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "20.17" | |
- name: Install Dependencies | |
run: npm ci | |
- name: Lint | |
run: npm run lint | |
- name: TS check | |
run: npm run lint:types | |
- name: Test | |
run: npm test -- --ci | |
release: | |
name: Publish Release (Only for Tags) | |
runs-on: ubuntu-latest | |
needs: [lint_and_test] # Ensure lint and test pass before publishing | |
if: startsWith(github.ref, 'refs/tags/v') # Only run for tag pushes | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "20.17" | |
- name: Install Dependencies | |
run: npm install | |
- name: Build | |
run: npm run build | |
- name: Publish to npm | |
run: npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |