Update npm-publish.yml #7
  
    
      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 @synergycodes/axiom package to NPM | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| node-version: [22] | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 2 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Use Node.js ${{ matrix.node-version }} | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ matrix.node-version }} | |
| cache: 'pnpm' | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Read versions | |
| id: version-check | |
| run: | | |
| OLD=$(git show HEAD~1:packages/ui/package.json | jq -r .version) | |
| NEW=$(jq -r .version packages/ui/package.json) | |
| echo "old=$OLD" >> $GITHUB_OUTPUT | |
| echo "new=$NEW" >> $GITHUB_OUTPUT | |
| - name: Conditionally build & publish | |
| run: | | |
| echo "Old version: ${{ steps.version-check.outputs.old }}" | |
| echo "New version: ${{ steps.version-check.outputs.new }}" | |
| if [ "${{ steps.version-check.outputs.new }}" != "${{ steps.version-check.outputs.old }}" ]; then | |
| echo "Versions differ. Proceeding with build and publish." | |
| pnpm ui build | |
| echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc | |
| cd packages/ui | |
| echo "Publishing @synergycodes/axiom@${{ steps.version-check.outputs.new }} with 'beta' tag…" | |
| pnpm publish --access public --tag beta --no-git-checks | |
| echo "Adding 'latest' dist-tag to @synergycodes/axiom@${{ steps.version-check.outputs.new }}…" | |
| pnpm dist-tag add @synergycodes/axiom@${{ steps.version-check.outputs.new }} latest | |
| rm -f ~/.npmrc | |
| else | |
| echo "Version unchanged. Skipping build and publish." | |
| fi | |
| env: | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |