Merge pull request #17 from Rajesh-Royal/develop #1
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 Package | |
| on: | |
| push: | |
| branches: [ master ] | |
| paths-ignore: | |
| - 'docs/**' | |
| - '*.md' | |
| - 'LICENSE' | |
| workflow_dispatch: {} | |
| permissions: | |
| contents: write | |
| concurrency: | |
| group: publish-${{ github.ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| registry-url: https://registry.npmjs.org | |
| always-auth: true | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci || npm install --no-audit --no-fund | |
| - name: Build | |
| run: npm run build:npm | |
| - name: Determine version & check registry | |
| id: ver | |
| env: | |
| PKG_NAME: "@rajesh896/broprint.js" | |
| run: | | |
| VERSION=$(node -p "require('./package.json').version") | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| if npm view "$PKG_NAME@$VERSION" >/dev/null 2>&1; then | |
| echo "exists=true" >> $GITHUB_OUTPUT | |
| echo "Version $VERSION already on registry; skipping publish." | |
| else | |
| echo "exists=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Publish to npm | |
| if: steps.ver.outputs.exists == 'false' | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: npm publish --access public | |
| - name: Create git tag | |
| if: steps.ver.outputs.exists == 'false' | |
| run: | | |
| VERSION=${{ steps.ver.outputs.version }} | |
| git tag v$VERSION | |
| git push origin v$VERSION || true |