Merge pull request #479 from YuukiToriyama/feature/re-design-parser/m… #43
Workflow file for this run
This file contains 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
name: Upload wasm to npmjs.com | |
on: | |
push: | |
tags: | |
- 'v*' | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
environment: npmjs | |
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 --access public | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPMJS_REGISTRY_TOKEN }} |