chore(release): 1.0.22 #29
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: | |
| tags: | |
| - "v*" | |
| jobs: | |
| publish: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: 🛎️ Checkout code | |
| uses: actions/checkout@v4 | |
| - name: 🟢 Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| registry-url: "https://registry.npmjs.org/" | |
| cache: "npm" | |
| - name: 📦 Install dependencies | |
| run: npm ci | |
| - name: 🔨 Build TypeScript | |
| run: npm run build | |
| - name: ✅ Verify build | |
| run: | | |
| test -d dist || (echo "dist directory not found" && exit 1) | |
| test -f dist/index.js || (echo "dist/index.js not found" && exit 1) | |
| echo "Build artifacts verified" | |
| - name: 📋 Check package version | |
| id: version | |
| run: | | |
| TAG_VERSION=${GITHUB_REF#refs/tags/v} | |
| PKG_VERSION=$(node -p "require('./package.json').version") | |
| echo "Tag version: $TAG_VERSION" | |
| echo "Package version: $PKG_VERSION" | |
| if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then | |
| echo "Version mismatch! Tag: v$TAG_VERSION, package.json: v$PKG_VERSION" | |
| exit 1 | |
| fi | |
| echo "version=$PKG_VERSION" >> $GITHUB_OUTPUT | |
| - name: 🚀 Publish to npm | |
| run: | | |
| set +e | |
| PUBLISH_OUTPUT=$(npm publish --access public --provenance 2>&1) | |
| PUBLISH_EXIT=$? | |
| set -e | |
| echo "$PUBLISH_OUTPUT" | |
| if [ "$PUBLISH_EXIT" -ne 0 ]; then | |
| if echo "$PUBLISH_OUTPUT" | grep -q "EOTP"; then | |
| echo "::error::npm publish failed with EOTP. Use an npm automation token for NPM_TOKEN or disable OTP requirement for token-based publish." | |
| fi | |
| exit "$PUBLISH_EXIT" | |
| fi | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: ✅ Success notification | |
| run: | | |
| echo "🎉 Successfully published @nbtca/prompt@${{ steps.version.outputs.version }} to npm" |