Skip to content

Commit 8c6c4a0

Browse files
authored
chore(publish): enable publishing on npm (#36)
1 parent 5926537 commit 8c6c4a0

File tree

2 files changed

+35
-9
lines changed

2 files changed

+35
-9
lines changed

.github/workflows/release.yml

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,15 +304,44 @@ jobs:
304304
done
305305
git push
306306
307+
publish-npm:
308+
needs:
309+
- plan
310+
- host
311+
runs-on: "ubuntu-20.04"
312+
env:
313+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
314+
PLAN: ${{ needs.plan.outputs.val }}
315+
if: ${{ !fromJson(needs.plan.outputs.val).announcement_is_prerelease || fromJson(needs.plan.outputs.val).publish_prereleases }}
316+
steps:
317+
- name: Fetch npm packages
318+
uses: actions/download-artifact@v4
319+
with:
320+
pattern: artifacts-*
321+
path: npm/
322+
merge-multiple: true
323+
- uses: actions/setup-node@v4
324+
with:
325+
node-version: '20.x'
326+
registry-url: 'https://registry.npmjs.org'
327+
- run: |
328+
for release in $(echo "$PLAN" | jq --compact-output '.releases[] | select([.artifacts[] | endswith("-npm-package.tar.gz")] | any)'); do
329+
pkg=$(echo "$release" | jq '.artifacts[] | select(endswith("-npm-package.tar.gz"))' --raw-output)
330+
npm publish --access public "./npm/${pkg}"
331+
done
332+
env:
333+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
334+
307335
announce:
308336
needs:
309337
- plan
310338
- host
311339
- publish-homebrew-formula
340+
- publish-npm
312341
# use "always() && ..." to allow us to wait for all publish jobs while
313342
# still allowing individual publish jobs to skip themselves (for prereleases).
314343
# "host" however must run to completion, no skipping allowed!
315-
if: ${{ always() && needs.host.result == 'success' && (needs.publish-homebrew-formula.result == 'skipped' || needs.publish-homebrew-formula.result == 'success') }}
344+
if: ${{ always() && needs.host.result == 'success' && (needs.publish-homebrew-formula.result == 'skipped' || needs.publish-homebrew-formula.result == 'success') && (needs.publish-npm.result == 'skipped' || needs.publish-npm.result == 'success') }}
316345
runs-on: "ubuntu-20.04"
317346
env:
318347
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Cargo.toml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,15 @@ cargo-dist-version = "0.21.0"
4141
# CI backends to support
4242
ci = "github"
4343
# The installers to generate for each app
44-
installers = ["shell", "powershell", "homebrew"]
44+
installers = ["shell", "powershell", "npm", "homebrew"]
45+
# A namespace to use when publishing this package to the npm registry
46+
npm-scope = "@todor-a"
4547
# A GitHub repo to push Homebrew formulas to
4648
tap = "todor-a/homebrew-tap"
4749
# Publish jobs to run in CI
48-
publish-jobs = ["homebrew"]
50+
publish-jobs = ["homebrew", "npm"]
4951
# Target platforms to build apps for (Rust target-triple syntax)
50-
targets = [
51-
"aarch64-apple-darwin",
52-
"x86_64-apple-darwin",
53-
"x86_64-unknown-linux-gnu",
54-
"x86_64-pc-windows-msvc",
55-
]
52+
targets = ["aarch64-apple-darwin", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu", "x86_64-pc-windows-msvc"]
5653
# The archive format to use for windows builds (defaults .zip)
5754
windows-archive = ".tar.gz"
5855
# The archive format to use for non-windows builds (defaults .tar.xz)

0 commit comments

Comments
 (0)