name: Theme CD

on:
  release:
    types:
      - published

jobs:
  package:
    name: Package Theme
    runs-on: ubuntu-latest
    if: github.event_name == 'release'
    steps:
      - uses: actions/checkout@v6
      - name: Setup pnpm
        uses: pnpm/action-setup@v4
        with:
          version: 10
      - name: Setup Node.js
        uses: actions/setup-node@v6
        with:
          node-version: 22
          cache: 'pnpm'
      - name: Install dependencies
        run: pnpm install
      - name: Build
        run: pnpm build
      - name: Upload Artifacts
        uses: christopherhx/gitea-upload-artifact@v4
        with:
          name: theme-package
          path: dist

  release:
    name: Release
    runs-on: ubuntu-latest
    needs: package
    if: github.event_name == 'release'
    steps:
      - uses: actions/checkout@v6
      - name: Download Artifacts
        uses: christopherhx/gitea-download-artifact@v4
        with:
          name: theme-package
          path: dist
      - name: Upload Release Assets
        uses: akkuman/gitea-release-action@v1
        with:
          files: |-
            dist/**