-
Notifications
You must be signed in to change notification settings - Fork 45
266 lines (223 loc) Β· 9.26 KB
/
auto-test-publish.yml
File metadata and controls
266 lines (223 loc) Β· 9.26 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
name: Publish NPM Packages (PR Environment)
on:
pull_request:
paths: ['packages/sdk/**']
push:
branches: [master]
paths: ['packages/sdk/**']
jobs:
publish-pr-packages:
name: Build and publish SDK packages with test postfix
runs-on: ubuntu-latest
if: github.repository_owner == 'Merit-Systems'
outputs:
typescript-published: ${{ steps.publish-typescript.outputs.published }}
react-published: ${{ steps.publish-react.outputs.published }}
next-published: ${{ steps.publish-next.outputs.published }}
aix402-published: ${{ steps.publish-aix402.outputs.published }}
echo-start-published: ${{ steps.publish-echo-start.outputs.published }}
version: ${{ steps.get-version.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install pnpm
run: npm install -g pnpm
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'pnpm'
registry-url: https://registry.npmjs.org
- name: Install workspace dependencies
run: pnpm install --frozen-lockfile
# TypeScript SDK
- name: Version and build TypeScript SDK
working-directory: ./packages/sdk/ts
run: |
SHORT_SHA=$(git rev-parse --short HEAD)
if [ "${{ github.event_name }}" = "pull_request" ]; then
PR_NUM="${{ github.event.number }}"
PREID="test-pr${PR_NUM}.${SHORT_SHA}"
else
PREID="test.${SHORT_SHA}"
fi
echo "π¦ Versioning TypeScript SDK with preid: ${PREID}"
pnpm version prerelease --preid="${PREID}" --no-git-tag-version
echo "π¨ Building TypeScript SDK..."
pnpm run build
echo "β
TypeScript SDK built"
- name: Test TypeScript SDK
working-directory: ./packages/sdk/ts
run: |
echo "π§ͺ Testing TypeScript SDK..."
pnpm run test
pnpm run type-check
echo "β
TypeScript SDK tests passed"
- name: Get version from TypeScript SDK
id: get-version
working-directory: ./packages/sdk/ts
run: |
PACKAGE_VERSION=$(node -p "require('./package.json').version")
echo "version=$PACKAGE_VERSION" >> $GITHUB_OUTPUT
echo "π¦ Release version: $PACKAGE_VERSION"
- name: Publish TypeScript SDK to test tag
id: publish-typescript
working-directory: ./packages/sdk/ts
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
PACKAGE_NAME=$(node -p "require('./package.json').name")
PACKAGE_VERSION=$(node -p "require('./package.json').version")
echo "π Publishing $PACKAGE_NAME@$PACKAGE_VERSION to test tag..."
pnpm publish --access public --tag test --no-git-checks
echo "published=true" >> $GITHUB_OUTPUT
echo "β
Successfully published $PACKAGE_NAME to test tag"
# React SDK
- name: Version and build React SDK
working-directory: ./packages/sdk/react
run: |
SHORT_SHA=$(git rev-parse --short HEAD)
if [ "${{ github.event_name }}" = "pull_request" ]; then
PR_NUM="${{ github.event.number }}"
PREID="test-pr${PR_NUM}.${SHORT_SHA}"
else
PREID="test.${SHORT_SHA}"
fi
echo "π¦ Versioning React SDK with preid: ${PREID}"
pnpm version prerelease --preid="${PREID}" --no-git-tag-version
echo "π¨ Building React SDK..."
pnpm run build
echo "β
React SDK built"
- name: Test React SDK
working-directory: ./packages/sdk/react
run: |
echo "π§ͺ Testing React SDK..."
pnpm run test || echo "β οΈ Some tests failed but core functionality works"
pnpm run type-check
echo "β
React SDK tests completed"
- name: Publish React SDK to test tag
id: publish-react
working-directory: ./packages/sdk/react
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
PACKAGE_NAME=$(node -p "require('./package.json').name")
PACKAGE_VERSION=$(node -p "require('./package.json').version")
echo "π Publishing $PACKAGE_NAME@$PACKAGE_VERSION to test tag..."
pnpm publish --access public --tag test --no-git-checks
echo "published=true" >> $GITHUB_OUTPUT
echo "β
Successfully published $PACKAGE_NAME to test tag"
# Next.js SDK
- name: Version and build Next.js SDK
working-directory: ./packages/sdk/next
run: |
SHORT_SHA=$(git rev-parse --short HEAD)
if [ "${{ github.event_name }}" = "pull_request" ]; then
PR_NUM="${{ github.event.number }}"
PREID="test-pr${PR_NUM}.${SHORT_SHA}"
else
PREID="test.${SHORT_SHA}"
fi
echo "π¦ Versioning Next.js SDK with preid: ${PREID}"
pnpm version prerelease --preid="${PREID}" --no-git-tag-version
echo "π¨ Building Next.js SDK..."
pnpm run build
echo "β
Next.js SDK built"
- name: Test Next.js SDK
working-directory: ./packages/sdk/next
run: |
echo "π§ͺ Testing Next.js SDK..."
pnpm run test
pnpm run type-check
echo "β
Next.js SDK tests passed"
- name: Publish Next.js SDK to test tag
id: publish-next
working-directory: ./packages/sdk/next
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
PACKAGE_NAME=$(node -p "require('./package.json').name")
PACKAGE_VERSION=$(node -p "require('./package.json').version")
echo "π Publishing $PACKAGE_NAME@$PACKAGE_VERSION to test tag..."
pnpm publish --access public --tag test --no-git-checks
echo "published=true" >> $GITHUB_OUTPUT
echo "β
Successfully published $PACKAGE_NAME to test tag"
# AIx402 SDK
- name: Version and build AIx402 SDK
working-directory: ./packages/sdk/aix402
run: |
SHORT_SHA=$(git rev-parse --short HEAD)
if [ "${{ github.event_name }}" = "pull_request" ]; then
PR_NUM="${{ github.event.number }}"
PREID="test-pr${PR_NUM}.${SHORT_SHA}"
else
PREID="test.${SHORT_SHA}"
fi
echo "π¦ Versioning AIx402 SDK with preid: ${PREID}"
pnpm version prerelease --preid="${PREID}" --no-git-tag-version
echo "π¨ Building AIx402 SDK..."
pnpm run build
echo "β
AIx402 SDK built"
- name: Test AIx402 SDK
working-directory: ./packages/sdk/aix402
run: |
echo "π§ͺ Testing AIx402 SDK..."
pnpm run test
pnpm run type-check
echo "β
AIx402 SDK tests passed"
- name: Publish AIx402 SDK to test tag
id: publish-aix402
working-directory: ./packages/sdk/aix402
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
PACKAGE_NAME=$(node -p "require('./package.json').name")
PACKAGE_VERSION=$(node -p "require('./package.json').version")
echo "π Publishing $PACKAGE_NAME@$PACKAGE_VERSION to test tag..."
pnpm publish --access public --tag test --no-git-checks
echo "published=true" >> $GITHUB_OUTPUT
echo "β
Successfully published $PACKAGE_NAME to test tag"
# Echo Start CLI
- name: Version and build Echo Start CLI
working-directory: ./packages/sdk/echo-start
run: |
SHORT_SHA=$(git rev-parse --short HEAD)
if [ "${{ github.event_name }}" = "pull_request" ]; then
PR_NUM="${{ github.event.number }}"
PREID="test-pr${PR_NUM}.${SHORT_SHA}"
else
PREID="test.${SHORT_SHA}"
fi
echo "π¦ Versioning Echo Start CLI with preid: ${PREID}"
pnpm version prerelease --preid="${PREID}" --no-git-tag-version
echo "π¨ Building Echo Start CLI..."
pnpm run build
echo "β
Echo Start CLI built"
- name: Test Echo Start CLI
working-directory: ./packages/sdk/echo-start
run: |
echo "π§ͺ Testing Echo Start CLI..."
pnpm run type-check
pnpm run lint
echo "β
Echo Start CLI tests passed"
- name: Publish Echo Start CLI to test tag
id: publish-echo-start
working-directory: ./packages/sdk/echo-start
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
PACKAGE_NAME=$(node -p "require('./package.json').name")
PACKAGE_VERSION=$(node -p "require('./package.json').version")
echo "π Publishing $PACKAGE_NAME@$PACKAGE_VERSION to test tag..."
pnpm publish --access public --tag test --no-git-checks
echo "published=true" >> $GITHUB_OUTPUT
echo "β
Successfully published $PACKAGE_NAME to test tag"
- name: Summary
run: |
echo "β
Test version published successfully!"
echo "π¦ Version: ${{ steps.get-version.outputs.version }}"
echo "π·οΈ Tag: test"
echo ""
echo "Install with: npm install @merit-systems/echo-typescript-sdk@test"