Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add: tsdown workflow
  • Loading branch information
dreyfus92 committed Apr 28, 2025
commit 60aea19f5987688fbd0117c31d6aaa5909f173d3
50 changes: 50 additions & 0 deletions .github/workflows/tsdown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: tsdown

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
Comment on lines +4 to +7

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to your docs this should be able to be called externally, you should switch this to use the workflow_call instead like the other functions.


jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'

- name: Generate tsdown config
run: |
cat > tsdown.config.ts << 'EOL'
import { defineConfig } from 'tsdown'

export default defineConfig({
entry: ['./src'],
format: ['esm'],
clean: true,
dts: true,
minify: true,
sourcemap: true,
external: [],
platform: 'node',
treeshake: true
})
EOL

- name: Install tsdown and types
run: npm install --save-dev tsdown @types/node

- name: Build with tsdown
run: npx tsdown build

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
retention-days: 5
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,49 @@ jobs:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_MERGEBOT }}
```

## tsdown

This workflow provides a standardized build process for TypeScript libraries using tsdown. It includes:

- Automatic building on push and pull requests
- Node.js setup with caching
- Automatic tsdown configuration generation
- Build artifact uploads

### Usage

Add the following to your repository's workflow:

```yml
name: Build

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build:
uses: bombshell-dev/automation/.github/workflows/tsdown.yml@main
```

The workflow will automatically:
1. Generate a standard tsdown configuration
2. Install necessary dependencies (tsdown and @types/node)
3. Build your TypeScript project
4. Upload the build artifacts

The generated configuration includes:
- ESM output format
- TypeScript declaration file generation
- Source maps
- Minification
- Node.js platform targeting
- Tree shaking optimization

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.

## Acknowledgements

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