@@ -112,17 +112,21 @@ jobs:
112112 echo "version=${NEW_VERSION}" >> $GITHUB_OUTPUT
113113 echo "🎯 Version: ${NEW_VERSION} (${CHANNEL})"
114114
115+ - name : Validate npm publishing credentials
116+ env :
117+ NPM_TOKEN : ${{ secrets.NPM_TOKEN }}
118+ run : |
119+ if [ -z "$NPM_TOKEN" ]; then
120+ echo "::error::NPM_TOKEN is required for npm publishing"
121+ exit 1
122+ fi
123+
115124 test :
116125 needs : prepare
117126 if : needs.prepare.outputs.should_release == 'true'
118127 runs-on : ubuntu-latest
119128 steps :
120129 - uses : actions/checkout@v7
121- with :
122- # This job runs the built terminal tests, which assert the CLI renders
123- # the latest stable release tag found via `git tag --merged HEAD`. The
124- # default shallow checkout fetches no tags.
125- fetch-depth : 0
126130
127131 - name : Setup Bun
128132 uses : oven-sh/setup-bun@v2
@@ -138,14 +142,33 @@ jobs:
138142 - name : Run tests
139143 run : bun run test:ci
140144
145+ tuistory :
146+ needs : prepare
147+ if : needs.prepare.outputs.should_release == 'true'
148+ runs-on : ubuntu-latest
149+ steps :
150+ - uses : actions/checkout@v7
151+ with :
152+ # The built terminal tests assert the CLI renders the latest stable
153+ # release tag found via `git tag --merged HEAD`.
154+ fetch-depth : 0
155+
156+ - name : Setup Bun
157+ uses : oven-sh/setup-bun@v2
158+ with :
159+ bun-version : 1.2.22
160+
161+ - name : Install dependencies
162+ run : bun install --frozen-lockfile
163+
141164 - name : Build CLI for terminal tests
142165 run : bun run build
143166
144167 - name : Run built terminal tests
145168 run : bun run test:tuistory
146169
147170 build :
148- needs : [prepare, test]
171+ needs : [prepare, test, tuistory ]
149172 if : needs.prepare.outputs.should_release == 'true'
150173 runs-on : ${{ matrix.os }}
151174 strategy :
@@ -423,21 +446,34 @@ jobs:
423446 echo "Homebrew tap updated to v${VERSION}"
424447 fi
425448
426- - name : Build JS dist for npm
427- if : needs.prepare.outputs.channel == 'release'
449+ - name : Build and verify npm package
428450 run : |
429451 bun install --frozen-lockfile
452+ npm version "${{ needs.prepare.outputs.version }}" --no-git-tag-version --allow-same-version
430453 bun run build
454+ npm pack --dry-run
431455 ls -lh dist/
432456
433- - name : Publish to npm (release only)
434- if : needs.prepare.outputs.channel == 'release'
457+ - name : Publish to npm
435458 env :
436459 NPM_TOKEN : ${{ secrets.NPM_TOKEN }}
437460 run : |
438461 if [ -z "$NPM_TOKEN" ]; then
439- echo "⚠️ NPM_TOKEN not set, skipping npm publish "
440- exit 0
462+ echo "::error:: NPM_TOKEN is required for npm publishing "
463+ exit 1
441464 fi
465+
442466 echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc
443- npm publish --access public
467+ VERSION="${{ needs.prepare.outputs.version }}"
468+ if [ "${{ needs.prepare.outputs.channel }}" = "alpha" ]; then
469+ NPM_DIST_TAG="alpha"
470+ else
471+ NPM_DIST_TAG="latest"
472+ fi
473+
474+ if npm view "autohand-cli@$VERSION" version --json > /dev/null 2>&1; then
475+ echo "autohand-cli@$VERSION is already published; updating the $NPM_DIST_TAG dist-tag"
476+ npm dist-tag add "autohand-cli@$VERSION" "$NPM_DIST_TAG"
477+ else
478+ npm publish --access public --tag "$NPM_DIST_TAG"
479+ fi
0 commit comments