Skip to content

Merge pull request #532 from YuukiToriyama/feature/purge-deprecates/m… #48

Merge pull request #532 from YuukiToriyama/feature/purge-deprecates/m…

Merge pull request #532 from YuukiToriyama/feature/purge-deprecates/m… #48

Workflow file for this run

name: Upload wasm to npmjs.com
on:
push:
tags:
- 'v*'
jobs:
publish:
runs-on: ubuntu-latest
environment: npmjs
permissions:
id-token: write
defaults:
run:
working-directory: wasm
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
scope: '@toriyama'
- name: Setup wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Build wasm module
run: wasm-pack build --release --target web --scope toriyama --out-name japanese_address_parser
# package.jsonの`name`が`@toriyama/wasm`になっているため、`@toriyama/japanese-address-parser`に書き換える
- name: Check if jq command is available
run: |
which jq
jq --version
- name: Edit package.name
run: |
cat pkg/package.json | jq '.name = "@toriyama/japanese-address-parser"' > tmp.json
mv tmp.json pkg/package.json
- name: Check if package.name was changed
run: |
# package.nameが正しく置換されているかを確認している。
# 正しく置換されていればJSONファイルを表示し、置換されていなければエラーを返しJobを中断させる。
cat pkg/package.json | jq 'if .name == "@toriyama/japanese-address-parser" then . else error("package.nameが正しく置換されていない") end'
- name: Upload wasm to npmjs.com
run: |
cd pkg
npm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPMJS_REGISTRY_TOKEN }}