name: publish
on:
  push:
    branches: [master]
jobs:
  main:
    runs-on: ubuntu-22.04
    steps:
      - uses: actions/checkout@v3
      - id: yarn_cache
        run: echo "::set-output name=dir::$(yarn cache dir)"
      - uses: actions/cache@v3
        with:
          path: ${{ steps.yarn_cache.outputs.dir }}
          key: yarn-${{ hashFiles('**/yarn.lock') }}
          restore-keys: yarn-
      - run: yarn
      - name: Git configuration.
        run: |
          git config --global user.email bot@example
          git config --global user.name bot
      - name: Publish.
        run: |
          npm version patch
          git push --atomic --tags origin HEAD
          echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc
          npm publish