-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Publish wasm API to npm #12317
Publish wasm API to npm #12317
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow this is neat.
I prefer to keep the old ruff_wasm
crate name. ruff_api
feels to generic as a crate name.
I see that this package now only publishes the web
bindings. I wonder if we need multiple packages similar to what BiomeJS does (they actually have an even more complicated setup) where they have a web
, node
(possibly deno) and bundler
package.
I've updated the warning and also adjusted the naming w/ a CI matrix job to publish 3 wasm-pack targets. I haven't used deno, but looks like it doesn't use package.json so it would need its own slightly different job probably Test run on my fork here: https://github.com/mattrunyon/ruff/actions/runs/9935706011 |
Nice thank you. We now need @charliermarsh to add the NPM token. |
Thanks for the ping -- I'll get to this today. |
@MichaReiser -- I added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to add the Cargo.toml
to
Lines 105 to 112 in 7a7c601
version_files = [ | |
"README.md", | |
"docs/integrations.md", | |
"crates/ruff/Cargo.toml", | |
"crates/ruff_linter/Cargo.toml", | |
"scripts/benchmarks/pyproject.toml", | |
] |
or it won't get automatically updated when doing the next release.
Thanks @charliermarsh . Stupid question. How can I dry-run the workflow? And is the trigger for the npm workflow in the correct release step? |
I saw something about a |
Nevermind, looks like dry-run probably doesn't publish based on this line in
|
Hmm okay. Let's see if @charliermarsh has an idea on how to test it or we'll test on release day 😆 |
If anybody w/ more knowledge on the release system wants to adjust this in the future to separate build and publish, you would basically run everything except the Could also run |
- uses: jetli/wasm-pack-action@v0.4.0 | ||
- uses: jetli/wasm-bindgen-action@v0.2.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most our workflows use taiki-e/install-action
for fast installation of cargo dependencies
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I stole this setup from the playground workflow, so might want to update both at some point
@MichaReiser - You should be able to release with The check in GitHub Actions is |
There is currently nothing handling dry-run in the action and build/publish are in the same workflow. So fair warning if the action runs at all it will try to publish. I mostly wasn't sure about how the different release steps worked w/ dry-run and I thought the publish jobs were skipped entirely w/ dry-run |
@mattrunyon - I will check... |
Confirmed that publish jobs do not run with |
I think I would make just make the new job |
LGTM! I’ll let @MichaReiser merge. |
Here's a run from my fork: https://github.com/mattrunyon/ruff/actions/runs/9963353823 If there's no token, the 2nd or 3rd to last line of the dry-run publish output will say something like "warning: You need to login to npm" Due to how Github actions work, there's no way to dry-run this until it merges (since there's no workflow w/ the same name already on main) |
Thanks again @mattrunyon for this amazing contribution. The dry run was completed successfully. https://github.com/astral-sh/ruff/actions/runs/9969546556/job/27546697354 |
Yes, the packages should be published once we do the next release. |
Summary
Will need to add an actions secret
NPM_TOKEN
that is an npm token w/ publish rights to the@astral-sh
org. It seems right now the "best" option for is a classic automation token which never expires (npm scoped tokens expire which would cause this to randomly fail after it expires).Fixes #1385
Added
ruff_wasm
to the pyproject version_files.Added a build and publish wasm job with cargo-dist. I am not familiar with this toolchain, but I regenerated the publish action. Note this does not add the wasm build to the GH release artifacts.
This will publish
@astral-sh/ruff-wasm-{target}
where target is web, bundler, or nodejsTest Plan
I test published this in my fork with a few modifications
Workflows: https://github.com/mattrunyon/ruff/actions/workflows/publish-wasm.yml
npm: https://www.npmjs.com/package/@mattrunyon/ruff-api