name: "Build And Publish Desktop Tauri Apps"
on: [workflow_dispatch]

jobs:
  build_and_publish:
    name: Build And Publish

    strategy:
      fail-fast: false
      matrix:
        platform: [macos-latest, ubuntu-latest, windows-latest]

    runs-on: ${{ matrix.platform }}
    steps:
    - uses: actions/checkout@v2
    - name: setup node
      uses: actions/setup-node@v1
      with:
        node-version: 12
    - name: install Rust stable
      uses: actions-rs/toolchain@v1
      with:
        toolchain: stable
    - name: install tauri bundler
      run: cargo install tauri-bundler --force
    - name: install webkit2gtk (ubuntu only)
      if: matrix.platform == 'ubuntu-latest'
      run: |
        sudo apt-get update
        sudo apt-get install -y webkit2gtk-4.0
    - name: install app dependencies and bootstrap packages
      run: npm install
    - uses: tauri-apps/tauri-action@v0
      env:
        PL_SERVER_URL: https://api.padloc.app
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      with:
        tagName: tauri-v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version
        releaseName: "Padloc (Tauri Edition) v__VERSION__"
        body: "WARNING: The builds in this release are experimental. Use at your own risk!"
        draft: true
        prerelease: true
        projectPath: packages/tauri
        npmScript: build
