name: Release Project

on:
  workflow_run:
    workflows: [ "Detect Deps" ]
    types:
      - completed
  workflow_dispatch:

permissions:
  contents: write
  id-token: write

jobs:
  release:
    name: Release
    runs-on: ubuntu-latest
    if: ${{ github.event.workflow_run.conclusion == 'success' }}
    
    steps:
      - name: Checkout
        uses: actions/checkout@v7
        with:
          fetch-depth: 0
          fetch-tags: true
          ref: ${{ github.ref }}
      
      - name: Setup pnpm
        uses: pnpm/action-setup@v6
        with:
          version: 11
      
      - name: Setup Node.js
        uses: actions/setup-node@v7
        with:
          node-version: 24
          registry-url: https://registry.npmjs.org/
          package-manager-cache: false
      
      - name: Configure Git
        run: |
          git config --global user.name "github-actions[bot]"
          git config --global user.email "github-actions[bot]@users.noreply.github.com"
      
      - name: Install deps
        run: pnpm install --frozen-lockfile
      
      - name: Build
        run: pnpm build
      
      - name: Release
        run: pnpm exec release --ci
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
