Skip to content

chore: update version and publish workflow - #10231

Open
lizschwab wants to merge 15 commits into
RaspberryPiFoundation:mainfrom
lizschwab:lerna-publish
Open

chore: update version and publish workflow#10231
lizschwab wants to merge 15 commits into
RaspberryPiFoundation:mainfrom
lizschwab:lerna-publish

Conversation

@lizschwab

Copy link
Copy Markdown
Contributor

The basics

The details

Resolves

Fixes #7765

Proposed Changes

Add Lerna to the monorepo and update the publish github action to use lerna for versioning and publishing.

Reason for Changes

This is part of the ongoing monorepo project. Leveraging Lerna sets us up to be able to build and publish packages in the correct order.

Test Coverage

No tests were added. I tested this locally by testing the version logic locally with the different variable combinations. Additional tests will be run prior to these changes being used for live publishing.

@lizschwab
lizschwab requested a review from maribethb August 5, 2026 16:49
@lizschwab
lizschwab requested a review from a team as a code owner August 5, 2026 16:49
@github-actions github-actions Bot added the PR: chore General chores (dependencies, typos, etc) label Aug 5, 2026
if [[ "${VERSION}" == *"-beta."* ]]; then
npm version prerelease --preid=beta --no-git-tag-version
VERSION_COMMAND="${VERSION_COMMAND} --conventional-commits --no-git-tag-version --yes"
if [ "${DRY_RUN}" = "true" ]; then

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a change from what I showed you the other day. I moved dry run into here so that we're using the same version command that would be applied with the same inputs.

DRY_RUN: ${{ inputs.dry_run}}
run: |
set -euo pipefail
VERSION_COMMAND="npx lerna version"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm essentially doing a string builder and adding the appropriate flags depending on the inputs and which branch we're working from.

Comment thread .github/workflows/publish.yml Outdated
if [ "${{ github.ref_name }}" != "${{ github.event.repository.default_branch }}" ]; then
echo "GitHub release would be created as prerelease."
if [ "${SKIP_VERSIONING}" = "true" ]; then
npx lerna publish from-package --yes --loglevel silly

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll remove the --loglevel silly once we're happy with the results

run: |
TARBALL="blockly-${{ needs.version.outputs.version }}.tgz"
VERSION=$(node -p "require('.packages/blockly/package.json').version")
TARBALL="blockly-*${VERSION}.tgz"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sure on this. I did a test of packing locally and all of the file names matched this pattern, so I think this will work.

