synapsecns/sanguine

View on GitHub
.github/workflows/lerna.yaml

Summary

Maintainability
Test Coverage
name: Publish Lerna
on:
  pull_request:
    types: [closed]
    paths:
      - 'packages/**'
      - 'docs/**'
    branches:
      - master

jobs:
  publish:
    # TODO: remove true at the end
    if: github.event.pull_request.merged == true
    runs-on: ubuntu-latest

    steps:
      - name: 'Checkout'
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
          submodules: 'recursive'

      - name: Setup NodeJS
        uses: ./.github/actions/setup-nodejs

      - name: Install Foundry
        uses: foundry-rs/foundry-toolchain@v1
        with:
          version: nightly

      - name: Authenticate with private NPM package
        run: |
          echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
          echo "always-auth=true" >> ~/.npmrc

      - name: 'Version and publish' # Interesting step
        env:
          GH_TOKEN: ${{ secrets.LERNA_FGPAT }}
          CODECOV_TOKEN: ${{ secrets.CODECOV }}
          GH_COMMIT_SHA: ${{ github.event.pull_request.head.sha }}

        # branch is protected so this must be an admin token, this will expire on 03/01/2024
        # replacement should be done by a service account with a fine-grained personal access token
        run: |
          git config user.name "${{ github.actor }}"
          git config user.email "${{ github.actor}}@users.noreply.github.com"

          if [ ${{ github.base_ref }} = development ]; then
            npx lerna version --conventional-commits --conventional-prerelease --preid beta --yes
          else
            npx lerna version --conventional-commits --conventional-graduate --yes
          fi

          npx lerna publish from-git --yes --no-verify-access