name: Release

on:
  push:
    tags:
      - "v*"

jobs:
  release:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0

      - name: Install pnpm
        uses: pnpm/action-setup@v2
        with:
          run_install: true
          version: 7

      # after pnpm
      - name: Use Node.js 16
        uses: actions/setup-node@v2
        with:
          node-version: 16
          registry-url: https://registry.npmjs.org/
          cache: pnpm

      - run: npm run build
      # https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
      - run: npm run ci:publish
        env:
          NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}

      - run: npx conventional-github-releaser -p angular
        env:
          CONVENTIONAL_GITHUB_RELEASER_TOKEN: ${{secrets.GITHUB_TOKEN}}
