Skip to content

Commit bc126b5

Browse files
committed
fix(ci): publish from package directories and build yoga WASM on cache miss
- Changed npm publish to use working-directory for each package - Fixed validation to check package dist/ not monorepo root dist/ - Added conditional yoga-layout WASM build step if cache misses - Each package publishes from its own directory (packages/socket, packages/cli, packages/cli-with-sentry)
1 parent ec24a1a commit bc126b5

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

.github/workflows/provenance.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ jobs:
3232
with:
3333
scope: '@socketsecurity'
3434
- name: Cache yoga-layout WASM
35+
id: cache-yoga
3536
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
3637
with:
3738
path: packages/yoga-layout/build/wasm
@@ -40,6 +41,9 @@ jobs:
4041
yoga-wasm-
4142
- run: npm install -g npm@latest
4243
- run: pnpm install
44+
- name: Build yoga-layout WASM (if cache miss)
45+
if: steps.cache-yoga.outputs.cache-hit != 'true'
46+
run: pnpm --filter @socketsecurity/yoga-layout run build
4347

4448
# Build and publish 'socket' package (default).
4549
- name: Prepare socket package for publishing
@@ -53,7 +57,8 @@ jobs:
5357
- name: Validate socket package
5458
run: node scripts/pre-publish-validate.mjs packages/socket
5559
- name: Publish socket package
56-
run: cd dist && npm publish --provenance --access public --no-git-checks
60+
working-directory: packages/socket
61+
run: npm publish --provenance --access public --no-git-checks
5762
continue-on-error: true
5863
env:
5964
SOCKET_CLI_DEBUG: ${{ inputs.debug }}
@@ -68,7 +73,8 @@ jobs:
6873
- name: Validate @socketsecurity/cli package
6974
run: node scripts/pre-publish-validate.mjs packages/cli
7075
- name: Publish @socketsecurity/cli package
71-
run: cd dist && npm publish --provenance --access public --no-git-checks
76+
working-directory: packages/cli
77+
run: npm publish --provenance --access public --no-git-checks
7278
continue-on-error: true
7379
env:
7480
SOCKET_CLI_DEBUG: ${{ inputs.debug }}
@@ -83,7 +89,8 @@ jobs:
8389
- name: Validate @socketsecurity/cli-with-sentry package
8490
run: node scripts/pre-publish-validate.mjs packages/cli-with-sentry
8591
- name: Publish @socketsecurity/cli-with-sentry package
86-
run: cd dist && npm publish --provenance --access public --no-git-checks
92+
working-directory: packages/cli-with-sentry
93+
run: npm publish --provenance --access public --no-git-checks
8794
continue-on-error: true
8895
env:
8996
SOCKET_CLI_DEBUG: ${{ inputs.debug }}

scripts/pre-publish-validate.mjs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,12 @@ const __dirname = path.dirname(__filename)
1212
const monorepoRoot = path.resolve(__dirname, '..')
1313

1414
// Accept optional package path as first argument (e.g. 'packages/cli').
15-
// Used to read source package.json for version info.
15+
// Validates the package's dist/ directory.
1616
const packagePath = process.argv[2]
17-
const sourcePackageRoot = packagePath
17+
const projectRoot = packagePath
1818
? path.resolve(monorepoRoot, packagePath)
1919
: monorepoRoot
2020

21-
// Dist directory is always at monorepo root.
22-
const projectRoot = monorepoRoot
23-
2421
/**
2522
* Format a success message.
2623
*/
@@ -326,10 +323,10 @@ async function validateGitTag() {
326323
const warnings = []
327324

328325
try {
329-
// Read version from source package.json.
330-
const sourcePkgPath = path.join(sourcePackageRoot, 'package.json')
331-
const sourcePkg = JSON.parse(await fs.readFile(sourcePkgPath, 'utf8'))
332-
const version = sourcePkg.version
326+
// Read version from package.json.
327+
const pkgPath = path.join(projectRoot, 'package.json')
328+
const pkg = JSON.parse(await fs.readFile(pkgPath, 'utf8'))
329+
const version = pkg.version
333330

334331
// Check if tag exists.
335332
const tagName = `v${version}`

0 commit comments

Comments
 (0)