name: release

on:
  workflow_dispatch:
    inputs:
      semver:
        description: "The semver to use"
        required: true
        default: "patch"
      remote:
        description: "The remote git where push the bumped version"
        required: true
        default: "origin"
      branch:
        description: "The branch you want to release"
        required: true
        default: "master"
      npm-otp:
        description: "It will provide the otp code to the npm publish"
        required: true
      npm-dist-tag:
        description: "It will add a npm tag to the module, like beta or next"
        required: false
      major:
        description: "It will unlock the release of a major release"
        required: false

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: 12
      - run: npm install
      - run: npm i releasify
      - run: |
          ./node_modules/.bin/releasify \
            publish \
            --verbose debug \
            --semver ${{github.event.inputs.semver}} \
            --remote ${{github.event.inputs.remote}} \
            --branch ${{github.event.inputs.branch}} \
            --major ${{github.event.inputs.major}} \
            --gh-token ${{secrets.GITHUB_TOKEN}}
        env:
          NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
          NPM_TOKEN: ${{secrets.NPM_TOKEN}}
