name: Release to npm
on:
  workflow_dispatch:
  schedule:
    - cron: '0 * * * *'

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Check for new go-ipfs version
        id: check
        uses: ./.github/actions/check-for-go-ipfs-release
      - name: Set up node
        if: steps.check.outputs.publish == 'true'
        uses: actions/setup-node@v1
        with:
          node-version: 14.x
      - name: Install
        if: steps.check.outputs.publish == 'true'
        run: npm install
      - name: Test
        if: steps.check.outputs.publish == 'true'
        run: npm test
      - name: Publish
        if: steps.check.outputs.publish == 'true'
        uses: ./.github/actions/publish
        env:
          NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
