Skip to content

Commit 66550a5

Browse files
committed
Add back dry-run
1 parent 5ae7246 commit 66550a5

File tree

1 file changed

+59
-18
lines changed

1 file changed

+59
-18
lines changed

.github/workflows/publish-npm.yml

Lines changed: 59 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
11
name: Publish to npm
22

3-
# Security: This workflow uses npm trusted publishing via GitHub Actions OIDC tokens.
4-
# The 'npm-production-publishing' environment is configured in GitHub Settings → Environments with:
5-
# - Deployment branches: Selected branches → main
6-
#
7-
# npm packages are configured to trust this repository's OIDC claims via:
8-
# https://docs.npmjs.com/trusted-publishers
9-
#
10-
# No npm access tokens are needed — authentication uses short-lived OIDC tokens
11-
# automatically issued by GitHub Actions.
12-
133
on:
144
workflow_call:
155
inputs:
166
release-tag:
177
description: 'Release tag to fetch binaries from (e.g. v1.0.0)'
188
required: true
199
type: string
10+
dry-run:
11+
required: false
12+
type: boolean
13+
default: false
2014
workflow_dispatch:
2115
inputs:
2216
release-tag:
2317
description: 'Release tag to fetch binaries from (e.g. v1.0.0)'
2418
required: true
2519
type: string
20+
dry-run:
21+
description: 'Dry run (build packages but skip publish)'
22+
required: false
23+
type: boolean
24+
default: true
2625

2726
concurrency: ${{ github.workflow }}-${{ github.ref }}
2827

@@ -84,12 +83,11 @@ jobs:
8483
if-no-files-found: error
8584
retention-days: 7
8685

87-
# Publish to npm
88-
release:
89-
name: Release to npm
86+
# Build npm packages (no environment needed)
87+
build:
88+
name: Build npm packages
9089
runs-on: ubuntu-latest
9190
needs: [generate-schema]
92-
environment: npm-production-publishing
9391
steps:
9492
- name: Checkout
9593
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
@@ -177,11 +175,19 @@ jobs:
177175
cd ui/acp
178176
# Build only TypeScript, schema is already generated
179177
pnpm run build:ts
180-
178+
181179
cd ../text
182180
pnpm run build
183181
184-
- name: Prepare summary
182+
- name: Upload built packages
183+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
184+
with:
185+
name: npm-packages
186+
path: ui/
187+
if-no-files-found: error
188+
retention-days: 7
189+
190+
- name: Build summary
185191
run: |
186192
{
187193
echo "## 📦 Build Summary"
@@ -200,11 +206,46 @@ jobs:
200206
done
201207
echo ""
202208
echo "### npm Packages"
203-
echo "✅ @aaif/goose-acp"
204-
echo "✅ @aaif/goose (TUI)"
209+
cd ui
210+
for pkg in acp text goose-binary/*/; do
211+
if [ -f "$pkg/package.json" ]; then
212+
name=$(jq -r '.name' "$pkg/package.json")
213+
version=$(jq -r '.version' "$pkg/package.json")
214+
echo "- $name@$version"
215+
fi
216+
done
205217
echo ""
218+
if [ "${{ inputs.dry-run }}" = "true" ]; then
219+
echo "### ⚠️ Dry run — packages were built but will NOT be published"
220+
fi
206221
} >> "$GITHUB_STEP_SUMMARY"
207222
223+
# Publish to npm (requires environment approval for OIDC token)
224+
publish:
225+
name: Publish to npm
226+
if: inputs.dry-run != true
227+
runs-on: ubuntu-latest
228+
needs: [build]
229+
environment: npm-production-publishing
230+
steps:
231+
- name: Download built packages
232+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
233+
with:
234+
name: npm-packages
235+
path: ui/
236+
237+
- name: Setup Node.js
238+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
239+
with:
240+
node-version: '24.10.0'
241+
registry-url: 'https://registry.npmjs.org'
242+
always-auth: true
243+
244+
- name: Setup pnpm
245+
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4
246+
with:
247+
version: 10.30.3
248+
208249
- name: Publish to npm
209250
run: |
210251
cd ui

0 commit comments

Comments
 (0)