name: Node.js Package
on:
  workflow_dispatch:
    inputs:
      newversion:
        description: 'Next Semantic Version Bump (major minor patch)'
        required: true

jobs:
  publish-npm:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: recursive
      - uses: actions/setup-node@v4
        with:
          node-version: lts/*
          registry-url: https://registry.npmjs.org/
      - run: npm install
      - run: npm run gen
      - run: git add src/generated/ && git commit -m "contracts gen ${{ github.event.inputs.newversion }}" .
      - run: npm run build
      - name: Version and publish to npm
        id: npm-bump
        uses: bcomnes/npm-bump@v2
        with:
          git_email: t-invest-dev@ru-investments.tech
          git_username: ${{ github.actor }}
          newversion: ${{ github.event.inputs.newversion }}
          push_version_commit: true # if your prePublishOnly step pushes git commits, you can omit this input or set it to false.
          github_token: ${{ secrets.GITHUB_TOKEN }} # built in actions token.  Passed tp gh-release if in use.
          npm_token: ${{ secrets.NPM_TOKEN }} # user set secret token generated at npm        
