-
Notifications
You must be signed in to change notification settings - Fork 274
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use NPM for publishing packages instead of Lerna (#1581)
## Motivation for the change, related issues Every few months there's a problem with publishing packages via Lerna, e.g. here's the latest one: #1572 Debugging those issues takes a lot of time and typically there are no useful resources out there. This PR limits the use of Lerna to bumping the packages version in the repo and tagging the updated code. ## Implementation details Instead of using `lerna publish`, we run a simple, custom bash script. ## Testing Instructions (or ideally a Blueprint) Merge and run. It seems to be working locally and I don't see any other way of testing it in GitHub.
- Loading branch information
Showing
5 changed files
with
80 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,4 +52,4 @@ jobs: | |
# Version bump, release, tag a new version on GitHub | ||
- name: Release new version of NPM packages | ||
shell: bash | ||
run: npx [email protected] publish ${{ inputs.version_bump }} --yes --no-private --loglevel=verbose --dist-tag=${{ inputs.dist_tag }} | ||
run: npm run release:${{ inputs.version_bump }} -- --dist-tag=${{ inputs.dist_tag }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/bin/bash | ||
|
||
# Default value for dist-tag | ||
DIST_TAG="" | ||
|
||
# Parse CLI arguments | ||
while [[ "$#" -gt 0 ]]; do | ||
case $1 in | ||
--dist-tag=*) DIST_TAG="${1#*=}"; shift ;; | ||
*) echo "Unknown parameter passed: $1"; exit 1 ;; | ||
esac | ||
done | ||
|
||
# Function to check if the package.json is for a public NPM package and publish it | ||
publish_if_public_package() { | ||
if [ -f "$1/package.json" ]; then | ||
# Use Node.js to check the 'private' field in package.json | ||
is_private=$(node -e " | ||
const fs = require('fs'); | ||
const path = '$1/package.json'; | ||
const pkg = JSON.parse(fs.readFileSync(path, 'utf8')); | ||
console.log(pkg.private === true ? 'true' : 'false'); | ||
") | ||
|
||
# If "private" is false, publish the package | ||
if [ "$is_private" = "false" ]; then | ||
echo "Publishing package in $1" | ||
if [ -n "$DIST_TAG" ]; then | ||
npm publish "$1" --tag "$DIST_TAG" | ||
else | ||
npm publish "$1" | ||
fi | ||
else | ||
echo "$1 is marked as private. Skipping publish." | ||
fi | ||
else | ||
echo "No package.json found in $1. Skipping." | ||
fi | ||
} | ||
|
||
# Iterate over all directories in dist/packages/php-wasm/* | ||
for dir in dist/packages/php-wasm/*/; do | ||
publish_if_public_package "$dir" | ||
done | ||
|
||
# Iterate over all directories in dist/packages/playground/* | ||
for dir in dist/packages/playground/*/; do | ||
publish_if_public_package "$dir" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"name": "@wp-playground/website", | ||
"version": "0.0.1", | ||
"type": "module", | ||
"private": true | ||
|