name: Release
on:
  push:
    tags:
      - 'v*'

jobs:
  release:
    strategy:
      fail-fast: false
      matrix:
        platform: [ubuntu-22.04, windows-latest]

    runs-on: ${{ matrix.platform }}
    steps:
      - name: checkout repository
        uses: actions/checkout@v4
      - name: setup node
        uses: actions/setup-node@v4
        with:
          node-version: 20
      - name: install pnpm
        uses: pnpm/action-setup@v4
        with: 
          version: 9
      - name: install rust
        uses: dtolnay/rust-toolchain@stable
      - name: rust cache
        uses: swatinem/rust-cache@v2
      - name: install dependencies (ubuntu only)
        if: matrix.platform == 'ubuntu-22.04'
        run: |
          sudo apt-get update
          sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev libayatana-appindicator3-dev librsvg2-dev patchelf libssl-dev libdbus-1-dev pkg-config
      - name: install pnpm packages
        run: pnpm install
      - name: build Oxyde
        uses: tauri-apps/tauri-action@v0
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          SURREAL_URL: ${{ secrets.SURREAL_URL }}
          SURREAL_NS: ${{ secrets.SURREAL_NS }}
          SURREAL_DB: ${{ secrets.SURREAL_DB }}
          SURREAL_ACCESS: ${{ secrets.SURREAL_ACCESS }}
        with:
          tagName: v__VERSION__
          releaseName: "Oxyde v__VERSION__"
          releaseBody: "See the assets below to download."
          releaseDraft: true
          prerelease: false