Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
68 changes: 68 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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 }}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
27 changes: 27 additions & 0 deletions scripts/prepare.mjs
Original file line number Diff line number Diff line change
@@ -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)