name: release

on:
  workflow_dispatch:
    inputs:
      gitea_version:
        required: true
        type: string

permissions:
  contents: write

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
      - name: Build theme
        run: |
          npm install
          npm run build
      - uses: actions/upload-artifact@v4
        with:
          name: theme-github
          path: dist/*
      - name: Create release
        run: |
          export TZ=Asia/Shanghai
          TAG="v${{ inputs.gitea_version }}-$(date +%Y%m%d-%H%M)"
          gh release create "$TAG" dist/* --notes-file .github/release.md --draft -t $TAG
        env:
          GH_TOKEN: ${{ github.token }}
