Skip to content

Commit b0e0f98

Browse files
authored
ci: include manifest build tasks into the main flow, attach pkgjsons to upload-artifact (#1322)
* ci: include manifest build tasks into the main flow, attach pkgjsons to upload-artifact * ci: update test wf artifact paths * ci: update pkg scripts tasks
1 parent 51aed2e commit b0e0f98

File tree

10 files changed

+30
-28
lines changed

10 files changed

+30
-28
lines changed

.github/workflows/dev-publish.yml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ jobs:
2020
- run: npm test
2121
env:
2222
FORCE_COLOR: 3
23-
- run: |
24-
npm run build:jsr
25-
npm run build:lite
26-
npm run build:pkgjson
2723
- uses: actions/upload-artifact@v4
2824
with:
2925
name: build-${{ github.run_id }}
@@ -32,6 +28,7 @@ jobs:
3228
jsr.json
3329
package.json
3430
package-lite.json
31+
package-main.json
3532
retention-days: 1
3633

3734
version:
@@ -84,8 +81,15 @@ jobs:
8481
with:
8582
name: build-${{ github.run_id }}
8683

84+
- name: pushing lite snapshot to ${{ env.GOOGLE_NPM_REGISTRY }}
85+
run: |
86+
mv -f package-lite.json package.json
87+
cat <<< $(jq '.version="${{ env.ZX_LITE_DEV_VERSION }}"' package.json) > package.json
88+
npm publish --provenance --access=public --no-git-tag-version --tag dev --registry https://${{ env.GOOGLE_NPM_REGISTRY }}
89+
8790
- name: pushing to ${{ env.GOOGLE_NPM_REGISTRY }}
8891
run: |
92+
mv -f package-main.json package.json
8993
cat <<< $(jq '.version="${{ env.ZX_DEV_VERSION }}"' package.json) > package.json
9094
npm publish --provenance --access=public --no-git-tag-version --tag dev --registry https://${{ env.GOOGLE_NPM_REGISTRY }}
9195
@@ -94,12 +98,6 @@ jobs:
9498
cat <<< $(jq '.name="@${{ github.repository }}"' package.json) > package.json
9599
npm publish --no-git-tag-version --access=public --tag dev --registry https://${{ env.GH_NPM_REGISTRY }}
96100
97-
- name: pushing lite snapshot to ${{ env.GOOGLE_NPM_REGISTRY }}
98-
run: |
99-
mv package-lite.json package.json
100-
cat <<< $(jq '.version="${{ env.ZX_LITE_DEV_VERSION }}"' package.json) > package.json
101-
npm publish --provenance --access=public --no-git-tag-version --tag dev --registry https://${{ env.GOOGLE_NPM_REGISTRY }}
102-
103101
jsr-publish:
104102
needs: [build, version]
105103
runs-on: ubuntu-latest

.github/workflows/jsr-publish.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ jobs:
2020
- run: npm test
2121
env:
2222
FORCE_COLOR: 3
23-
- run: node scripts/build-jsr.mjs
2423
- uses: actions/upload-artifact@v4
2524
with:
2625
name: build-${{ github.run_id }}

.github/workflows/publish.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ jobs:
2222
- run: npm test
2323
env:
2424
FORCE_COLOR: 3
25-
- run: |
26-
npm run build:jsr
27-
npm run build:lite
28-
npm run build:pkgjson
2925
- uses: actions/upload-artifact@v4
3026
with:
3127
name: build-${{ github.run_id }}
@@ -34,6 +30,7 @@ jobs:
3430
jsr.json
3531
package.json
3632
package-lite.json
33+
package-main.json
3734
retention-days: 1
3835

3936
version:
@@ -82,7 +79,9 @@ jobs:
8279
name: build-${{ github.run_id }}
8380

8481
- name: pushing to ${{ env.GOOGLE_NPM_REGISTRY }}
85-
run: npm publish --provenance --access=public --registry https://${{ env.GOOGLE_NPM_REGISTRY }}
82+
run: |
83+
mv -f package-main.json package.json
84+
npm publish --provenance --access=public --registry https://${{ env.GOOGLE_NPM_REGISTRY }}
8685
8786
- name: pushing to ${{ env.GH_NPM_REGISTRY }}
8887
run: |
@@ -91,7 +90,7 @@ jobs:
9190
9291
- name: pushing lite snapshot to ${{ env.GOOGLE_NPM_REGISTRY }}
9392
run: |
94-
mv package-lite.json package.json
93+
mv -f package-lite.json package.json
9594
npm publish --provenance --access=public --no-git-tag-version --tag lite --registry https://${{ env.GOOGLE_NPM_REGISTRY }}
9695
9796
jsr-publish:

.github/workflows/test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ jobs:
3232
name: build
3333
path: |
3434
build
35+
jsr.json
3536
package.json
37+
package-lite.json
38+
package-main.json
3639
retention-days: 1
3740

3841
checks:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ test/fixtures/ts-project/build/
1010
jsr.json
1111
.npmrc
1212
package-lite.json
13+
package-main.json

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,17 @@
7070
"fmt": "prettier --write .",
7171
"fmt:check": "prettier --check .",
7272
"prebuild": "rm -rf build",
73-
"build": "npm run build:versions && npm run build:js && npm run build:dts && npm run build:tests",
73+
"build": "npm run build:versions && npm run build:js && npm run build:dts && npm run build:tests && npm run build:manifest",
7474
"build:js": "node scripts/build-js.mjs --format=cjs --hybrid --entry='src/{cli,core,deps,globals,index,internals,util,vendor*}.ts' && npm run build:vendor",
7575
"build:vendor": "node scripts/build-js.mjs --format=cjs --entry=src/vendor-*.ts --bundle=all --external='./internals.ts'",
7676
"build:versions": "node scripts/build-versions.mjs",
7777
"build:tests": "node scripts/build-tests.mjs",
7878
"build:dts": "tsc --project tsconfig.json && node scripts/build-dts.mjs",
7979
"build:dcr": "docker build -f ./dcr/Dockerfile . -t zx",
8080
"build:jsr": "node scripts/build-jsr.mjs",
81-
"build:lite": "node scripts/build-lite.mjs",
82-
"build:pkgjson": "node scripts/build-pkgjson.mjs",
81+
"build:lite": "node scripts/build-pkgjson-lite.mjs",
82+
"build:pkgjson": "node scripts/build-pkgjson-main.mjs",
83+
"build:manifest": "npm run build:pkgjson && npm run build:lite && npm run build:jsr",
8384
"postbuild": "node scripts/build-clean.mjs",
8485
"docs:dev": "vitepress dev docs",
8586
"docs:build": "vitepress build docs",

scripts/build-jsr.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,5 @@ fs.writeFileSync(
8181
2
8282
)
8383
)
84+
85+
console.log('jsr.json prepared for JSR')

