name: all-nodejs-packages-publish

on:
  push:

    # Publish `v1.2.3` tags as releases.
    tags:
      - v*

jobs:

  build-and-publish-packages:
    runs-on: ubuntu-20.04
    steps:
    - uses: actions/checkout@v3.1.0
    - run: git fetch --unshallow --prune
    - uses: actions/setup-node@v2.1.2
      with:
        always-auth: true
        node-version: '16.14.2'
        registry-url: 'https://registry.npmjs.org'
    - name: ./tools/ci.sh
      run: ./tools/ci.sh
      env:
        DEV_BUILD_DISABLED: false
        FULL_BUILD_DISABLED: false
        JEST_TEST_RUNNER_DISABLED: true
        TAPE_TEST_RUNNER_DISABLED: true
    - name: lerna-publish
      env:
        NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
      run: |
        git config --global user.email "npm-ci@hyperledger.org"
        git config --global user.name "hyperledger-ghci"
        yarn lerna publish from-git --yes --loglevel=debug
