name: Publish

on:
  push:
    branches:
      - master
env:
  CI: true
  PNPM_CACHE_FOLDER: .pnpm-store

jobs:
  version:
    timeout-minutes: 15

    runs-on: ${{ matrix.os }}

    strategy:
      matrix:
        os: [ubuntu-latest]
        node: [14]

    steps:
      - name: Checkout 🛎
        uses: actions/checkout@master

      - name: Setup node env 🏗
        uses: actions/setup-node@v3
        with:
          node-version: ${{ matrix.node }}
          check-latest: true

      - uses: pnpm/action-setup@v2.2.2
        name: Install pnpm
        with:
          version: 7
          run_install: false

      - name: Setup pnpm config 🏗
        run: pnpm config set store-dir $PNPM_CACHE_FOLDER

      - name: Setup npmrc 🏗
        run: echo "\n//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> .npmrc

      - name: Install dependencies 👨🏻‍💻
        run: pnpm install --no-frozen-lockfile

      - name: Bump versions 🏷 and Publish 🚀
        uses: changesets/action@v1
        with:
          version: pnpm ci:version
          commit: "chore: next release"
          title: "chore: next release"
          # manual publish currently
          # publish: pnpm ci:publish
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