scripts/build-lite.mjs renamed to scripts/build-pkgjson-lite.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,4 @@ const pkgJson = {
8888

8989
fs.writeFileSync('package-lite.json', JSON.stringify(pkgJson, null, 2))
9090

91-
console.log('package-lite.json prepared for zx-lite publishing')
91+
console.log('package-lite.json prepared for npm')

scripts/build-pkgjson.mjs renamed to scripts/build-pkgjson-main.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ const whitelist = new Set([
4747
const pkgJson = Object.fromEntries(
4848
Object.entries(_pkgJson).filter(([k]) => whitelist.has(k))
4949
)
50-
fs.writeFileSync(pkgJsonFile, JSON.stringify(pkgJson, null, 2))
50+
fs.writeFileSync('package-main.json', JSON.stringify(pkgJson, null, 2))
5151

52-
console.log('package.json optimized for npm publishing')
52+
console.log('package-main.json prepared for npm')

test/it/build-npm.test.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,13 @@ describe('npm artifact', () => {
4646
'build',
4747
'man',
4848
'package.json',
49+
'package-main.json',
4950
'README.md',
5051
'LICENSE',
5152
])
5253

5354
// pack / unpack
54-
await $`npm run build:pkgjson`
55+
await $`mv package-main.json package.json`
5556
const pack = await $`npm pack`
5657
await $`tar xf ${pack}`
5758
await $`rm ${pack}`.nothrow()
@@ -131,16 +132,14 @@ describe('npm artifact', () => {
131132
await sync(root, tmp, [
132133
'build',
133134
'package.json',
135+
'package-lite.json',
134136
'README.md',
135137
'LICENSE',
136138
'scripts',
137139
])
138140

139-
// prepare package.json for lite
140-
await $`npm run build:lite`
141-
await $`mv package-lite.json package.json`
142-
143141
// pack / unpack
142+
await $`mv package-lite.json package.json`
144143
const pack = await $`npm pack`
145144
await $`tar xf ${pack}`
146145
await $`rm ${pack}`.nothrow()

0 commit comments

Comments
 (0)