name: Release

on:
  push:
    branches:
      - main

jobs:
  test:
    uses: ./.github/workflows/test.yml

  release:
    name: Release
    runs-on: ubuntu-latest
    needs: test
    environment: npm
    permissions:
      id-token: write # for CFA and npm provenance
    steps:
      - name: Checkout
        uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
        with:
          persist-credentials: false
      - name: Setup Node.js
        uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
        with:
          node-version-file: '.nvmrc'
          cache: 'yarn'
      - name: Install
        run: yarn install --immutable
      - uses: continuousauth/action@4e8a2573eeb706f6d7300d6a9f3ca6322740b72d # v1.0.5
        timeout-minutes: 60
        with:
          project-id: ${{ secrets.CFA_PROJECT_ID }}
          secret: ${{ secrets.CFA_SECRET }}
          npm-token: ${{ secrets.NPM_TOKEN }}
