From 2c2ab097a351e13963d8e47f938fef9849d36f27 Mon Sep 17 00:00:00 2001
From: Kingtous <kingtouse@gmail.com>
Date: Fri, 21 Oct 2022 00:45:28 +0800
Subject: [PATCH 1/4] refactor: ci change to ubuntu 18.04

---
 .github/workflows/flutter-nightly.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.github/workflows/flutter-nightly.yml b/.github/workflows/flutter-nightly.yml
index 6a6fae7bc..5e677c4db 100644
--- a/.github/workflows/flutter-nightly.yml
+++ b/.github/workflows/flutter-nightly.yml
@@ -91,7 +91,7 @@ jobs:
           # - { target: i686-unknown-linux-gnu      , os: ubuntu-20.04, use-cross: true }
           # - { target: i686-unknown-linux-musl     , os: ubuntu-20.04, use-cross: true }
           # - { target: x86_64-apple-darwin         , os: macos-10.15                   }
-          - { target: x86_64-unknown-linux-gnu    , os: ubuntu-20.04 }
+          - { target: x86_64-unknown-linux-gnu    , os: ubuntu-18.04 }
           # - { target: x86_64-unknown-linux-musl   , os: ubuntu-20.04, use-cross: true }
     steps:
       - name: Checkout source code

From 1e86f96827c12fe2e7d4df1512be050b5049ccc7 Mon Sep 17 00:00:00 2001
From: Kingtous <kingtous@qq.com>
Date: Fri, 21 Oct 2022 08:39:37 +0800
Subject: [PATCH 2/4] refactor: remove flutter_rust_bridge compilation speedup
 workaround

chagne crontab to 0:00
---
 .github/workflows/flutter-nightly.yml | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/.github/workflows/flutter-nightly.yml b/.github/workflows/flutter-nightly.yml
index 5e677c4db..692bfcfb7 100644
--- a/.github/workflows/flutter-nightly.yml
+++ b/.github/workflows/flutter-nightly.yml
@@ -2,7 +2,8 @@ name: Flutter Nightly Build
 
 on:
   schedule:
-    - cron: "* 0 * * *"
+    # schedule build every night
+    - cron: "0 0 * * *"
   workflow_dispatch:
 
 jobs:
@@ -46,13 +47,10 @@ jobs:
         run: |
           dart pub global activate ffigen --version 5.0.1
           $exists = Test-Path ~/.cargo/bin/flutter_rust_bridge_codegen.exe
-          If ( ! $exists -eq $True )
-          {
-            Push-Location ..
-            git clone https://github.com/SoLongAndThanksForAllThePizza/flutter_rust_bridge --depth=1
-            Push-Location flutter_rust_bridge/frb_codegen ; cargo install --path . ; Pop-Location
-            Pop-Location
-          }
+          Push-Location ..
+          git clone https://github.com/SoLongAndThanksForAllThePizza/flutter_rust_bridge --depth=1
+          Push-Location flutter_rust_bridge/frb_codegen ; cargo install --path . ; Pop-Location
+          Pop-Location
           Push-Location flutter ; flutter pub get ; Pop-Location
           ~/.cargo/bin/flutter_rust_bridge_codegen --rust-input ./src/flutter_ffi.rs --dart-output ./flutter/lib/generated_bridge.dart
 
@@ -126,10 +124,8 @@ jobs:
         run: |
           dart pub global activate ffigen --version 5.0.1
           # flutter_rust_bridge
-          if [[ ! -e $HOME/.cargo/bin/flutter_rust_bridge_codegen ]]; then
-            pushd /tmp && git clone https://github.com/SoLongAndThanksForAllThePizza/flutter_rust_bridge --depth=1 && popd
-            pushd /tmp/flutter_rust_bridge/frb_codegen && cargo install --path . && popd
-          fi
+          pushd /tmp && git clone https://github.com/SoLongAndThanksForAllThePizza/flutter_rust_bridge --depth=1 && popd
+          pushd /tmp/flutter_rust_bridge/frb_codegen && cargo install --path . && popd
           pushd flutter && flutter pub get && popd
           ~/.cargo/bin/flutter_rust_bridge_codegen --rust-input ./src/flutter_ffi.rs --dart-output ./flutter/lib/generated_bridge.dart
 

From 3818a0ddd05f6a1449058ce8aa9b9bb99f7c7dab Mon Sep 17 00:00:00 2001
From: Kingtous <kingtous@qq.com>
Date: Fri, 21 Oct 2022 08:41:57 +0800
Subject: [PATCH 3/4] feat: add hwcodec

---
 .github/workflows/flutter-nightly.yml | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/.github/workflows/flutter-nightly.yml b/.github/workflows/flutter-nightly.yml
index 692bfcfb7..f9a7e4fb2 100644
--- a/.github/workflows/flutter-nightly.yml
+++ b/.github/workflows/flutter-nightly.yml
@@ -66,7 +66,7 @@ jobs:
         shell: bash
 
       - name: Build rustdesk
