name: Publish to npm as prerelease version
on:
  push:
    tags:
      - 'v[0-9]+.[0-9]+.[0-9]+-*' # prerelease tag
jobs:
  publish-prerelease:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
      with:
        token: ${{ secrets.ORIGAMI_GITHUB_TOKEN }}
        submodules: recursive
    - uses: actions/setup-node@v2.1.5
      with:
        node-version: '12.x'
        registry-url: 'https://registry.npmjs.org'
    - run: npm ci
    - name: Get the version
      id: version
      run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
    - run: npm version --no-git-tag-version ${{ steps.version.outputs.VERSION }}
    - run: npm publish --tag prerelease
      env:
        NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
