Rename file for publishing to npm. #3
This file contains hidden or 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
| # This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node | |
| # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | |
| name: Node.js CI | |
| on: | |
| push: | |
| branches: [ master, 'release/**' ] | |
| pull_request: | |
| branches: [ master, 'release/**' ] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 16 | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Cache Node Modules | |
| id: cache-node-modules | |
| uses: actions/cache@v4 | |
| with: | |
| path: node_modules | |
| key: node-modules-${{ hashFiles('yarn.lock') }} | |
| - name: Install dependencies | |
| if: steps.cache-node-modules.outputs.cache-hit != 'true' | |
| run: yarn --frozen-lockfile | |
| - name: Run build | |
| run: node make.js build && yarn build | |
| - name: Test | |
| run: yarn lint && yarn test | |
| - name: Set up Node.js for publishing | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Deploy to NPM | |
| if: github.repository_owner == 'Authress-Engineering' && github.ref != 'refs/heads/main' && github.ref != 'refs/heads/master' && github.event_name == 'push' | |
| run: | | |
| npm install -g [email protected] | |
| npm publish --access public | |
| - name: Create Github Release and Tag | |
| if: github.repository_owner == 'Authress-Engineering' && github.ref != 'refs/heads/main' && github.ref != 'refs/heads/master' && github.event_name == 'push' | |
| run: | | |
| git tag ${GITHUB_REF/refs\/heads\/release\//}.$GITHUB_RUN_NUMBER | |
| git push origin ${GITHUB_REF/refs\/heads\/release\//}.$GITHUB_RUN_NUMBER |