name: release-canary

on:
  workflow_dispatch:
    branches:
      - beta

env:
  NODE_VERSION: 22.6.0
  PNPM_VERSION: 9.7.1
  DO_NOT_TRACK: 1 # Disable Turbopack telemetry
  NEXT_TELEMETRY_DISABLED: 1 # Disable Next telemetry

jobs:
  release:
    permissions:
      id-token: write
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Setup
        uses: ./.github/actions/setup
        with:
          node-version: ${{ env.NODE_VERSION }}
          pnpm-version: ${{ env.PNPM_VERSION }}
      - name: Load npm token
        run: echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
        env:
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
      - name: Canary release script
        # dry run hard-coded to true for testing and no npm token provided
        run: pnpm tsx ./scripts/publish-canary.ts
        env:
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
          NPM_CONFIG_PROVENANCE: true
