name: release

on:
  workflow_dispatch:

permissions:
  contents: write

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Build theme
        run: |
          npm install
          npm run build
      - name: Create release
        run: |
          tar -zcf dist/theme-github-base.tar.gz --remove-files \
          dist/theme-github-auto.css dist/theme-github-light.css dist/theme-github-dark.css dist/theme-github-soft-dark.css

          tar -zcf dist/theme-github-colorblindness-colorblind.tar.gz --remove-files \
          dist/theme-github-colorblind-auto.css dist/theme-github-colorblind-light.css dist/theme-github-colorblind-dark.css

          tar -zcf dist/theme-github-colorblindness-tritanopia.tar.gz --remove-files \
          dist/theme-github-tritanopia-auto.css dist/theme-github-tritanopia-light.css dist/theme-github-tritanopia-dark.css

          tar -zcf dist/theme-github-extra-pink.tar.gz --remove-files \
          dist/theme-github-pink-auto.css dist/theme-github-pink-light.css dist/theme-github-pink-dark.css dist/theme-github-pink-soft-dark.css

          TAG="v$(npm run -s version)"
          gh release create "$TAG" dist/* --notes-file .github/release.md --draft -t $TAG
        env:
          GH_TOKEN: ${{ github.token }}
