-
Notifications
You must be signed in to change notification settings - Fork 14
229 lines (218 loc) · 7.27 KB
/
ci.yaml
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
name: ci
on:
pull_request:
push:
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Setup requirements
uses: ./.github/actions/setup
- name: Checkout source code
uses: actions/checkout@v4
- name: Install dependencies
run: pnpm install
- name: Lint library
working-directory: packages/typeschema
run: pnpm lint
- name: Test library
working-directory: packages/typeschema
run: pnpm test
- name: Build library
working-directory: packages/typeschema
run: pnpm build
- name: Create package
id: pack
working-directory: packages/typeschema
run: |
pnpm pack
echo "tar=$(find -name '*.tgz')" >> $GITHUB_OUTPUT
cp *.tgz ../..
- name: Lint package
working-directory: packages/typeschema
run: pnpm lint:package
- name: Upload package
uses: actions/upload-artifact@v3
with:
name: npm-package-typeschema
path: ${{steps.pack.outputs.tar}}
bundle_with_vite:
needs: build
name: Test bundling with Vite
runs-on: ubuntu-latest
steps:
- name: Setup requirements
uses: ./.github/actions/setup
- name: Create a Vite project
run: pnpm create vite sample --template vanilla-ts
- name: Download package
uses: actions/download-artifact@v3
with:
name: npm-package-typeschema
- name: Add package
working-directory: sample
run: pnpm install $(ls ../decs-typeschema-*.tgz) zod
- name: Use package
working-directory: sample
run: |
echo "
import {validate} from '@decs/typeschema';
import {z} from 'zod';
validate(z.string(), 'hello').then(console.log);
" > src/main.ts
- name: Bundle project
working-directory: sample
run: pnpm build
bundle_with_webpack:
needs: build
name: Test bundling with Webpack
runs-on: ubuntu-latest
steps:
- name: Setup requirements
uses: ./.github/actions/setup
- name: Create a Next.js project
run: pnpm create next-app sample --ts --eslint --tailwind --src-dir --app --import-alias="@/*"
- name: Download package
uses: actions/download-artifact@v3
with:
name: npm-package-typeschema
- name: Add package
working-directory: sample
run: pnpm install $(ls ../decs-typeschema-*.tgz) zod
- name: Use package
working-directory: sample
run: |
echo "
import {validate} from '@decs/typeschema';
import {z} from 'zod';
export default function Page() {
validate(z.string(), 'hello').then(console.log);
}
" > src/app/page.tsx
- name: Bundle project
working-directory: sample
run: pnpm build
bundle_with_turbopack:
needs: build
name: Test bundling with Turbopack
runs-on: ubuntu-latest
steps:
- name: Setup requirements
uses: ./.github/actions/setup
- name: Create a Next.js project
run: pnpm create next-app sample --ts --eslint --tailwind --src-dir --app --import-alias="@/*"
- name: Download package
uses: actions/download-artifact@v3
with:
name: npm-package-typeschema
- name: Add package
working-directory: sample
run: pnpm install $(ls ../decs-typeschema-*.tgz) zod
- name: Use package
working-directory: sample
run: |
echo "
import {validate} from '@decs/typeschema';
import {z} from 'zod';
export default function Page() {
validate(z.string(), 'hello').then(console.log);
}
" > src/app/page.tsx
- name: Start development server
working-directory: sample
run: pnpm next dev --turbo &
- name: Load page
working-directory: sample
run: curl http://127.0.0.1:3000 -f
check_for_version_upgrade:
name: Check for version upgrade
if: |
github.event_name == 'push' ||
github.event.pull_request.head.repo.owner.login == github.event.pull_request.base.repo.owner.login
runs-on: ubuntu-latest
needs: [bundle_with_vite, bundle_with_webpack, bundle_with_turbopack]
outputs:
from_version: ${{steps.check.outputs.from_version}}
to_version: ${{steps.check.outputs.to_version}}
is_upgraded_version: ${{steps.check.outputs.is_upgraded_version}}
is_pre_release: ${{steps.check.outputs.is_pre_release}}
steps:
- uses: garronej/ts-ci@v2.1.0
id: check
with:
action_name: is_package_json_version_upgraded
branch: ${{github.head_ref || github.ref}}
publish_to_deno:
name: Publish to Deno
runs-on: ubuntu-latest
needs: check_for_version_upgrade
if: |
needs.check_for_version_upgrade.outputs.is_upgraded_version == 'true' &&
(
github.event_name == 'push' ||
needs.check_for_version_upgrade.outputs.is_pre_release == 'true'
)
steps:
- name: Setup requirements
uses: ./.github/actions/setup
- name: Checkout source code
uses: actions/checkout@v4
- name: Skip GitHub actions
run: rm -r .github
- name: Remove deno-dist branch if it exists
run: git push origin :deno-dist || true
- name: Checkout deno-dist branch
run: git checkout -b deno-dist
- name: Install dependencies
run: pnpm install
- name: Build library
run: pnpm build:deno
- name: Track deno_dist folder
run: npx -y -p denoify remove_deno_dist_from_gitignore
env:
DRY_RUN: '0'
- name: Push changes
run: |
git config --global user.name actions
git config --global user.email actions@github.com
git add -A
git commit -am "Add deno distribution files"
git push origin deno-dist
- name: Create release on GitHub
uses: softprops/action-gh-release@v1
with:
name: v${{needs.check_for_version_upgrade.outputs.to_version}}
tag_name: v${{needs.check_for_version_upgrade.outputs.to_version}}
target_commitish: deno-dist
generate_release_notes: false
draft: false
prerelease: ${{needs.check_for_version_upgrade.outputs.is_pre_release == 'true'}}
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Remove deno-dist branch
run: git push origin :deno-dist
publish_to_npm:
name: Publish to NPM
runs-on: ubuntu-latest
needs: check_for_version_upgrade
if: |
needs.check_for_version_upgrade.outputs.is_upgraded_version == 'true' &&
(
github.event_name == 'push' ||
needs.check_for_version_upgrade.outputs.is_pre_release == 'true'
)
steps:
- name: Setup requirements
uses: ./.github/actions/setup
- name: Checkout source code
uses: actions/checkout@v4
- name: Install dependencies
run: pnpm install
- name: Build library
working-directory: packages/typeschema
run: pnpm build
- name: Publish library to NPM
uses: JS-DevTools/npm-publish@v2
with:
token: ${{secrets.NPM_TOKEN}}