name: Alpha Release CI
on:
  workflow_dispatch:

jobs:
  build-tauri:
    permissions:
      contents: write
    strategy:
      fail-fast: false
      matrix:
        platform: [macos-latest, windows-latest]

    runs-on: ${{ matrix.platform }}
    steps:
      - name: Checkout repository
        uses: actions/checkout@v3

      - name: Install dependencies (ubuntu only)
        if: matrix.platform == 'ubuntu-20.04'
        run: |
          sudo apt-get update
          sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libayatana-appindicator3-dev librsvg2-dev

      - name: setup node
        uses: actions/setup-node@v3
        with:
          node-version: 16

      - name: install Rust nightly
        uses: dtolnay/rust-toolchain@nightly

      - name: install dependencies (ubuntu only)
        if: matrix.platform == 'ubuntu-20.04'
        run: |
          sudo apt-get update
          sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libappindicator3-dev librsvg2-dev patchelf

      - uses: pnpm/action-setup@v2
        with:
          version: latest-7

      - name: install frontend dependencies
        run: pnpm install # change this to npm or pnpm depending on which one you use

      - name: build app
        uses: tauri-apps/tauri-action@v0
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tauriScript: pnpm tauri
          tagName: ${{ github.ref_name }} # This only works if your workflow triggers on new tags.
          releaseName: '漫画阅读器  v__VERSION__' # tauri-action replaces \_\_VERSION\_\_ with the app version.
          releaseBody: '从附件中下载对应平台的安装包以及应用。'
          releaseDraft: true
          prerelease: false
