Lerna Publish: Run single job for multiple tags?

hi there :wave:

i’m building a publish pipeline for a JS monorepo managed by lerna. my publish step looks like:

    - name: Publish npm packages
      env:
        NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
      run: |
        npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
        echo ":::: Publishing as $(npm whoami)"
        npm run package:publish # just `lerna publish from-package --yes --no-verify-access` under the hood

the job itself (2nd of two in the workflow - test → publish) uses:

  publish:
    name: Publish
    if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
    runs-on: ubuntu-latest
    needs: test
    steps:
      # bunch of setup stuff

my issue is that lerna likes to create a single commit with multiple tags - e.g.:

commit xyzpdq1234567890 (tag: @foo/bar@1.3.3, tag: @foo/baz@1.0.3, tag: @foo/qux@1.0.4, origin/main, origin/HEAD, main)

…and this causes my action to create redundant jobs(?) / runs for each tag / event. my aim is to create a single job whenever any tag is pushed that (assuming tests pass) publishes all packages which have changes (something lerna handles itself).

is there a way to configure a job / step to run only once if one or more new tags are pushed?

thanks in advance :pray:

Each tag getting pushed creates its own push event. You configure the workflow to run only for specific tags, but I assume you don’t want to completely ignore tags for certain components.

I’m not familiar with Lerna, but if possible you could try to publish only the component matching the tag. You’ll still get multiple workflows, but at least each tagged component would get published only once.