"#core/*": "./build/src/core/*",
"#generators/*": "./build/src/generators/*"
},
"publishConfig": {

@lizschwab lizschwab Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the per-package configuration I was able to find for the publish command. https://github.com/lerna/lerna/blob/main/libs/commands/publish/README.md#per-package-configuration

Comment thread .gitignore Outdated
/nbproject/private/
tsdoc-metadata.json
.vscode
CHANGELOG.md

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell from the Lerna documentation, there's no per-package configuration for version. I'm hoping adding the root level and blockly package changelog files to gitignore will prevent them from being published.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense, my only question is confirming this doesn't gitignore all the CHANGELOG.md files, I am pretty sure it would. should this be /CHANGELOG.md so it's just the root level one?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch

@lizschwab
lizschwab marked this pull request as draft August 5, 2026 16:56
@lizschwab
lizschwab marked this pull request as ready for review August 5, 2026 17:27
Comment thread .github/workflows/publish.yml Outdated
VERSION=$(node -p "require('./package.json').version")
if [[ "${VERSION}" == *"-beta."* ]]; then
npm version prerelease --preid=beta --no-git-tag-version
VERSION_COMMAND="${VERSION_COMMAND} --conventional-commits --no-git-tag-version --yes"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think including no-git-tag-version is problematic here. Since you're using lerna publish from-git it's looking for the git tag corresponding to this release, but you've skipped creating it. I think we need to create it here so remove this flag. you might want it at the same place you have --no-push though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I wasn't 100% sure we still wanted that. I'll update it.

Comment thread .github/workflows/publish.yml Outdated
env:
GH_TOKEN: ${{ github.token }}
SKIP_VERSIONING: ${{ inputs.skip_versioning }}
DIST_TAG: ${{ steps.dist.output.dist_tag }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this needs to be outputs not output for the syntax to work https://docs.github.com/en/actions/how-tos/write-workflows/choose-what-workflows-do/pass-job-outputs

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are correct, good catch!

Comment thread .github/workflows/publish.yml Outdated
working-directory: packages/blockly
env:
GH_TOKEN: ${{ github.token }}
DIST_TAG: ${{ steps.dist.output.dist_tag }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same outputs typo here

working-directory: packages/blockly
run: npm pack ./dist

- name: Create GitHub release

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this step shouldn't run if dry-run is true


- name: Dry run summary
if: ${{ inputs.dry_run }}
- name: Publish

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this step also shouldn't run if dry run is true.

Comment thread .github/workflows/publish.yml Outdated
if: ${{ !inputs.skip_versioning && inputs.version_override == '' }}
- name: Build core package
working-directory: packages/blockly
run: npm run package

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is when the publishable copy of ./packages/blockly/dist/package.json gets copied / created out of the real one right?

If so then I think lerna would publish the wrong version to npm. because lerna is only going to update ./packages/blockly/package.json in the version step, which happens after this, and therefore the one in dist which actually gets published would still be the old version.

you could test this locally by running npm run package, then the version command with --no-push, and see if dist/package.json gets updated but I really don't think lerna will do that since it's not until the publish step that it cares about the dist directory at all.

I think it should be safe to resolve this by just moving this step after the version step.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, good catch!


version:
publish:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should add the guard that we have in samples that doesn't bother to run any part of this if the owner isn't RaspberryPiFoundation

Comment thread .github/workflows/publish.yml Outdated
VERSION_COMMAND="${VERSION_COMMAND} --conventional-commits --no-git-tag-version --yes"
if [ "${DRY_RUN}" = "true" ]; then
VERSION_COMMAND="${VERSION_COMMAND} --no-push"
RELEASE_VERSIONS=$(eval "$VERSION_COMMAND")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think instead of capturing this into a variable and then printing the variable one line later it might be cleaner to just eval the command? i worry capturing the output as a variable might do something weird to the formatting and there's probably going to be a lot of info since we have log-level silly on at the moment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took away the log-level silly on version, but that makes sense. I can just have it eval instead of storing in a variable. I tested it locally and it works, but the output is a little different. When we store it in the variable we get this (ignore the lack of version number change; there are no changes in my local):

Dry run: would publish the following versions to npm dist-tag: latest

Changes:
 - blockly: 13.3.0 => 13.3.0
 - @blockly/block-dynamic-connection: 13.3.0 => 13.3.0
 - @blockly/block-plus-minus: 13.3.0 => 13.3.0
 - @blockly/block-shareable-procedures: 13.3.0 => 13.3.0
 - @blockly/block-test: 13.3.0 => 13.3.0
 - @blockly/workspace-content-highlight: 13.3.0 => 13.3.0
 - @blockly/continuous-toolbox: 13.3.0 => 13.3.0
 - @blockly/plugin-cross-tab-copy-paste: 13.3.0 => 13.3.0
 - @blockly/create-package: 13.3.0 => 13.3.0
 - @blockly/dev-scripts: 13.3.0 => 13.3.0
 - @blockly/dev-tools: 13.3.0 => 13.3.0
 - @blockly/disable-top-blocks: 13.3.0 => 13.3.0
 - @blockly/field-angle: 13.3.0 => 13.3.0
 - @blockly/field-bitmap: 13.3.0 => 13.3.0
 - @blockly/field-colour: 13.3.0 => 13.3.0
 - @blockly/field-colour-hsv-sliders: 13.3.0 => 13.3.0
 - @blockly/field-date: 13.3.0 => 13.3.0
 - @blockly/field-dependent-dropdown: 13.3.0 => 13.3.0
 - @blockly/field-grid-dropdown: 13.3.0 => 13.3.0
 - @blockly/field-multilineinput: 13.3.0 => 13.3.0
 - @blockly/field-slider: 13.3.0 => 13.3.0
 - @blockly/fixed-edges: 13.3.0 => 13.3.0
 - @blockly/migrate: 13.3.0 => 13.3.0
 - @blockly/plugin-modal: 13.3.0 => 13.3.0
 - sample-app: 13.3.0 => 13.3.0 (private)
 - sample-app-typescript: 13.3.0 => 13.3.0 (private)
 - @blockly/plugin-scroll-options: 13.3.0 => 13.3.0
 - @blockly/shadow-block-converter: 13.3.0 => 13.3.0
 - @blockly/plugin-strict-connection-checker: 13.3.0 => 13.3.0
 - @blockly/suggested-blocks: 13.3.0 => 13.3.0
 - @blockly/theme-dark: 13.3.0 => 13.3.0
 - @blockly/theme-deuteranopia: 13.3.0 => 13.3.0
 - @blockly/theme-hackermode: 13.3.0 => 13.3.0 (private)
 - @blockly/theme-highcontrast: 13.3.0 => 13.3.0
 - @blockly/theme-modern: 13.3.0 => 13.3.0
 - @blockly/theme-tritanopia: 13.3.0 => 13.3.0
 - @blockly/toolbox-search: 13.3.0 => 13.3.0
 - @blockly/plugin-typed-variable-modal: 13.3.0 => 13.3.0
 - @blockly/workspace-backpack: 13.3.0 => 13.3.0
 - @blockly/workspace-minimap: 13.3.0 => 13.3.0
 - @blockly/plugin-workspace-search: 13.3.0 => 13.3.0
 - @blockly/zoom-to-fit: 13.3.0 => 13.3.0

If we eval instead we get this:

Dry run: would publish the following versions to npm dist-tag: latest
lerna notice cli v9.0.7
lerna info current version 13.3.0
lerna info Assuming all packages changed
lerna WARN version Skipping working tree validation, proceed at your own risk

Changes:
 - blockly: 13.3.0 => 13.3.0
 - @blockly/block-dynamic-connection: 13.3.0 => 13.3.0
 - @blockly/block-plus-minus: 13.3.0 => 13.3.0
 - @blockly/block-shareable-procedures: 13.3.0 => 13.3.0
 - @blockly/block-test: 13.3.0 => 13.3.0
 - @blockly/workspace-content-highlight: 13.3.0 => 13.3.0
 - @blockly/continuous-toolbox: 13.3.0 => 13.3.0
 - @blockly/plugin-cross-tab-copy-paste: 13.3.0 => 13.3.0
 - @blockly/create-package: 13.3.0 => 13.3.0
 - @blockly/dev-scripts: 13.3.0 => 13.3.0
 - @blockly/dev-tools: 13.3.0 => 13.3.0
 - @blockly/disable-top-blocks: 13.3.0 => 13.3.0
 - @blockly/field-angle: 13.3.0 => 13.3.0
 - @blockly/field-bitmap: 13.3.0 => 13.3.0
 - @blockly/field-colour: 13.3.0 => 13.3.0
 - @blockly/field-colour-hsv-sliders: 13.3.0 => 13.3.0
 - @blockly/field-date: 13.3.0 => 13.3.0
 - @blockly/field-dependent-dropdown: 13.3.0 => 13.3.0
 - @blockly/field-grid-dropdown: 13.3.0 => 13.3.0
 - @blockly/field-multilineinput: 13.3.0 => 13.3.0
 - @blockly/field-slider: 13.3.0 => 13.3.0
 - @blockly/fixed-edges: 13.3.0 => 13.3.0
 - @blockly/migrate: 13.3.0 => 13.3.0
 - @blockly/plugin-modal: 13.3.0 => 13.3.0
 - sample-app: 13.3.0 => 13.3.0 (private)
 - sample-app-typescript: 13.3.0 => 13.3.0 (private)
 - @blockly/plugin-scroll-options: 13.3.0 => 13.3.0
 - @blockly/shadow-block-converter: 13.3.0 => 13.3.0
 - @blockly/plugin-strict-connection-checker: 13.3.0 => 13.3.0
 - @blockly/suggested-blocks: 13.3.0 => 13.3.0
 - @blockly/theme-dark: 13.3.0 => 13.3.0
 - @blockly/theme-deuteranopia: 13.3.0 => 13.3.0
 - @blockly/theme-hackermode: 13.3.0 => 13.3.0 (private)
 - @blockly/theme-highcontrast: 13.3.0 => 13.3.0
 - @blockly/theme-modern: 13.3.0 => 13.3.0
 - @blockly/theme-tritanopia: 13.3.0 => 13.3.0
 - @blockly/toolbox-search: 13.3.0 => 13.3.0
 - @blockly/plugin-typed-variable-modal: 13.3.0 => 13.3.0
 - @blockly/workspace-backpack: 13.3.0 => 13.3.0
 - @blockly/workspace-minimap: 13.3.0 => 13.3.0
 - @blockly/plugin-workspace-search: 13.3.0 => 13.3.0
 - @blockly/zoom-to-fit: 13.3.0 => 13.3.0

lerna info auto-confirmed 
lerna info execute Skipping git tag/commit
lerna info execute Skipping git push
lerna info execute Skipping releases
lerna info getChangelogConfig Auto-prefixing conventional-changelog preset "conventionalcommits"
lerna info getChangelogConfig Successfully resolved preset "conventional-changelog-conventionalcommits"
lerna success version finished

So storing it is a bit cleaner but it's not harmful to have the extra logging in there.

DRY_RUN: ${{ inputs.dry_run}}
DIST_TAG: ${{ steps.dist.outputs.dist_tag }}
run: |
set -euo pipefail

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you want to keep this to make sure we can see error output and that an error in lerna causes the step to fail (my bash is kinda rusty tho)

Comment thread .gitignore Outdated
/nbproject/private/
tsdoc-metadata.json
.vscode
CHANGELOG.md

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense, my only question is confirming this doesn't gitignore all the CHANGELOG.md files, I am pretty sure it would. should this be /CHANGELOG.md so it's just the root level one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: chore General chores (dependencies, typos, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Configure the release process

2 participants