-        run: python3 .\build.py --portable
+        run: python3 .\build.py --portable --hwcodec
 
       - name: Publish Release
         uses: softprops/action-gh-release@v1
@@ -98,7 +98,7 @@ jobs:
       - name: Install prerequisites
         run: |
           case ${{ matrix.job.target }} in
-            x86_64-unknown-linux-gnu) sudo apt-get -y update ; sudo apt install -y g++ gcc git curl wget nasm yasm libgtk-3-dev clang libxcb-randr0-dev libxdo-dev libxfixes-dev libxcb-shape0-dev libxcb-xfixes0-dev libasound2-dev libpulse-dev cmake libclang-dev ninja-build libayatana-appindicator3-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev;;
+            x86_64-unknown-linux-gnu) sudo apt-get -y update ; sudo apt install -y g++ gcc git curl wget nasm yasm libgtk-3-dev clang libxcb-randr0-dev libxdo-dev libxfixes-dev libxcb-shape0-dev libxcb-xfixes0-dev libasound2-dev libpulse-dev cmake libclang-dev ninja-build libayatana-appindicator3-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libvdpau-dev libva-dev;;
             # arm-unknown-linux-*) sudo apt-get -y update ; sudo apt-get -y install gcc-arm-linux-gnueabihf ;;
             # aarch64-unknown-linux-gnu) sudo apt-get -y update ; sudo apt-get -y install gcc-aarch64-linux-gnu ;;
           esac
@@ -155,7 +155,7 @@ jobs:
           rustc -V
 
       - name: Build rustdesk
-        run: ./build.py --flutter
+        run: ./build.py --flutter --hwcodec
 
       - name: Publish Release
         uses: softprops/action-gh-release@v1

From f0f3a2027cb9c96398f7641dd0b20dc6fb1559d2 Mon Sep 17 00:00:00 2001
From: Kingtous <kingtous@qq.com>
Date: Fri, 21 Oct 2022 08:51:20 +0800
Subject: [PATCH 4/4] opt: ci

opt: use force to prevent reuse newer bundle tools
---
 .github/workflows/flutter-nightly.yml | 51 +++++++++++++++++++--------
 build.py                              |  2 +-
 flutter/pubspec.yaml                  |  2 +-
 3 files changed, 39 insertions(+), 16 deletions(-)

diff --git a/.github/workflows/flutter-nightly.yml b/.github/workflows/flutter-nightly.yml
index f9a7e4fb2..5374ec72d 100644
--- a/.github/workflows/flutter-nightly.yml
+++ b/.github/workflows/flutter-nightly.yml
@@ -6,6 +6,12 @@ on:
     - cron: "0 0 * * *"
   workflow_dispatch:
 
+env:
+  LLVM_VERSION: "10.0"
+  FLUTTER_VERSION: "3.0.5"
+  TAG_NAME: "nightly"
+  VCPKG_COMMIT_ID: '6ca56aeb457f033d344a7106cb3f9f1abf8f4e98'
+
 jobs:
   build-for-windows:
     name: ${{ matrix.job.target }} (${{ matrix.job.os }})
@@ -22,16 +28,15 @@ jobs:
         uses: actions/checkout@v3
 
       - name: Install LLVM and Clang
-        if: startsWith(matrix.job.os, 'windows')
         uses: KyleMayes/install-llvm-action@v1
         with:
-          version: "13.0"
+          version: ${{ env.LLVM_VERSION }}
 
       - name: Install flutter
         uses: subosito/flutter-action@v2
         with:
           channel: 'stable'
-          flutter-version: '3.0.5'
+          flutter-version: ${{ env.FLUTTER_VERSION }}
 
       - name: Install Rust toolchain
         uses: actions-rs/toolchain@v1
@@ -41,7 +46,9 @@ jobs:
           override: true
           profile: minimal # minimal component installation (ie, no documentation)
 
-      - uses: Swatinem/rust-cache@v1
+      - uses: Swatinem/rust-cache@v2
+        with:
+          prefix-key: ${{ matrix.job.os }}
 
       - name: Install flutter rust bridge deps
         run: |
@@ -58,7 +65,7 @@ jobs:
         uses: lukka/run-vcpkg@v7
         with:
           setupOnly: true
-          vcpkgGitCommitId: '6ca56aeb457f033d344a7106cb3f9f1abf8f4e98'
+          vcpkgGitCommitId: ${{ env.VCPKG_COMMIT_ID }}
 
       - name: Install vcpkg dependencies
         run: |
@@ -66,13 +73,20 @@ jobs:
         shell: bash
 
       - name: Build rustdesk
-        run: python3 .\build.py --portable --hwcodec
+        run: python3 .\build.py --portable --hwcodec --flutter
+
+      - name: Rename rustdesk
+        shell: bash
+        run: |
+          for name in rustdesk*??.exe; do
+              mv "$name" "${name%%.exe}-${{ matrix.job.target }}.exe"
+          done
 
       - name: Publish Release
         uses: softprops/action-gh-release@v1
         with:
           prerelease: true
