feat: npm distribution#29
Merged
Merged
Conversation
- ci.yml -> ci.ts (gagen). Single-job structure preserved (still runs everything on macos-14 with dotnet cross-compile). ci.ts has a shebang and is +x in git so it can be invoked directly. The lint workflow check (`./.github/workflows/ci.ts --lint`) is wired in. - Add scripts/create_npm_packages.ts: extracts each platform zip and ships the whole directory as the per-platform sub-package (`packageContents` — needed because roslyn is a self-contained .NET app where the executable references ~200 sibling DLLs and runtime files). Produces npm-dist/publish-manifest.json with the main tarball's sha256. - Add scripts/publish_npm_packages.ts: reads the manifest, publishes sub-package tarballs first (so the main's optionalDependencies resolve), then the main. Uses --access public --provenance. - Update scripts/generate_release_notes.ts: bump to @dprint/automation@0.11.3 and, when the manifest is present, append an "Alternatively, run `dprint config add npm:@dprint/roslyn`" block under step 1. - draft_release in ci.ts has permissions: contents: write, id-token: write so npm publish --provenance can do the OIDC handshake when trusted publishing is configured. npm package layout for @dprint/roslyn (matching the convention used by other dprint plugins): - main package: @dprint/roslyn - per-platform sub-packages: @dprint/roslyn-<os>-<arch>[-<libc>] (e.g. @dprint/roslyn-linux-x64-glibc, @dprint/roslyn-darwin-arm64) Worth noting for the first publish: the seven sub-packages don't exist on npm yet, so npm trusted publishing can't be configured on them ahead of time (chicken-and-egg). The first version needs to be published manually with a regular token; afterward you can add the GitHub repo as the trusted publisher for each package and CI will take over via OIDC on subsequent tags.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two changes bundled together because the npm publish steps land naturally on top of the gagen-generated workflow:
1. Convert
ci.ymlto gagen (ci.ts+ci.generated.yml)Single-job structure preserved — still runs everything on
macos-14so dotnet can cross-compile every target.ci.tshas a#!/usr/bin/env -S deno run -Ashebang and is100755in git so it can be invoked directly; the workflow lint step (./.github/workflows/ci.ts --lint) is wired in.2. Publish an npm distribution of the plugin
Adds three scripts and the corresponding workflow steps so a tag push publishes
@dprint/roslyn(main) plus seven per-platform sub-packages alongside the existing GitHub release.scripts/create_npm_packages.ts— extracts each platform zip and uses the newpackageContentsoption in@dprint/automation@0.11.3to ship the whole directory as the per-platform sub-package. Necessary because roslyn is a self-contained .NET app — the executable references ~200 sibling DLLs and runtime files. Producesnpm-dist/publish-manifest.jsonwith the main tarball's sha256.scripts/publish_npm_packages.ts— reads the manifest, publishes sub-package tarballs first (so the main'soptionalDependenciesresolve) then the main. Uses--access public --provenance. Publishes the tarballs directly so npm uploads the exact bytes whose sha256 is in the mainplugin.json.scripts/generate_release_notes.ts— bumped to@dprint/automation@0.11.3. When the manifest is present, appends an "Alternatively, rundprint config add npm:@dprint/roslyn" block under step 1, matching the existing prose style.draft_releaseinci.tsgetspermissions: { contents: write, "id-token": write }sonpm publish --provenancecan do the OIDC handshake.npm package layout
Matches the convention already in use by
@dprint/exec:@dprint/roslyn@dprint/roslyn-<os>-<arch>[-<libc>], e.g.@dprint/roslyn-linux-x64-glibc,@dprint/roslyn-darwin-arm64,@dprint/roslyn-win32-x64. Each carriesos/cpu/libcfilters so npm only installs the matching one.Test plan
deno run -A .github/workflows/ci.ts --lintpasses (idempotent generation).deno checkclean on all four scripts and onci.ts.create_npm_packages.tsin WSL, inspected the resulting tarballs — 206 entries each (205 .NET files +package.json), executable mode is0o755, all DLLs andruntimes/files end up alongside the binary, and the sha256 of each tarball equals the per-platformchecksumwritten into the mainplugin.json.@dprint/roslyn-*sub-packages exist on npm yet, so npm trusted publishing can't be configured on them ahead of time. The first version needs to be published manually with a regular token; after that, configure the GitHub repo as trusted publisher on each package and subsequent tag-driven publishes go through OIDC.Pre-merge notes
README.mdmodification onmainis unrelated and not part of this PR.@dprint/automationfrom0.10.3to0.11.3(latest) increate_plugin_file.ts-adjacent scripts. The existingcreate_plugin_file.tsis left on0.10.3since nothing requires it to be on the newer version — happy to bump it for consistency if you'd like.