Compare commits

...

4 Commits

Author SHA1 Message Date
tequ
4918e914c5 4.0.4-alpha.1 (#55) 2026-05-26 02:24:59 +00:00
tequ
7552ae8635 fix publish workflow (#54) 2026-05-26 02:18:25 +00:00
tequ
fd100f6e92 4.0.4-alpha.0 (#53) 2026-05-26 02:04:14 +00:00
tequ
587a75403a Add npm trusted publishing workflow (#48)
Add GitHub Actions workflow for npm trusted publishing via OIDC.
2026-05-26 10:47:27 +09:00
3 changed files with 104 additions and 14 deletions

102
.github/workflows/npm-publish.yml vendored Normal file
View File

@@ -0,0 +1,102 @@
name: Publish npm packages
on:
release:
types: [published]
concurrency:
group: npm-publish-${{ github.event.release.tag_name }}
cancel-in-progress: false
jobs:
publish:
name: Publish ${{ github.event.release.tag_name }}
runs-on: ubuntu-latest
environment: npm
permissions:
contents: read
id-token: write
steps:
- id: release
name: Resolve package from tag
shell: bash
run: |
case "$RELEASE_TAG" in
xahau@*) package_path="packages/xahau" ;;
xahau-address-codec@*) package_path="packages/xahau-address-codec" ;;
xahau-binary-codec@*) package_path="packages/xahau-binary-codec" ;;
xahau-keypairs@*) package_path="packages/xahau-keypairs" ;;
*)
echo "Unsupported release tag: $RELEASE_TAG" >&2
echo "Expected xahau@<version>, xahau-address-codec@<version>, xahau-binary-codec@<version>, or xahau-keypairs@<version>." >&2
exit 1
;;
esac
echo "package-path=$package_path" >> "$GITHUB_OUTPUT"
env:
RELEASE_TAG: ${{ github.event.release.tag_name }}
- uses: actions/checkout@v6
with:
ref: ${{ github.event.release.tag_name }}
- uses: actions/setup-node@v6
with:
node-version: "20"
registry-url: https://registry.npmjs.org
package-manager-cache: false
- name: Install dependencies
run: npm ci
- name: Build package
run: npm run build
- id: package
name: Read package metadata
shell: bash
run: |
package_json="${{ steps.release.outputs.package-path }}/package.json"
name="$(jq -r .name "$package_json")"
version="$(jq -r .version "$package_json")"
tag="$name@$version"
{
echo "name=$name"
echo "version=$version"
echo "tag=$tag"
} >> "$GITHUB_OUTPUT"
- name: Check release tag matches package version
shell: bash
run: |
if [[ "$RELEASE_TAG" != "$PACKAGE_TAG" ]]; then
echo "Release tag $RELEASE_TAG does not match package tag $PACKAGE_TAG." >&2
exit 1
fi
env:
RELEASE_TAG: ${{ github.event.release.tag_name }}
PACKAGE_TAG: ${{ steps.package.outputs.tag }}
- name: Check package version is unpublished
shell: bash
run: |
package_spec="${{ steps.package.outputs.tag }}"
stderr_file="$(mktemp)"
if npm view "$package_spec" version --registry https://registry.npmjs.org 2>"$stderr_file"; then
echo "$package_spec is already published." >&2
exit 1
fi
if grep -Eq "E404|404 Not Found|is not in this registry" "$stderr_file"; then
echo "$package_spec is not published yet."
exit 0
fi
cat "$stderr_file" >&2
exit 1
- name: Publish to npm
run: npm publish --workspace "${{ steps.release.outputs.package-path }}" --registry https://registry.npmjs.org

14
package-lock.json generated
View File

@@ -2724,9 +2724,6 @@
"arm64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
@@ -2741,9 +2738,6 @@
"arm64"
],
"dev": true,
"libc": [
"musl"
],
"license": "MIT",
"optional": true,
"os": [
@@ -2758,9 +2752,6 @@
"x64"
],
"dev": true,
"libc": [
"glibc"
],
"license": "MIT",
"optional": true,
"os": [
@@ -2775,9 +2766,6 @@
"x64"
],
"dev": true,
"libc": [
"musl"
],
"license": "MIT",
"optional": true,
"os": [
@@ -16060,7 +16048,7 @@
}
},
"packages/xahau": {
"version": "4.0.3",
"version": "4.0.4-alpha.1",
"license": "ISC",
"dependencies": {
"@scure/bip32": "^1.3.1",

View File

@@ -1,6 +1,6 @@
{
"name": "xahau",
"version": "4.0.3",
"version": "4.0.4-alpha.1",
"license": "ISC",
"description": "A TypeScript/JavaScript API for interacting with the Xahau Network in Node.js and the browser",
"files": [