-
Notifications
You must be signed in to change notification settings - Fork 1
130 lines (113 loc) · 4.13 KB
/
Copy pathpublish-packages.yml
File metadata and controls
130 lines (113 loc) · 4.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: Publish packages to npm
on:
workflow_dispatch:
inputs:
package:
description: 'Package to publish'
required: true
default: 'all'
type: choice
options:
- all
- cli
- mcp
dry_run:
description: 'Dry run (no actual publish)'
required: false
default: false
type: boolean
push:
branches:
- main
paths:
- 'packages/cli/**'
- 'packages/mcp/**'
- 'packages/shared/**'
tags:
- 'v*'
- 'cli@*'
- 'mcp@*'
jobs:
publish:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v5
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- uses: actions/setup-node@v5
with:
node-version: '22'
registry-url: 'https://registry.npmjs.org'
- name: Install npm with trusted publishing support
run: npm install --global npm@11.8.0
- run: bun install
- name: Determine target
id: target
run: |
TAG="${GITHUB_REF_NAME:-}"
INPUT="${{ github.event.inputs.package }}"
if [ -n "$INPUT" ]; then
echo "target=$INPUT" >> "$GITHUB_OUTPUT"
elif [[ "$TAG" == cli@* ]]; then
echo "target=cli" >> "$GITHUB_OUTPUT"
elif [[ "$TAG" == mcp@* ]]; then
echo "target=mcp" >> "$GITHUB_OUTPUT"
else
echo "target=all" >> "$GITHUB_OUTPUT"
fi
- name: Resolve workspace protocol for npm publish
run: |
SHARED_VERSION=$(node -p "require('./packages/shared/package.json').version")
for pkg in packages/cli/package.json packages/mcp/package.json; do
sed -i "s|\"workspace:\\*\"|\"^${SHARED_VERSION}\"|g" "$pkg"
done
- name: Build and publish @graspful/shared
run: cd packages/shared && bun run build
- name: Publish @graspful/shared
if: github.event.inputs.dry_run != 'true'
run: |
cd packages/shared
VERSION=$(node -p "require('./package.json').version")
if npm view "@graspful/shared@$VERSION" version >/dev/null 2>&1; then
echo "@graspful/shared@$VERSION is already published"
else
npm publish --access public
fi
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Build CLI
if: steps.target.outputs.target == 'all' || steps.target.outputs.target == 'cli'
run: cd packages/cli && bun run build
- name: Build MCP
if: steps.target.outputs.target == 'all' || steps.target.outputs.target == 'mcp'
run: cd packages/mcp && bun run build
- name: Publish @graspful/cli
if: (steps.target.outputs.target == 'all' || steps.target.outputs.target == 'cli') && github.event.inputs.dry_run != 'true'
run: |
cd packages/cli
VERSION=$(node -p "require('./package.json').version")
if npm view "@graspful/cli@$VERSION" version >/dev/null 2>&1; then
echo "@graspful/cli@$VERSION is already published"
else
npm publish --access public
fi
- name: Publish @graspful/mcp
if: (steps.target.outputs.target == 'all' || steps.target.outputs.target == 'mcp') && github.event.inputs.dry_run != 'true'
run: |
cd packages/mcp
VERSION=$(node -p "require('./package.json').version")
if npm view "@graspful/mcp@$VERSION" version >/dev/null 2>&1; then
echo "@graspful/mcp@$VERSION is already published"
else
npm publish --access public
fi
- name: Dry run — CLI
if: (steps.target.outputs.target == 'all' || steps.target.outputs.target == 'cli') && github.event.inputs.dry_run == 'true'
run: cd packages/cli && npm publish --access public --dry-run
- name: Dry run — MCP
if: (steps.target.outputs.target == 'all' || steps.target.outputs.target == 'mcp') && github.event.inputs.dry_run == 'true'
run: cd packages/mcp && npm publish --access public --dry-run