🦔

GitHub Actionsでnpm publish

2023/09/01に公開
name: npm publish

on:
  # v*.*.*のタグが付与されたときに実行
  push:
    branches-ignore:
      - '**'
    tags:
      - 'v*'
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - name: Setup node
        uses: actions/setup-node@v3
        with:
          node-version: 18
          registry-url: 'https://registry.npmjs.org'
          scope: '@okmtyuta'
          always-auth: true
          cache: 'yarn'
        env:
	  # NPM_TOKEN: ${{ secrets.NPM_TOKEN }}とするとエラー
          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

      - name: Install dependencies
        run: yarn install

      - name: Build client
        run: yarn build:client

      - name: publish client
        run: |
          cd packages/client
          npm publish --access=public
        env:
	  # NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}とするとエラー
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

Discussion