-          tag_name: "nightly"
+          tag_name: ${{ env.TAG_NAME }}
           files: |
             rustdesk-*.exe
 
@@ -98,7 +112,7 @@ jobs:
       - name: Install prerequisites
         run: |
           case ${{ matrix.job.target }} in
-            x86_64-unknown-linux-gnu) sudo apt-get -y update ; sudo apt install -y g++ gcc git curl wget nasm yasm libgtk-3-dev clang libxcb-randr0-dev libxdo-dev libxfixes-dev libxcb-shape0-dev libxcb-xfixes0-dev libasound2-dev libpulse-dev cmake libclang-dev ninja-build libayatana-appindicator3-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libvdpau-dev libva-dev;;
+            x86_64-unknown-linux-gnu) sudo apt-get -y update ; sudo apt install -y g++ gcc git curl wget nasm yasm libgtk-3-dev clang libxcb-randr0-dev libxdo-dev libxfixes-dev libxcb-shape0-dev libxcb-xfixes0-dev libasound2-dev libpulse-dev cmake libclang-dev ninja-build libayatana-appindicator3-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libvdpau-dev libva-dev libclang-dev llvm-dev libclang-10-dev llvm-10-dev;;
             # arm-unknown-linux-*) sudo apt-get -y update ; sudo apt-get -y install gcc-arm-linux-gnueabihf ;;
             # aarch64-unknown-linux-gnu) sudo apt-get -y update ; sudo apt-get -y install gcc-aarch64-linux-gnu ;;
           esac
@@ -107,7 +121,7 @@ jobs:
         uses: subosito/flutter-action@v2
         with:
           channel: 'stable'
-          flutter-version: '3.0.5'
+          flutter-version: ${{ env.FLUTTER_VERSION }}
 
       - name: Install Rust toolchain
         uses: actions-rs/toolchain@v1
@@ -117,7 +131,9 @@ jobs:
           override: true
           profile: minimal # minimal component installation (ie, no documentation)
 
-      - uses: Swatinem/rust-cache@v1
+      - uses: Swatinem/rust-cache@v2
+        with:
+          prefix-key: ${{ matrix.job.os }}
 
       - name: Install flutter rust bridge deps
         shell: bash
@@ -133,7 +149,7 @@ jobs:
         uses: lukka/run-vcpkg@v7
         with:
           setupOnly: true
-          vcpkgGitCommitId: '6ca56aeb457f033d344a7106cb3f9f1abf8f4e98'
+          vcpkgGitCommitId: ${{ env.VCPKG_COMMIT_ID }}
 
       - name: Install vcpkg dependencies
         run: |
@@ -142,7 +158,7 @@ jobs:
 
       - name: Install cargo bundle tools
         run: |
-          cargo install cargo-bundle
+          cargo install cargo-bundle --force
 
       - name: Show version information (Rust, cargo, GCC)
         shell: bash
@@ -157,11 +173,18 @@ jobs:
       - name: Build rustdesk
         run: ./build.py --flutter --hwcodec
 
+      - name: Rename rustdesk
+        shell: bash
+        run: |
+          for name in rustdesk*??.deb; do
+              mv "$name" "${name%%.deb}-${{ matrix.job.target }}-${{ matrix.job.os }}.deb"
+          done
+
       - name: Publish Release
         uses: softprops/action-gh-release@v1
         with:
           prerelease: true
-          tag_name: "nightly"
+          tag_name: ${{ env.TAG_NAME }}
           files: |
-            rustdesk-*.deb
+            rustdesk*.deb
 
diff --git a/build.py b/build.py
index e7deb52ba..403154d85 100755
--- a/build.py
+++ b/build.py
@@ -204,7 +204,7 @@ def build_flutter_windows(version):
     else:
         os.rename("./target/release/rustdesk-portable-packer.exe", "./rustdesk_portable.exe")
     print(f"output location: {os.path.abspath(os.curdir)}/rustdesk_portable.exe")
-    os.system(f"cp -rf ./rustdesk_portable.exe ./rustdesk-{version}-install.exe")
+    os.rename("./rustdesk_portable.exe", f"./rustdesk-{version}-install.exe")
     print(f"output location: {os.path.abspath(os.curdir)}/rustdesk-{version}-install.exe")
 
 def main():
diff --git a/flutter/pubspec.yaml b/flutter/pubspec.yaml
index 6d2cb31b7..f77fe9894 100644
--- a/flutter/pubspec.yaml
+++ b/flutter/pubspec.yaml
@@ -97,7 +97,7 @@ dependencies:
         #     ref: 62f09545149f320616467c306c8c5f71714a18e6
     uni_links: ^0.5.1
     uni_links_desktop: ^0.1.3
-    path: ^1.8.2
+    path: ^1.8.1
 
 dev_dependencies:
     icons_launcher: ^2.0.4