From 60aea19f5987688fbd0117c31d6aaa5909f173d3 Mon Sep 17 00:00:00 2001 From: Paul Valladares <85648028+dreyfus92@users.noreply.github.com> Date: Mon, 28 Apr 2025 08:30:12 -0600 Subject: [PATCH 1/2] add: tsdown workflow --- .github/workflows/tsdown.yml | 50 ++++++++++++++++++++++++++++++++++++ README.md | 43 +++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 .github/workflows/tsdown.yml diff --git a/.github/workflows/tsdown.yml b/.github/workflows/tsdown.yml new file mode 100644 index 0000000..a678e78 --- /dev/null +++ b/.github/workflows/tsdown.yml @@ -0,0 +1,50 @@ +name: tsdown + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +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 \ No newline at end of file diff --git a/README.md b/README.md index 652ccae..9c77e58 100644 --- a/README.md +++ b/README.md @@ -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—Copyright (c) 2023 Astro. From c25adb79a770197bb57ae76c598269735fce908a Mon Sep 17 00:00:00 2001 From: Paul Valladares <85648028+dreyfus92@users.noreply.github.com> Date: Mon, 28 Apr 2025 09:14:44 -0600 Subject: [PATCH 2/2] update: workflow & readme --- .github/workflows/tsdown.yml | 39 +++++++++--------------------------- README.md | 34 +++++++++---------------------- 2 files changed, 19 insertions(+), 54 deletions(-) diff --git a/.github/workflows/tsdown.yml b/.github/workflows/tsdown.yml index a678e78..508caa8 100644 --- a/.github/workflows/tsdown.yml +++ b/.github/workflows/tsdown.yml @@ -7,7 +7,7 @@ on: branches: [ main ] jobs: - build: + verify: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -16,35 +16,14 @@ jobs: 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 pnpm + uses: pnpm/action-setup@v2 + with: + version: 8 - - name: Install tsdown and types - run: npm install --save-dev tsdown @types/node + - name: Install dependencies + run: pnpm install - - 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 \ No newline at end of file + - name: Verify build + run: pnpm run build \ No newline at end of file diff --git a/README.md b/README.md index 9c77e58..9a0e59d 100644 --- a/README.md +++ b/README.md @@ -25,21 +25,16 @@ jobs: DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_MERGEBOT }} ``` -## tsdown +## ts down -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 +This workflow verifies that your TypeScript project builds successfully. It runs on push and pull requests to ensure your project's build process is working correctly. ### Usage Add the following to your repository's workflow: ```yml -name: Build +name: Verify Build on: push: @@ -48,25 +43,16 @@ on: branches: [main] jobs: - build: + verify: 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. +The workflow will: +1. Set up Node.js and pnpm +2. Install project dependencies +3. Run the project's build script to verify it builds successfully + +This ensures your project's build process is working correctly before merging changes. ## Acknowledgements