name: 'real world tests'

on:
  workflow_dispatch:
  pull_request:
  push:
    branches:
      - dev

jobs:
  v1:
    strategy:
      fail-fast: false
      matrix:
        include:
          - platform: 'macos-latest'
            args: '--verbose --target universal-apple-darwin'
          - platform: 'ubuntu-22.04'
            args: '--verbose'
          - platform: 'windows-latest'
            args: '--verbose'

    runs-on: ${{ matrix.platform }}
    steps:
      - uses: actions/checkout@v4

      # node
      - name: install pnpm
        uses: pnpm/action-setup@v4
        with:
          version: 10.x.x

      - name: setup node
        uses: actions/setup-node@v4
        with:
          node-version: lts/*
          cache: pnpm

      - name: install example dependencies
        run: |
          cd ./.github/fixtures/example-v1
          pnpm install
      # Testing cli fallback install
      #          cd ../example-with-tauri-v1
      #          pnpm install

      # rust
      - name: install Rust stable
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: aarch64-apple-darwin,x86_64-apple-darwin

      - uses: Swatinem/rust-cache@v2
        with:
          cache-on-failure: true
          workspaces: |
            ./.github/fixtures/example-v1/src-tauri -> ../../target
            ./.github/fixtures/example-with-tauri-v1/src-tauri -> ../../target

      # system
      - name: install dependencies (ubuntu only)
        if: matrix.platform == 'ubuntu-22.04'
        run: |
          sudo apt-get update
          sudo apt-get install -y libwebkit2gtk-4.0-dev libappindicator3-dev librsvg2-dev

      - name: Preconfigured Tauri Project
        uses: ./
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          # Updater signature is exposed here to make sure it works in PR's
          TAURI_PRIVATE_KEY: dW50cnVzdGVkIGNvbW1lbnQ6IHJzaWduIGVuY3J5cHRlZCBzZWNyZXQga2V5ClJXUlRZMEl5YTBGV3JiTy9lRDZVd3NkL0RoQ1htZmExNDd3RmJaNmRMT1ZGVjczWTBKZ0FBQkFBQUFBQUFBQUFBQUlBQUFBQWdMekUzVkE4K0tWQ1hjeGt1Vkx2QnRUR3pzQjVuV0ZpM2czWXNkRm9hVUxrVnB6TUN3K1NheHJMREhQbUVWVFZRK3NIL1VsMDBHNW5ET1EzQno0UStSb21nRW4vZlpTaXIwZFh5ZmRlL1lSN0dKcHdyOUVPclVvdzFhVkxDVnZrbHM2T1o4Tk1NWEU9Cg==
        with:
          projectPath: ./.github/fixtures/example-with-tauri-v1
          includeDebug: true
          includeRelease: false
          tagName: ${{ !github.event.pull_request.head.repo.fork && 'example-with-tauri-v__VERSION__' || '' }}
          releaseName: 'Release example with preconfigured Tauri app v__VERSION__ for tauri-v1'
          releaseBody: 'See the assets to download this version and install.'
          releaseDraft: true
          uploadPlainBinary: true
          args: ${{ matrix.args }}

      - name: Frontend-only Project
        uses: ./
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          # Updater signature is exposed here to make sure it works in PR's
          TAURI_PRIVATE_KEY: dW50cnVzdGVkIGNvbW1lbnQ6IHJzaWduIGVuY3J5cHRlZCBzZWNyZXQga2V5ClJXUlRZMEl5YTBGV3JiTy9lRDZVd3NkL0RoQ1htZmExNDd3RmJaNmRMT1ZGVjczWTBKZ0FBQkFBQUFBQUFBQUFBQUlBQUFBQWdMekUzVkE4K0tWQ1hjeGt1Vkx2QnRUR3pzQjVuV0ZpM2czWXNkRm9hVUxrVnB6TUN3K1NheHJMREhQbUVWVFZRK3NIL1VsMDBHNW5ET1EzQno0UStSb21nRW4vZlpTaXIwZFh5ZmRlL1lSN0dKcHdyOUVPclVvdzFhVkxDVnZrbHM2T1o4Tk1NWEU9Cg==
        with:
          projectPath: ./.github/fixtures/example-v1
          distPath: ../dist # relative to tauri.conf.json
          iconPath: ./icon.png # relative to projectPath
          bundleIdentifier: com.tauri.actiontest
          appName: example
          appVersion: ../package.json # relative to tauri.conf.json
          includeDebug: true
          includeRelease: false
          tagName: ${{ !github.event.pull_request.head.repo.fork && 'example-v__VERSION__' || '' }}
          releaseName: 'Release example app v__VERSION__ for tauri-v1'
          releaseBody: 'See the assets to download this version and install.'
          releaseDraft: true
          uploadPlainBinary: true
          args: ${{ matrix.args }}

  v2:
    strategy:
      fail-fast: false
      matrix:
        include:
          - platform: 'macos-latest'
            args: '--verbose --target universal-apple-darwin'
          - platform: 'ubuntu-22.04'
            args: '--verbose'
          - platform: 'windows-latest'
            args: '--verbose'

    runs-on: ${{ matrix.platform }}
    steps:
      - uses: actions/checkout@v4

      # node
      - name: install pnpm
        uses: pnpm/action-setup@v4
        with:
          version: 10.x.x

      - name: setup node
        uses: actions/setup-node@v4
        with:
          node-version: lts/*
          cache: pnpm

      - name: install example dependencies
        run: |
          cd ./.github/fixtures/example-v2
          pnpm install
      # Testing cli fallback install
      #          cd ../example-with-tauri-v2
      #          pnpm install

      # rust
      - name: install Rust stable
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: aarch64-apple-darwin,x86_64-apple-darwin

      - uses: Swatinem/rust-cache@v2
        with:
          cache-on-failure: true
          workspaces: |
            ./.github/fixtures/example-v2/src-tauri -> ../../target
            ./.github/fixtures/example-with-tauri-v2/src-tauri -> ../../target

      # system
      - name: install dependencies (ubuntu only)
        if: matrix.platform == 'ubuntu-22.04'
        run: |
          sudo apt-get update
          sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev

      - name: Preconfigured Tauri Project
        uses: ./
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          # Updater signature is exposed here to make sure it works in PR's
          TAURI_SIGNING_PRIVATE_KEY: dW50cnVzdGVkIGNvbW1lbnQ6IHJzaWduIGVuY3J5cHRlZCBzZWNyZXQga2V5ClJXUlRZMEl5YTBGV3JiTy9lRDZVd3NkL0RoQ1htZmExNDd3RmJaNmRMT1ZGVjczWTBKZ0FBQkFBQUFBQUFBQUFBQUlBQUFBQWdMekUzVkE4K0tWQ1hjeGt1Vkx2QnRUR3pzQjVuV0ZpM2czWXNkRm9hVUxrVnB6TUN3K1NheHJMREhQbUVWVFZRK3NIL1VsMDBHNW5ET1EzQno0UStSb21nRW4vZlpTaXIwZFh5ZmRlL1lSN0dKcHdyOUVPclVvdzFhVkxDVnZrbHM2T1o4Tk1NWEU9Cg==
        with:
          projectPath: ./.github/fixtures/example-with-tauri-v2
          includeDebug: true
          includeRelease: false
          tagName: ${{ !github.event.pull_request.head.repo.fork && 'example-with-tauri-v__VERSION__' || '' }}
          releaseName: 'Release example with preconfigured Tauri app v__VERSION__ for tauri-v2'
          releaseBody: 'See the assets to download this version and install.'
          releaseDraft: true
          args: ${{ matrix.args }}
          updaterJsonKeepUniversal: true
          retryAttempts: 1
          assetNamePattern: '[name]x[version]x[platform]x[arch]x[mode]x[setup]x[ext]'
          uploadPlainBinary: true

      - name: Frontend-only Project
        uses: ./
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          # Updater signature is exposed here to make sure it works in PR's
          TAURI_SIGNING_PRIVATE_KEY: dW50cnVzdGVkIGNvbW1lbnQ6IHJzaWduIGVuY3J5cHRlZCBzZWNyZXQga2V5ClJXUlRZMEl5YTBGV3JiTy9lRDZVd3NkL0RoQ1htZmExNDd3RmJaNmRMT1ZGVjczWTBKZ0FBQkFBQUFBQUFBQUFBQUlBQUFBQWdMekUzVkE4K0tWQ1hjeGt1Vkx2QnRUR3pzQjVuV0ZpM2czWXNkRm9hVUxrVnB6TUN3K1NheHJMREhQbUVWVFZRK3NIL1VsMDBHNW5ET1EzQno0UStSb21nRW4vZlpTaXIwZFh5ZmRlL1lSN0dKcHdyOUVPclVvdzFhVkxDVnZrbHM2T1o4Tk1NWEU9Cg==
        with:
          projectPath: ./.github/fixtures/example-v2
          distPath: ../dist # relative to tauri.conf.json
          iconPath: ./icon.png # relative to projectPath
          bundleIdentifier: com.tauri.actiontest
          appName: example
          appVersion: ../package.json # relative to tauri.conf.json
          includeDebug: true
          includeRelease: false
          tagName: ${{ !github.event.pull_request.head.repo.fork && 'example-v__VERSION__' || '' }}
          releaseName: 'Release example app v__VERSION__ for tauri-v2'
          releaseBody: 'See the assets to download this version and install.'
          releaseDraft: true
          uploadPlainBinary: true
          args: ${{ matrix.args }}

  arm:
    strategy:
      fail-fast: false
      matrix:
        include:
          - platform: 'ubuntu-24.04-arm'
            args: '--verbose'
          - platform: 'windows-11-arm'
            args: '--verbose'

    runs-on: ${{ matrix.platform }}
    steps:
      - uses: actions/checkout@v4

      # node
      - name: install pnpm
        uses: pnpm/action-setup@v4
        with:
          version: 10.x.x

      - name: setup node
        uses: actions/setup-node@v4
        with:
          node-version: lts/*
          cache: pnpm

      - name: install example dependencies
        run: |
          cd ./.github/fixtures/example-v2
          pnpm install
      # Testing cli fallback install
      #          cd ../example-with-tauri-v2
      #          pnpm install

      # rust
      - name: install Rust stable
        uses: dtolnay/rust-toolchain@stable

      - uses: Swatinem/rust-cache@v2
        with:
          cache-on-failure: true
          workspaces: |
            ./.github/fixtures/example-v2/src-tauri -> ../../target
            ./.github/fixtures/example-with-tauri-v2/src-tauri -> ../../target

      # system
      - name: install dependencies (ubuntu only)
        if: matrix.platform == 'ubuntu-24.04-arm'
        run: |
          sudo apt-get update
          sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev

      - name: Preconfigured Tauri Project
        uses: ./
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          # Updater signature is exposed here to make sure it works in PR's
          TAURI_SIGNING_PRIVATE_KEY: dW50cnVzdGVkIGNvbW1lbnQ6IHJzaWduIGVuY3J5cHRlZCBzZWNyZXQga2V5ClJXUlRZMEl5YTBGV3JiTy9lRDZVd3NkL0RoQ1htZmExNDd3RmJaNmRMT1ZGVjczWTBKZ0FBQkFBQUFBQUFBQUFBQUlBQUFBQWdMekUzVkE4K0tWQ1hjeGt1Vkx2QnRUR3pzQjVuV0ZpM2czWXNkRm9hVUxrVnB6TUN3K1NheHJMREhQbUVWVFZRK3NIL1VsMDBHNW5ET1EzQno0UStSb21nRW4vZlpTaXIwZFh5ZmRlL1lSN0dKcHdyOUVPclVvdzFhVkxDVnZrbHM2T1o4Tk1NWEU9Cg==
        with:
          projectPath: ./.github/fixtures/example-with-tauri-v2
          includeDebug: true
          includeRelease: false
          tagName: ${{ !github.event.pull_request.head.repo.fork && 'example-arm-with-tauri-v__VERSION__' || '' }}
          releaseName: 'Release example with preconfigured Tauri app v__VERSION__ for tauri-v2 on ARM'
          releaseBody: 'See the assets to download this version and install.'
          releaseDraft: true
          args: ${{ matrix.args }}
          updaterJsonKeepUniversal: true
          retryAttempts: 1
          assetNamePattern: '[name]x[version]x[platform]x[arch]x[mode]x[setup]x[ext]'
          uploadPlainBinary: true
          generateReleaseNotes: true

      - name: Frontend-only Project
        uses: ./
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          # Updater signature is exposed here to make sure it works in PR's
          TAURI_SIGNING_PRIVATE_KEY: dW50cnVzdGVkIGNvbW1lbnQ6IHJzaWduIGVuY3J5cHRlZCBzZWNyZXQga2V5ClJXUlRZMEl5YTBGV3JiTy9lRDZVd3NkL0RoQ1htZmExNDd3RmJaNmRMT1ZGVjczWTBKZ0FBQkFBQUFBQUFBQUFBQUlBQUFBQWdMekUzVkE4K0tWQ1hjeGt1Vkx2QnRUR3pzQjVuV0ZpM2czWXNkRm9hVUxrVnB6TUN3K1NheHJMREhQbUVWVFZRK3NIL1VsMDBHNW5ET1EzQno0UStSb21nRW4vZlpTaXIwZFh5ZmRlL1lSN0dKcHdyOUVPclVvdzFhVkxDVnZrbHM2T1o4Tk1NWEU9Cg==
        with:
          projectPath: ./.github/fixtures/example-v2
          distPath: ../dist # relative to tauri.conf.json
          iconPath: ./icon.png # relative to projectPath
          bundleIdentifier: com.tauri.actiontest
          appName: example
          appVersion: ../package.json # relative to tauri.conf.json
          includeDebug: true
          includeRelease: false
          tagName: ${{ !github.event.pull_request.head.repo.fork && 'example-arm-v__VERSION__' || '' }}
          releaseName: 'Release example app v__VERSION__ for tauri-v2 on ARM'
          releaseBody: 'See the assets to download this version and install.'
          releaseDraft: true
          uploadPlainBinary: true
          generateReleaseNotes: true
          args: ${{ matrix.args }}
