Skip to content

Commit 5424f87

Browse files
committed
refactor(build): consolidate publish and build scripts
- Replace publish-platform.mjs with new publish.ts script - Update build-binaries.mjs to support multiple targets - Add new publish.yml workflow for unified publishing - Improve cache handling in generate-embedded-resources.mjs
1 parent 33dd618 commit 5424f87

File tree

8 files changed

+371
-278
lines changed

8 files changed

+371
-278
lines changed

.github/workflows/build-binaries.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,8 @@ jobs:
6666
name: ${{ matrix.slug }}
6767
path: binaries/${{ matrix.slug }}
6868

69-
- name: Setup npm auth
70-
if: startsWith(github.ref, 'refs/tags/v')
71-
run: |
72-
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
73-
7469
- name: Smoke test platform binary
7570
shell: bash
7671
run: |
7772
chmod +x binaries/${{ matrix.slug }}/codemachine* || true
7873
binaries/${{ matrix.slug }}/codemachine --version
79-
80-
- name: Publish platform package to npm
81-
if: startsWith(github.ref, 'refs/tags/v')
82-
shell: bash
83-
run: |
84-
cd binaries/${{ matrix.slug }}
85-
npm publish --access public --tag latest

.github/workflows/publish.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: publish
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag:
7+
description: "npm dist-tag (default: latest)"
8+
required: false
9+
type: string
10+
dry_run:
11+
description: "Dry run (no publish)"
12+
required: false
13+
default: false
14+
type: boolean
15+
push:
16+
tags:
17+
- 'v*'
18+
19+
concurrency: ${{ github.workflow }}-${{ github.ref }}
20+
21+
permissions:
22+
contents: write
23+
packages: write
24+
25+
jobs:
26+
publish:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0
32+
33+
- name: Setup Bun
34+
uses: oven-sh/setup-bun@v1
35+
with:
36+
bun-version: 1.3.0
37+
38+
- name: Install dependencies
39+
run: bun install --frozen-lockfile
40+
41+
- name: Publish packages
42+
env:
43+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
44+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
45+
NPM_TAG: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag || '' }}
46+
DRY_RUN: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.dry_run || '' }}
47+
run: |
48+
TAG=${NPM_TAG:-latest}
49+
CMD="bun scripts/publish.ts --tag ${TAG}"
50+
if [ "${DRY_RUN}" = "true" ]; then
51+
CMD="${CMD} --dry-run"
52+
fi
53+
echo "Running: ${CMD}"
54+
${CMD}

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ package-lock.json
1313
.env
1414
.env.example
1515
.npmrc
16+
.npmrc.publish
1617

1718
# Ignore folders starting with .tmp
1819
.tmp*
@@ -23,4 +24,4 @@ package-lock.json
2324
.codemachine/template.json
2425

2526
# MkDocs build output
26-
site/
27+
site/

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
"_comment_release": "Release: Publishing and validation",
4040
"prepare": "husky install",
4141
"validate": "bun scripts/validate.mjs",
42-
"release": "bun scripts/publish.mjs --tag latest",
43-
"publish:platform": "bun scripts/publish-platform.mjs"
42+
"release": "bun scripts/publish.ts --tag latest",
43+
"publish:all": "bun scripts/publish.ts --tag latest --dry-run"
4444
},
4545
"dependencies": {
4646
"1.3.0": "^1.3.0",

0 commit comments

Comments
 (0)