git-ca 0.2.4

git plugin that drafts commit messages using GitHub Copilot
name: Publish npm

on:
  workflow_call:
    inputs:
      plan:
        required: true
        type: string

permissions:
  contents: read
  id-token: write

jobs:
  publish:
    runs-on: ubuntu-22.04
    env:
      PLAN: ${{ inputs.plan }}
    steps:
      - name: Fetch npm packages
        uses: actions/download-artifact@v7
        with:
          pattern: artifacts-*
          path: npm/
          merge-multiple: true

      - uses: actions/setup-node@v6
        with:
          node-version: "24"
          registry-url: "https://registry.npmjs.org"

      - name: Publish npm package
        run: |
          for release in $(echo "$PLAN" | jq --compact-output '.releases[] | select([.artifacts[] | endswith("-npm-package.tar.gz")] | any)'); do
            pkg=$(echo "$release" | jq '.artifacts[] | select(endswith("-npm-package.tar.gz"))' --raw-output)
            npm publish --access public "./npm/${pkg}"
          done