name: Release
on:
    push:
        branches:
            - main
            - beta

jobs:
    version:
        timeout-minutes: 15
        runs-on: ubuntu-20.04
        strategy:
            matrix:
                node-version: [18]
        steps:
            - uses: actions/checkout@v3
            - uses: actions/setup-node@v3
              with:
                  node-version: ${{ matrix.node-version }}
                  registry-url: "https://registry.npmjs.org"
                  cache: "npm"
            - run: npm ci
            - run: npm run build

            - uses: lewagon/wait-on-check-action@v1.3.1
              with:
                  ref: ${{ github.ref }}
                  check-regexp: test.*|check.*|commit-check.*|lint.*
                  repo-token: ${{ secrets.GITHUB_TOKEN }}
                  wait-interval: 10

            - run: npx --no -- semantic-release
              env:
                  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
                  NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
