1.3.0 #44
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
| name: Publish to NPM | |
| on: | |
| push: | |
| branches: [ master ] | |
| tags: [ 'v*' ] | |
| release: | |
| types: [ published ] | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.GH_TOKEN }} | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| registry-url: 'https://registry.npmjs.org/' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run tests (fixed) | |
| run: npm test -- --passWithNoTests | |
| - name: Build package | |
| run: npm run build | |
| - name: Conditional version bump and publish | |
| run: | | |
| if [[ ${{ github.ref }} == refs/heads/master ]]; then | |
| git config user.name 'GitHub Actions' | |
| git config user.email 'actions@github.com' | |
| fi | |
| if [[ ${{ github.ref }} == refs/tags/* ]]; then | |
| echo "Tag push/Release detected: Publishing without version bump." | |
| npm publish --access public | |
| elif [[ ${{ github.ref }} == refs/heads/master ]]; then | |
| echo "Master branch push detected: Bumping version and publishing." | |
| npm version patch -m "ci: bump version to %s [skip ci]" | |
| npm publish --access public | |
| else | |
| echo "Not master or a tag. Skipping publish." | |
| fi | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Push version changes | |
| if: github.ref == 'refs/heads/master' | |
| run: git push origin master --follow-tags | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} |