Ask questionsDocument publishing foam-vscode

This message is copied from a private channel in Discord (if you have access, you can view here).

As for publishing, you can use lerna to publish all packages in lockstep.

First bump the package version by running this in the monorepo root:

yarn lerna version <major|minor|patch>

That will bump the version numbers of all packages, and their internal references, so for example foam-vscode will point to the new version of foam-core etc.

It will also push a tag to github. If you want to dry run this locally without pushing, you can run

yarn lerna version minor --no-git-tag-version --no-push

When you're ready to publish, you can do:

yarn lerna publish

Once the npm packages are published, you can package up the vscode extension with the following command in the foam-vscode directory: yarn package-extension

The vsce tool does not understand yarn monorepos, so what this will do is use npm to install the package, which requires the foam-core dependency to have already been published to npm. I know this is ass backwards, since if you discover that something is wrong in the packaged extension, you'll need to fix whatever issue there is and then republish the packages to npm, which will again bump the version number and cause potentially dead versions in the registry. If you want to avoid that, you can first create an alpha version with creating a prerelease version, e.g. 0.4.1-alpha.0, with:

yarn lerna publish <premajor|preminor|prepatch|prerelease>

Anyway, once you've gotten a nicely packaged vsix file, you can install and test it locally:

code --install-extension foam-vscode-0.4.1.vsix

If everything is fine, you can then publish the vsix file to marketplace:

vsce publish --packagePath foam-vscode-0.4.1.vsix

That should probably be documented, and the process could be improved, but that's what it is now :man_shrugging:

Two things I wanted to note here:

  1. Ideally, it would be nice to auto-publish via a GitHub action
  2. Publishing the extension should be documented somewhere for contributors

Answer questions jsjoeio

More notes: yarn lerna publish preminor

  • update CHANGELOG.MD file

  • yarn lerna publish preminor

from package/foam-vscode yarn package-extension

  • do local testing

    • linkdef generation
    • navigation
    • graph
    • snippets
  • fix bugs if necessary (and CHANGELOG)

  • yarn lerna publish minor

  • republish from package/foam-vscode yarn package-extension

  • might wanna test it again based on bug fixes

  • publish the extension npx vsce publish --packagePath foam-vscode-XXX

  • update the release notes

    • in GitHub, top right, click on releases
    • select "tags" in top left
    • pick last released tag, add release information from changelog
    • publish (no need to attach artifacts)
  • announce on discord


  • check whether we need the pre<version> publish step, or if we can build the extension from the monorepo (once is merged)
    • to test if it works, just bump the version locally, then run the "yarn package extension" command --> if it works the issue if fixed, if it doesn't it's trying to get the package from 5pm
  • replace in package-extension the use of npx with yarn
  • write doc about release process
  • create proper test script
Joe Previte jsjoeio @facebook Seattle, WA Dev Advocate at Facebook Open Source
Github User Rank List