name: Release

on:
  push:
    tags:
      - v*

permissions:
  contents: write
  id-token: write

jobs:
  lint:
    uses: ./.github/workflows/lint.yaml

  test:
    uses: ./.github/workflows/test.yaml

  release:
    if: github.repository == 'pengzhanbo/vuepress-theme-plume'
    needs: [test, lint]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
        with:
          fetch-depth: 0

      - name: Install pnpm
        uses: pnpm/action-setup@v4

      - uses: actions/setup-node@v6
        with:
          node-version: 24
          registry-url: https://registry.npmjs.org
          cache: pnpm

      - name: Install deps
        run: pnpm install

      - name: Update npm
        run: npm i -g npm@latest

      - name: Build And Publish
        id: publish
        run: |
          pnpm build
          pnpm release:publish --no-git-checks
          pnpm release:sync

      - run: npx changelogithub
        env:
          GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

  deploy:
    uses: ./.github/workflows/docs-deploy.yaml
