Skip to content
This repository was archived by the owner on Sep 19, 2025. It is now read-only.

Commit 48a0916

Browse files
committed
add ci and init npm support
1 parent 2d5399a commit 48a0916

File tree

5 files changed

+110
-1
lines changed

5 files changed

+110
-1
lines changed

.github/workflows/ci.yaml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: ['main']
6+
tags:
7+
- "v*"
8+
pull_request:
9+
branches: ['main']
10+
11+
workflow_dispatch:
12+
inputs:
13+
tag:
14+
description: 'Tag to release (e.g., v1.2.3)'
15+
required: false
16+
default: ''
17+
18+
jobs:
19+
test:
20+
timeout-minutes: 60
21+
runs-on: ubuntu-24.04
22+
steps:
23+
- uses: actions/checkout@v4
24+
with:
25+
ref: ${{ github.event.inputs.tag || github.ref }}
26+
- uses: actions/setup-node@v4
27+
with:
28+
node-version: lts/*
29+
- run: make install
30+
- run: make test
31+
32+
release:
33+
if: ${{ github.event.inputs.tag != '' || startsWith(github.ref, 'refs/tags/v') }}
34+
runs-on: ubuntu-24.04
35+
needs: ['test']
36+
permissions:
37+
contents: write
38+
id-token: write # The OIDC ID token is used for authentication with JSR.
39+
steps:
40+
- name: Checkout
41+
uses: actions/checkout@v4
42+
with:
43+
ref: ${{ github.event.inputs.tag || github.ref }}
44+
- uses: actions/setup-node@v4
45+
with:
46+
node-version: '20.x'
47+
registry-url: 'https://registry.npmjs.org'
48+
- name: Set version env
49+
run: echo "RELEASE_VERSION=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
50+
- uses: release-drafter/release-drafter@v5
51+
with:
52+
name: ${{ env.RELEASE_VERSION }}
53+
tag: ${{ env.RELEASE_VERSION }}
54+
version: ${{ env.RELEASE_VERSION }}
55+
publish: true
56+
env:
57+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
- run: make install
59+
- working-directory: ./js
60+
run: |
61+
make build
62+
npx jsr publish --allow-slow-types
63+
npm publish --provenance --access public
64+
env:
65+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

js/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ build-target:
1616
test: build
1717
deno test -A app.test.ts
1818
echo "https://github.com/rustwasm/wasm-pack/pull/1061"
19-
node --experimental-vm-modules --trace-warnings --experimental-wasm-modules app.test.js
19+
node --trace-warnings --experimental-wasm-modules app.test.mjs
2020

2121
doc: build
2222
deno doc --html ./pkg-bundler/pulsebeam_core.js
File renamed without changes.

js/bump.bash

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
3+
# a script that maintains both jsr and npm package versions to be aligned with git tags
4+
set -e
5+
6+
tmp=__tmp.json
7+
version=${1}
8+
version_tag="v${version}"
9+
10+
if ! echo ${version} | grep -Eo '[0-9]{1,}.[0-9]{1,}.[0-9]{1,}'; then
11+
echo "VERSION must be in semver format"
12+
exit 1
13+
fi
14+
15+
if ! [[ "$(git branch --show-current)" == "main" ]]; then
16+
echo "bumping version has to be based on main"
17+
exit 1
18+
fi
19+
20+
if ! git diff-index --quiet HEAD --; then
21+
echo "Error: Git working directory is dirty. Please commit or stash your changes before proceeding."
22+
exit 1
23+
fi
24+
25+
git fetch origin
26+
git log origin/main..HEAD
27+
28+
read -p "Are you sure to bump version to ${version}? " -n 1 -r
29+
echo # (optional) move to a new line
30+
if ! [[ $REPLY =~ ^[Yy]$ ]]; then
31+
exit 1
32+
fi
33+
34+
jq ".version = \"${version}\"" jsr.json >${tmp}
35+
mv ${tmp} jsr.json
36+
37+
git add .
38+
git commit -m "[peer] bump to ${version}"
39+
git tag ${version_tag}
40+
41+
echo "version bump has been commited and tagged"
42+
git push origin main
43+
git push origin refs/tags/${version_tag}

js/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
jsr.json

0 commit comments

Comments
 (0)