diff --git a/.github/workflows/deno.yml b/.github/workflows/deno.yml new file mode 100644 index 0000000..9f71c0b --- /dev/null +++ b/.github/workflows/deno.yml @@ -0,0 +1,34 @@ +name: Deploy +on: + push: + branches: main + pull_request: + branches: main + +jobs: + deploy: + name: Deploy + runs-on: ubuntu-latest + + permissions: + id-token: write # Needed for auth with Deno Deploy + contents: read # Needed to clone the repository + + steps: + - name: Clone repository + uses: actions/checkout@v3 + + - name: Install Deno + uses: denoland/setup-deno@v1 + with: + deno-version: v1.x + + - name: Build step + run: "deno task build:wasm" + + - name: Upload to Deno Deploy + uses: denoland/deployctl@v1 + with: + project: "bundlejs" + entrypoint: "packages/edge/mod.ts" + root: "." diff --git a/.github/workflows/release.js.yml b/.github/workflows/release.js.yml deleted file mode 100644 index db89c85..0000000 --- a/.github/workflows/release.js.yml +++ /dev/null @@ -1,57 +0,0 @@ -name: Release -on: workflow_dispatch - -jobs: - release: - name: Release - runs-on: ubuntu-latest - - strategy: - matrix: - node-version: [18.x] - # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ - - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token - fetch-depth: 0 # otherwise, you will failed to push refs to dest repo - - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v2 - with: - node-version: ${{ matrix.node-version }} - - - name: Use Deno - uses: denoland/setup-deno@v1 - with: - deno-version: v1.x - - - name: Cache .pnpm-store - uses: actions/cache@v1 - with: - path: ~/.pnpm-store - key: ${{ runner.os }}-node${{ matrix.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }} - - - name: Install pnpm - run: curl -f https://get.pnpm.io/v6.js | node - add --global pnpm@6 - - - name: Install dependencies - run: pnpm install - - - name: Pre-release - run: pnpm -w pre-release:all - - - name: Release - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - run: pnpm -w semantic-release - - - name: Push changes - if: ${{ github.ref == 'refs/heads/main' }} - uses: ad-m/github-push-action@master - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - branch: ${{ github.ref }} diff --git a/deno.jsonc b/deno.jsonc index 585e2ff..6e4b22e 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -3,6 +3,9 @@ "./packages/core", "./packages/edge" ], + "tasks": { + "build:wasm": "deno run -A ./packages/core/scripts/build-wasm.ts" + }, "imports": { "@okikio/emitter": "npm:@okikio/emitter", "esbuild-wasm/esm/browser.d.ts": "npm:esbuild-wasm/esm/browser.d.ts", diff --git a/packages/core/scripts/build-wasm.ts b/packages/core/scripts/build-wasm.ts index 35c9cf8..42d3124 100644 --- a/packages/core/scripts/build-wasm.ts +++ b/packages/core/scripts/build-wasm.ts @@ -9,7 +9,7 @@ import { bytes } from "../src/utils/pretty-bytes.ts"; import { compress as brotli, decompress as unbrotli } from "../src/deno/brotli/mod.ts"; import { compress as zstd, decompress as unzstd } from "../src/deno/zstd/mod.ts"; -import { dirname, relative } from 'node:path'; +import { dirname, join } from 'node:path'; import * as fs from "node:fs/promises"; const encoder = new TextEncoder(); @@ -102,12 +102,21 @@ export async function build([mode = "zstd", encoding = "base64"]: Partial<["zstd `; console.log(`- Writing output to file (${target})`); + + const targetPath = join(import.meta.dirname!, "..", target); + const esbuildPath = join(import.meta.dirname!, "..", "src/esbuild.wasm"); + + console.log({ + targetPath, + esbuildPath, + }) + await Promise.all([ - fs.writeFile("src/esbuild.wasm", res), - fs.writeFile(target, encoder.encode(source)), + fs.writeFile(esbuildPath, res), + fs.writeFile(targetPath, encoder.encode(source)), ]); - const outputFile = await fs.stat(target); + const outputFile = await fs.stat(targetPath); console.log( `- Output file (${target}), final size is: ${bytes(outputFile.size)}\n` );