Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@ layout node
# Automatically put scripts/ in your $PATH, as long as you
# are inside this repo
PATH_add ./scripts/

# Put node_modules/.bin at the front of the $PATH. Using a raw export here in
# addition to layout node / PATH_add so the path stays relative and resolves
# from the current working directory, as well as from the repo root.
export PATH="./node_modules/.bin:$PATH"
2 changes: 1 addition & 1 deletion .github/scripts/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ publish_to_npm () {
fi

echo "I'm ready to publish $PKGNAME to NPM, under $VERSION!"
npm publish --tag privaterollout
pnpm publish --no-git-checks --tag privaterollout
}

# Turns "packages/liveblocks-core" => "@liveblocks/core"
Expand Down
52 changes: 6 additions & 46 deletions .github/scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,35 +55,18 @@ check_is_valid_version () {

ROOT="$(git rev-parse --show-toplevel)"

all_published_pkgnames () {
for pkgdir in "${PKGS_TO_RELEASE[@]}"; do
jq -r .name "$ROOT/$pkgdir/package.json"
done
}

get_package_name_from_dir () {
( cd "$1" && jq -r .name package.json )
}

update_dependencies_to_new_package_versions () {
for pkgname in $( all_published_pkgnames ); do
for key in dependencies devDependencies peerDependencies; do
currversion="$(jq -r ".${key}.\"${pkgname}\"" package.json)"
if [ "$currversion" != "null" -a "$currversion" != '*' ]; then
jq ".${key}.\"${pkgname}\" = \"$1\"" package.json | sponge package.json
fi
done
done
}

update_package_version () {
PKGDIR="$1"
VERSION="$2"

PKGNAME="$( get_package_name_from_dir "$PKGDIR" )"

echo "==> Updating package.json version for $PKGNAME"
( cd "$PKGDIR" && npm version "$VERSION" $FORCE_FLAG --no-git-tag-version $WORKSPACES_UPDATE_FLAG && update_dependencies_to_new_package_versions "$2" )
( cd "$PKGDIR" && npm version "$VERSION" $FORCE_FLAG --no-git-tag-version $WORKSPACES_UPDATE_FLAG )
}

commit_to_git () {
Expand All @@ -110,38 +93,15 @@ commit_to_git () {

check_is_valid_version "$VERSION"

# Run a fresh `npm i` to ensure the lock file isn't outdated before continuing
npm install --no-audit
# Run a fresh install to ensure the lock file isn't outdated before continuing
pnpm install --no-frozen-lockfile
git is-clean -v

for PKGDIR in "${PKGS_TO_RELEASE[@]}"; do
update_package_version "$PKGDIR" "$VERSION"
done

# Update package-lock.json with newly bumped versions
npm install --no-audit

# HACK/WORKAROUND:
# For some reason we don't yet understand, the above npm install commands can
# sometimes add these "nested" Liveblocks packages. These package folders don't
# actually exist on disk, and are wrong. The mystery is why they end up in this
# lockfile.
# Here, we work around it by loop over each of them and manually removing them
# from the lockfile.
for key in $(jq -r '.packages|keys[]' package-lock.json | grep -Ee 'liveblocks-.*/node_modules/@liveblocks'); do
jq "del(.packages[\"$key\"])" package-lock.json | sponge package-lock.json
done

# One final cleanup pass
npm ci --no-audit
npm install --no-audit

# The following pattern is always indicative of a bug in this script, so let's
# fail if this is found
if grep -qEe 'packages/liveblocks-.*/node_modules/@liveblocks' package-lock.json; then
err "The lockfile contains a pattern that should not exist"
err "Please manually debug this to figure out what went wrong during the update"
exit 4
fi
# Update pnpm-lock.yaml with newly bumped versions
pnpm install --no-frozen-lockfile

commit_to_git "${COMMIT_MESSAGE}${VERSION}" "package-lock.json" "packages/" "tools/"
commit_to_git "${COMMIT_MESSAGE}${VERSION}" "pnpm-lock.yaml" "packages/" "tools/"
27 changes: 27 additions & 0 deletions .github/workflows/check-no-linked-example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Check no linked example

on: [pull_request]

jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Fail if link-locally-do-not-commit sentinel is present
run: |
if grep -r --include='*.json' --include='*.yaml' --include='*.yml' \
--exclude-dir='.github' \
-l 'link-locally-do-not-commit' . ; then
echo ""
echo "✘ Found the link-locally-do-not-commit sentinel in the files listed above."
echo " This indicates leftover state from scripts/link-example-locally.sh."
echo ""
echo " To fix:"
echo " - Delete the pnpm.overrides block from root package.json"
echo " - Revert any workspace:* deps in examples/**/package.json"
echo " - Remove the example line from pnpm-workspace.yaml"
echo " - Run pnpm install"
echo ""
exit 1
fi
6 changes: 5 additions & 1 deletion .github/workflows/publish-cli-tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,15 @@ jobs:
echo "${{ steps.version.outputs.value }}"
echo "${{ steps.npm_tag.outputs.value }}"

- name: Setup pnpm
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4

- name: Setup Node.js environment
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version-file: ".nvmrc"
registry-url: "https://registry.npmjs.org"
cache: pnpm

- name: Setup git config
run: |
Expand All @@ -84,7 +88,7 @@ jobs:

- name: Build all CLI tools
run: |
npm run build -- --filter='./tools/*' --filter='!@liveblocks/devtools'
pnpm run build --filter='./tools/*' --filter='!@liveblocks/devtools'

- name: Publish packages
env:
Expand Down
12 changes: 7 additions & 5 deletions .github/workflows/publish-devtools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,22 @@ jobs:
- name: Validate branch
run: test "$(git rev-parse --abbrev-ref HEAD)" == "main"

- name: Setup pnpm
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4

- name: Setup Node
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version-file: ".nvmrc"
cache: "npm"
cache-dependency-path: "**/package-lock.json"
cache: pnpm

- name: Setup git config
run: |
git config user.name "GitHub Actions Bot"
git config user.email "<>"

- name: Install dependencies
run: npm install
run: pnpm install --frozen-lockfile

- name: Turbo Cache
id: turbo-cache
Expand All @@ -81,10 +83,10 @@ jobs:
DevTools to " "tools/liveblocks-devtools"

- name: Build for Chromium
run: npx --no turbo run build --filter=@liveblocks/devtools
run: pnpm exec turbo run build --filter=@liveblocks/devtools

- name: Build for Firefox
run: npx --no turbo run build:firefox --filter=@liveblocks/devtools
run: pnpm exec turbo run build:firefox --filter=@liveblocks/devtools

- name: Browser Platform Publish
uses: PlasmoHQ/bpp@v3
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/publish-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,15 @@ jobs:
echo "${{ steps.version.outputs.value }}"
echo "${{ steps.npm_tag.outputs.value }}"

- name: Setup pnpm
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4

- name: Setup Node.js environment
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
with:
node-version-file: ".nvmrc"
registry-url: "https://registry.npmjs.org"
cache: pnpm

- name: Setup git config
run: |
Expand All @@ -96,7 +100,7 @@ jobs:

- name: Build all packages
run: |
npm run build -- --filter='./packages/*'
pnpm run build --filter='./packages/*'

- name: Publish packages
env:
Expand Down
Loading
Loading