@ 260902.1 · fetching
current
name: Release Please

on:
  push:
    branches:
      - main

permissions:
  contents: read

jobs:
  release-please:
    outputs:
      release_created:  ${{ steps.release.outputs.release_created }}
      release_tag:  ${{ steps.release.outputs.tag_name }}
    permissions:
      contents: write
      pull-requests: write
    runs-on: ubuntu-latest
    steps:
      - uses: googleapis/release-please-action@16a9c90856f42705d54a6fda1823352bdc62cf38  # v4.4.0
        id: release
        with:
          release-type: node

  npm-publish:
    needs: release-please
    if: ${{ needs.release-please.outputs.release_created }}
    runs-on: ubuntu-latest
    permissions:
      contents: write
      id-token: write
    steps:
      - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8  # v5.0.0

      - uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444  # v5.0.0
        with:
          node-version: lts/*

      - name: Get npm cache directory
        id: npm-cache-dir
        run: echo "dir=$(npm config get cache)" >> "${GITHUB_OUTPUT}"

      - uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830  # v4.3.0
        with:
          path: ${{ steps.npm-cache-dir.outputs.dir }}
          key: ${{ runner.os }}-node-${{ hashFiles('**/npm-shrinkwrap.json') }}
          restore-keys: |
            ${{ runner.os }}-node-

      - run: npm ci

      - name: Add package archive to GitHub release
        run: gh release upload "$RELEASE_TAG" "$(npm pack)"
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          RELEASE_TAG: ${{ needs.release-please.outputs.release_tag }}

      - name: Publish to the npm registry
        run: npm publish --access public --provenance