name: Publish on: workflow_dispatch: push: tags: - "v*" permissions: id-token: write contents: write jobs: publish: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 - uses: actions/setup-node@v6 with: node-version: 22 registry-url: https://registry.npmjs.org/ - run: npm ci # Extract version from package.json and determine release channel - name: Parse version and determine release channel id: version run: | VERSION=$(node -p "require('./package.json').version") echo "PACKAGE_VERSION=$VERSION" >> $GITHUB_OUTPUT if [[ $VERSION == *"-alpha."* ]]; then echo "NPM_TAG=alpha" >> $GITHUB_OUTPUT echo "PRERELEASE=true" >> $GITHUB_OUTPUT elif [[ $VERSION == *"-beta."* ]]; then echo "NPM_TAG=beta" >> $GITHUB_OUTPUT echo "PRERELEASE=true" >> $GITHUB_OUTPUT else echo "NPM_TAG=latest" >> $GITHUB_OUTPUT fi # Publish with the appropriate tag - name: Publish to npm run: npm publish --tag ${{ steps.version.outputs.NPM_TAG }} # Only create GitHub releases for stable versions - name: Create GitHub Release uses: softprops/action-gh-release@v2 with: generate_release_notes: true prerelease: ${{ steps.version.outputs.PRERELEASE == 'true' }} token: ${{ secrets.GITHUB_TOKEN }}