name: Typecho Build Release Ci
on:
  release:
    types: [published]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout code
      uses: actions/checkout@v4
    - name: Build
      run: |
        mkdir build
        cp -r LICENSE.txt index.php install.php admin install usr var build/
        mkdir build/usr/uploads/
        chmod 755 build/usr/uploads/
        rm -rf build/admin/src
        rm -rf build/usr/themes/classic-22/static/scss
        cd build && zip -q -r typecho.zip * && mv typecho.zip ../ && cd -
    - name: Upload Release Asset
      uses: shogo82148/actions-upload-release-asset@v1
      with:
          upload_url: ${{ github.event.release.upload_url }}
          asset_path: ./typecho.zip
          asset_name: typecho.zip
          asset_content_type: application/zip
    - name: Trigger language build
      run: |
        curl -XPOST -H "Authorization: token ${{ secrets.WORKFLOW_TOKEN }}" \
          -H "Accept: application/vnd.github.everest-preview+json" \
          -H "Content-Type: application/json" \
          https://api.github.com/repos/typecho/languages/actions/workflows/update.yml/dispatches --data '{"ref": "master"}'