name: Release

on:
  push:
    branches:
      - main
      - 2.x

permissions:
  pull-requests: write
  contents: write

concurrency:
  group: ${{ github.workflow }}-${{ github.event.number || github.sha }}
  cancel-in-progress: ${{ github.event_name != 'push' }}

jobs:
  update-changelog:
    if: github.repository_owner == 'nuxt' && !contains(github.event.head_commit.message, 'v3.')
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
        with:
          fetch-depth: 0
      - run: corepack enable
      - uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
        with:
          node-version: 20
          cache: "pnpm"

      - name: Install dependencies
        run: pnpm install

      - run: pnpm jiti ./scripts/update-changelog.ts
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}