From 65990bdc24fc61f698e17b0aee3b75a54965f287 Mon Sep 17 00:00:00 2001 From: skulidropek <66840575+skulidropek@users.noreply.github.com> Date: Sat, 21 Mar 2026 07:36:18 +0000 Subject: [PATCH 1/2] ci: add npm publish workflow with NPM_KEY --- .github/workflows/publish.yml | 68 +++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..8f43415 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,68 @@ +name: Publish create-spawn-dock + +on: + push: + tags: + - "v*" + branches: + - main + +env: + FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true + +permissions: {} + +jobs: + publish: + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v6 + + - name: Install dependencies + uses: ./.github/actions/setup + + - name: Run checks + run: pnpm typecheck + + - name: Run tests + run: pnpm test + + - name: Build package + run: pnpm build + + - name: Configure npm registry + uses: actions/setup-node@v6 + with: + node-version: 22.12.0 + registry-url: https://registry.npmjs.org + + - name: Determine publish version + id: version + shell: bash + run: | + if [[ "${{ github.ref }}" == refs/tags/v* ]]; then + echo "type=release" >> "$GITHUB_OUTPUT" + echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT" + else + SHORT_SHA="${GITHUB_SHA::7}" + TIMESTAMP="$(date +%Y%m%d%H%M%S)" + CURRENT="$(node -p "require('./package.json').version")" + echo "type=canary" >> "$GITHUB_OUTPUT" + echo "version=${CURRENT}-canary.${TIMESTAMP}.${SHORT_SHA}" >> "$GITHUB_OUTPUT" + fi + + - name: Set package version + run: npm version "${{ steps.version.outputs.version }}" --no-git-tag-version --allow-same-version + + - name: Publish release + if: steps.version.outputs.type == 'release' + run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_KEY }} + + - name: Publish canary + if: steps.version.outputs.type == 'canary' + run: npm publish --tag canary + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_KEY }} From 4fa88877c20f5fca1a5200493de072dc2842b4a7 Mon Sep 17 00:00:00 2001 From: skulidropek <66840575+skulidropek@users.noreply.github.com> Date: Sat, 21 Mar 2026 07:39:32 +0000 Subject: [PATCH 2/2] fix(ci): make prepare resilient in GitHub Actions --- package.json | 2 +- scripts/prepare.mjs | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 scripts/prepare.mjs diff --git a/package.json b/package.json index c8bba2e..a83a3b5 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "create-spawn-dock": "./packages/app/dist/src/app/main.js" }, "scripts": { - "prepare": "corepack pnpm build", + "prepare": "node ./scripts/prepare.mjs", "build": "pnpm --filter @create-spawn-dock/app build", "check": "pnpm --filter @create-spawn-dock/app check", "test": "pnpm --filter @create-spawn-dock/app test", diff --git a/scripts/prepare.mjs b/scripts/prepare.mjs new file mode 100644 index 0000000..7548819 --- /dev/null +++ b/scripts/prepare.mjs @@ -0,0 +1,27 @@ +#!/usr/bin/env node +import { spawnSync } from "node:child_process" + +const commands = [ + ["pnpm", ["build"]], + ["corepack", ["pnpm", "build"]], +] + +let lastStatus = 1 + +for (const [command, args] of commands) { + const result = spawnSync(command, args, { + stdio: "inherit", + }) + + if (result.error && result.error.code === "ENOENT") { + continue + } + + lastStatus = result.status ?? 1 + + if (lastStatus === 0) { + process.exit(0) + } +} + +process.exit(lastStatus)