Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document publishing foam-vscode #314

Closed
jsjoeio opened this issue Nov 4, 2020 · 11 comments
Closed

Document publishing foam-vscode #314

jsjoeio opened this issue Nov 4, 2020 · 11 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@jsjoeio
Copy link
Contributor

jsjoeio commented Nov 4, 2020

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 🤷‍♂️

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
@riccardoferretti riccardoferretti self-assigned this Nov 4, 2020
@riccardoferretti riccardoferretti added the documentation Improvements or additions to documentation label Nov 4, 2020
@riccardoferretti
Copy link
Collaborator

hi @jsjoeio - you are totally right, I have more notes from the handover with @jevakallio - will write them down in the foam doc.
I would also like to automate most of the flow (there is a testing step, which will need to be manual until we add more e2e tests), any guide/contribution/suggestion very much appreciated (somewhat related to #315)

@jsjoeio
Copy link
Contributor Author

jsjoeio commented Nov 4, 2020

I can help with this if you want @riccardoferretti - feel free to assign to me after sharing your notes!

@jsjoeio
Copy link
Contributor Author

jsjoeio commented Nov 4, 2020

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

TODO

  • check whether we need the pre publish step, or if we can build the extension from the monorepo (once feat: Support for yarn workspaces microsoft/vscode-vsce#493 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

@riccardoferretti
Copy link
Collaborator

when doing the second publish without changes, we need to force the new publish by using yarn lerna publish --force-publish \* (see https://lerna.js.org/#command-publish)

@riccardoferretti
Copy link
Collaborator

forgot to mention before, we should also make publishing to https://open-vsx.org/ part of this process

@jsjoeio
Copy link
Contributor Author

jsjoeio commented Nov 15, 2020

Good call!

@riccardoferretti
Copy link
Collaborator

https://code.visualstudio.com/api/working-with-extensions/continuous-integration#automated-publishing

@riccardoferretti
Copy link
Collaborator

The latest and greatest script I am following now:

All commands are run from the root folder

  1. checkout master and fast forward to origin/master
  • git checkout master && git fetch && git rebase
  1. run sanity checks
  • yarn clean && yarn build && yarn test
  1. Update ./packages/foam-vscode/CHANGELOG.md
  2. Publish the pre-release packages to NPM
  • yarn lerna publish preminor --no-git-tag-version --no-push
  • This will:
    • Bump the version numbers of all packages, and their internal references (so e.g. foam-vscode will point to the new version of foam-core, etc)
    • Publish the packages to npm
    • Normally it would also push a tag to git, the --no-git-tag-version --no-push options prevent that from happening
  • This step is necessary because the extension packager doesn't work with monorepos (feat: Support for yarn workspaces microsoft/vscode-vsce#493), but needs the dependencies (in this case foam-core) to be in npm
  1. Package the extension locally
  • yarn vscode:package-extension
  • the artifact can be found at ./packages/foam-vscode/foam-vscode-$version.vsix
  1. Install the extension locally and do manual testing
  • yarn vscode:install-extension
  • do manual tests
  1. Publish the release to git and NPM
  • yarn lerna publish minor
  • This will:
    • Bump the version numbers of all packages, and their internal references, as before
    • Create a git tag and push it to origin
    • Publish the packages to npm
  1. Package the extension to be released
  • yarn vscode:package-extension
  1. Publish the extension to the VSCode Marketplace
  • yarn vscode:publish-extension
  1. Update the release notes in GitHub
  • in GitHub, top right, click on "releases"
  • select "tags" in top left
  • select the tag that was just released, click "edit" and copy release information from changelog
  • publish (no need to attach artifacts)
  1. Announce to discord

@jsjoeio
Copy link
Contributor Author

jsjoeio commented Nov 19, 2020

Oh man...I'm liking how this is shaking out @riccardoferretti 👏🏼 Step 10 sounds great too! Sorry I haven't had time to jump on this, thanks for getting started!

@jvmazagao
Copy link

Can steps 9 and 10 be automated?

The discord announces, I supposed that had Github Actions and 9 We can create an Action too.

But Great Script @riccardoferretti

@riccardoferretti
Copy link
Collaborator

riccardoferretti commented Nov 27, 2020

Update. (and fixed numbering)

But as I get more familiar with this, I will probably turn it into a github action soon.
(I am using every release as a test bed for something ;) )

All commands are run from the root folder

  1. checkout master and fast forward to origin/master
  • git checkout master && git fetch && git rebase
  1. run sanity checks
  • yarn clean && yarn build && yarn test
  1. Update ./packages/foam-vscode/CHANGELOG.md
  2. Publish the pre-release packages to NPM
  • This step is necessary because the extension packager doesn't work with monorepos (feat: Support for yarn workspaces microsoft/vscode-vsce#493), but needs the dependencies (in this case foam-core) to be in npm
  • yarn lerna version preminor --no-git-tag-version --no-push
    • This will:
      • Bump the version numbers of all packages, and their internal references (so e.g. foam-vscode will point to the new version of foam-core, etc)
      • Normally it would also push a tag to git, the --no-git-tag-version --no-push options prevent that from happening
  • git add *
  • git commit -m"Preparation for next release"
  • lerna publish from-package
    • Publish the packages to npm
  1. Package the extension locally
  • yarn vscode:package-extension
  • the artifact can be found at ./packages/foam-vscode/foam-vscode-$version.vsix
  1. Install the extension locally and do manual testing
  • yarn vscode:install-extension
  • do manual tests
  1. Publish the release to git and NPM
  • yarn lerna publish minor
  • This will:
    • Bump the version numbers of all packages, and their internal references, as before
    • Create a git tag and push it to origin
    • Publish the packages to npm
  1. Package the extension to be released
  • yarn vscode:package-extension
  1. Publish the extension to the VSCode Marketplace
  • yarn vscode:publish-extension
  • if the publish command fails because the token has expired, follow the instructions here
    • (you don't need to install vsce, just call it via npx e.g. npx vsce login foam)
  1. Update the release notes in GitHub
  • in GitHub, top right, click on "releases"
  • select "tags" in top left
  • select the tag that was just released, click "edit" and copy release information from changelog
  • publish (no need to attach artifacts)
  1. Announce to discord

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants