From 71f019380a91e3c28be77f1561670bca25bc1ef0 Mon Sep 17 00:00:00 2001 From: Dax Raad Date: Fri, 11 Oct 2024 23:07:59 -0400 Subject: [PATCH] add dry run --- .github/workflows/binary.yml | 10 ++++++++-- generate.ts | 4 +++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/binary.yml b/.github/workflows/binary.yml index 090b53c..d470d30 100644 --- a/.github/workflows/binary.yml +++ b/.github/workflows/binary.yml @@ -1,8 +1,9 @@ name: generate on: + workflow_dispatch: + pull_request: push: - workflow_dispatch: branches: - master @@ -27,4 +28,9 @@ jobs: npm whoami env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - - run: bun run generate.ts + - run: | + if [ "${{ github.ref }}" = "refs/heads/master" ]; then + bun run generate.ts + else + bun run generate.ts --dry + fi diff --git a/generate.ts b/generate.ts index c413464..3edbeb7 100644 --- a/generate.ts +++ b/generate.ts @@ -1,5 +1,7 @@ import { $ } from "bun"; +const dry = process.argv.includes("--dry"); + for (const file of new Bun.Glob("*").scanSync("metadata")) { const provider = await import(`./metadata/${file}`); const version = [provider.version, provider.suffix].filter(Boolean).join("-"); @@ -37,5 +39,5 @@ for (const file of new Bun.Glob("*").scanSync("metadata")) { await Bun.write(tsconfig, JSON.stringify(tsjson, null, 2)); await $`bun install && bun run build`; - await $`npm publish --access public`; + if (!dry) await $`npm publish --access public`; }