Skip to content

Commit 60aea19

Browse files
committed
add: tsdown workflow
1 parent 2a11ace commit 60aea19

File tree

2 files changed

+93
-0
lines changed

2 files changed

+93
-0
lines changed

.github/workflows/tsdown.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: tsdown
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Setup Node.js
16+
uses: actions/setup-node@v4
17+
with:
18+
node-version: '20'
19+
cache: 'npm'
20+
21+
- name: Generate tsdown config
22+
run: |
23+
cat > tsdown.config.ts << 'EOL'
24+
import { defineConfig } from 'tsdown'
25+
26+
export default defineConfig({
27+
entry: ['./src'],
28+
format: ['esm'],
29+
clean: true,
30+
dts: true,
31+
minify: true,
32+
sourcemap: true,
33+
external: [],
34+
platform: 'node',
35+
treeshake: true
36+
})
37+
EOL
38+
39+
- name: Install tsdown and types
40+
run: npm install --save-dev tsdown @types/node
41+
42+
- name: Build with tsdown
43+
run: npx tsdown build
44+
45+
- name: Upload build artifacts
46+
uses: actions/upload-artifact@v4
47+
with:
48+
name: dist
49+
path: dist/
50+
retention-days: 5

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,49 @@ jobs:
2525
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_MERGEBOT }}
2626
```
2727
28+
## tsdown
29+
30+
This workflow provides a standardized build process for TypeScript libraries using tsdown. It includes:
31+
32+
- Automatic building on push and pull requests
33+
- Node.js setup with caching
34+
- Automatic tsdown configuration generation
35+
- Build artifact uploads
36+
37+
### Usage
38+
39+
Add the following to your repository's workflow:
40+
41+
```yml
42+
name: Build
43+
44+
on:
45+
push:
46+
branches: [main]
47+
pull_request:
48+
branches: [main]
49+
50+
jobs:
51+
build:
52+
uses: bombshell-dev/automation/.github/workflows/tsdown.yml@main
53+
```
54+
55+
The workflow will automatically:
56+
1. Generate a standard tsdown configuration
57+
2. Install necessary dependencies (tsdown and @types/node)
58+
3. Build your TypeScript project
59+
4. Upload the build artifacts
60+
61+
The generated configuration includes:
62+
- ESM output format
63+
- TypeScript declaration file generation
64+
- Source maps
65+
- Minification
66+
- Node.js platform targeting
67+
- Tree shaking optimization
68+
69+
If you need to customize the configuration, you can create your own `tsdown.config.ts` file in your project root, and the workflow will use that instead of generating one.
70+
2871
## Acknowledgements
2972

3073
This repository borrows heavily from [`withastro/automation`](https://github.com/withastro/automation), published under the MIT License&mdash;Copyright (c) 2023 Astro.

0 commit comments

Comments
 (0)