π Releases v1.2.0 #2
Workflow file for this run
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: | |
| - main | |
| release: | |
| types: [created] | |
| jobs: | |
| publish: | |
| name: Publish Package | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 18 | |
| registry-url: "https://registry.npmjs.org/" | |
| - name: Install dependencies | |
| run: npm install | |
| - name: Check if version changed | |
| id: check_version | |
| run: | | |
| VERSION=$(jq -r .version package.json) | |
| echo "Current package.json version: $VERSION" | |
| if npm view $(jq -r .name package.json) version | grep -q "^$VERSION$"; then | |
| echo "Version $VERSION is already published. Skipping publish." | |
| echo "SKIP_PUBLISH=true" >> $GITHUB_ENV | |
| fi | |
| - name: Publish to npm | |
| if: env.SKIP_PUBLISH != 'true' | |
| run: npm publish --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} |