👷 Add support Github Actions #1
This file contains hidden or 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: Publish to npm | |
| on: | |
| push: | |
| branches: | |
| - main | |
| # タグが push されたときにも実行可能 | |
| tags: | |
| - 'v*.*.*' | |
| jobs: | |
| build-and-publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # リポジトリをチェックアウト | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| # Node.js をセットアップ | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: 20 | |
| registry-url: https://registry.npmjs.org | |
| # npm 認証トークンを設定 | |
| - name: Configure npm auth | |
| run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc | |
| env: | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| # 依存関係をインストール | |
| - name: Install dependencies | |
| run: pnpm install | |
| # ビルド | |
| - name: Build | |
| run: pnpm build | |
| # npm に公開 | |
| - name: Publish to npm | |
| run: pnpm publish --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |