Skip to content

Commit 779749f

Browse files
committed
ci: configure zx-lite publishing
1 parent cb6f205 commit 779749f

File tree

5 files changed

+87
-7
lines changed

5 files changed

+87
-7
lines changed

.github/workflows/dev-publish.yml

+16-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- run: npm test
2121
env:
2222
FORCE_COLOR: 3
23-
- run: node scripts/clean-package-json.mjs
23+
- run: node scripts/prepublish-clean.mjs
2424
- uses: actions/upload-artifact@v4
2525
with:
2626
name: build-${{ github.run_id }}
@@ -46,12 +46,24 @@ jobs:
4646
with:
4747
node-version: 22
4848
cache: 'npm'
49-
- uses: actions/download-artifact@v4
50-
with:
51-
name: build-${{ github.run_id }}
49+
5250
- run: echo "//wombat-dressing-room.appspot.com/:_authToken=$AUTH_TOKEN" >> .npmrc
5351
env:
5452
AUTH_TOKEN: ${{ secrets.AUTH_TOKEN }}
53+
54+
# publishing lite snapshot version: 1.2.3-lite-dev.abcd1234
55+
- uses: actions/download-artifact@v4
56+
with:
57+
name: build-${{ github.run_id }}
58+
- run: |
59+
node scripts/prepublish-lite.mjs
60+
npm version $(node --eval="process.stdout.write(require('./package.json').version)")-dev.$(git rev-parse --short HEAD) --no-git-tag-version
61+
npm publish --provenance --access=public --no-git-tag-version --tag dev
62+
63+
# publishing regular snapshot version: 1.2.3-dev.abcd1234
64+
- uses: actions/download-artifact@v4
65+
with:
66+
name: build-${{ github.run_id }}
5567
- run: |
5668
npm version $(node --eval="process.stdout.write(require('./package.json').version)")-dev.$(git rev-parse --short HEAD) --no-git-tag-version
5769
npm publish --provenance --access=public --no-git-tag-version --tag dev

.github/workflows/npm-publish.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- run: npm test
2323
env:
2424
FORCE_COLOR: 3
25-
- run: node scripts/clean-package-json.mjs
25+
- run: node scripts/prepublish-clean.mjs
2626
- uses: actions/upload-artifact@v4
2727
with:
2828
name: build-${{ github.run_id }}
@@ -54,4 +54,7 @@ jobs:
5454
- run: echo "//wombat-dressing-room.appspot.com/:_authToken=$AUTH_TOKEN" >> .npmrc
5555
env:
5656
AUTH_TOKEN: ${{ secrets.AUTH_TOKEN }}
57-
- run: npm publish --provenance --access=public
57+
- run: |
58+
npm publish --provenance --access=public
59+
node scripts/prepublish-lite.mjs
60+
npm publish --provenance --access=public --no-git-tag-version --tag lite

scripts/clean-package-json.mjs scripts/prepublish-clean.mjs

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
// Optimizes package.json for npm publishing
16+
1517
import fs from 'node:fs'
1618
import path from 'node:path'
1719

@@ -46,3 +48,5 @@ const pkgJson = Object.fromEntries(
4648
Object.entries(_pkgJson).filter(([k]) => whitelist.has(k))
4749
)
4850
fs.writeFileSync(pkgJsonFile, JSON.stringify(pkgJson, null, 2))
51+
52+
console.log('package.json prepared for npm')

scripts/prepublish-lite.mjs

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// Copyright 2024 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// https://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// Prepares lite (core) version of zx to publish
16+
17+
import fs from 'node:fs'
18+
import path from 'node:path'
19+
20+
const __dirname = path.dirname(new URL(import.meta.url).pathname)
21+
const root = path.resolve(__dirname, '..')
22+
const pkgJsonFile = path.join(root, 'package.json')
23+
const _pkgJson = JSON.parse(fs.readFileSync(pkgJsonFile, 'utf-8'))
24+
25+
const pkgJson = {
26+
..._pkgJson,
27+
version: _pkgJson.version + '-lite',
28+
exports: {
29+
'.': {
30+
types: './build/core.d.ts',
31+
import: './build/core.js',
32+
require: './build/core.cjs',
33+
default: './build/core.js',
34+
},
35+
'./package.json': './package.json',
36+
},
37+
main: './build/core.cjs',
38+
types: './build/core.d.ts',
39+
typesVersions: {
40+
'*': {
41+
'.': ['./build/core.d.ts'],
42+
},
43+
},
44+
man: undefined,
45+
files: [
46+
'build/core.cjs',
47+
'build/core.js',
48+
'build/core.d.ts',
49+
'build/deno.js',
50+
'build/esblib.js',
51+
'build/util.cjs',
52+
'build/util.js',
53+
'build/util.d.ts',
54+
'build/vendor-core.cjs',
55+
'build/vendor-core.js',
56+
'build/vendor-core.d.ts',
57+
],
58+
}
59+
60+
fs.writeFileSync(pkgJsonFile, JSON.stringify(pkgJson, null, 2))
61+
62+
console.log('package.json prepared for zx-lite')

test/core.test.js

-1
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,6 @@ describe('core', () => {
11021102
assert.deepEqual(await p1.lines(), ['foo', 'bar', 'baz'])
11031103

11041104
const p2 = $.sync`echo 'foo\nbar\r\nbaz'`
1105-
console.log('p2', p2)
11061105
assert.deepEqual(p2.lines(), ['foo', 'bar', 'baz'])
11071106
})
11081107

0 commit comments

Comments
 (0)