From be75b50521d540326726daac193a3fc260c7f33f Mon Sep 17 00:00:00 2001 From: liwei Date: Wed, 2 Nov 2022 21:58:34 +0800 Subject: [PATCH] ci: build windows --- .github/workflows/release.yml | 109 ++++++++++++------ ui/flutter/.gitignore | 14 ++- ui/flutter/assets/icon/icon.ico | Bin 0 -> 4286 bytes .../lib/core/entry/libgopeed_boot_native.dart | 11 +- ui/flutter/pubspec.lock | 21 ++++ ui/flutter/pubspec.yaml | 9 ++ ui/flutter/windows/CMakeLists.txt | 3 + 7 files changed, 126 insertions(+), 41 deletions(-) create mode 100644 ui/flutter/assets/icon/icon.ico diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9de56c97..907002ad 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,39 +25,81 @@ jobs: id: create_release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -# build-cli: -# runs-on: ubuntu-latest -# needs: [ release ] -# steps: -# - uses: actions/checkout@v3 -# - uses: actions/setup-go@v3 -# with: -# go-version: '^1.19' -# cache: true -# - name: Build -# env: -# VERSION: ${{ needs.release.outputs.tag_name }} -# run: | -# mkdir -p dist/zip -# goos_arr=(windows darwin linux) -# goarch_arr=(386 amd64 arm64) -# export CGO_ENABLED=0 -# for goos in "${goos_arr[@]}"; do -# for goarch in "${goarch_arr[@]}"; do -# dir="dist/gopeed-$VERSION-$goos-$goarch/" -# (GOOS=$goos GOARCH=$goarch go build -tags nosqlite -ldflags="-s -w" -o $dir github.com/monkeyWie/gopeed/cmd/gopeed \ -# && cd $dir \ -# && zip -r ../zip/gopeed-cli-$VERSION-$goos-$goarch.zip * \ -# && cd ../..) \ -# || true -# done -# done -# - name: Upload -# uses: shogo82148/actions-upload-release-asset@v1 -# with: -# upload_url: ${{ needs.release.outputs.upload_url }} -# asset_path: dist/zip/* -# overwrite: true + build-windows: + runs-on: windows-latest + needs: [ release ] + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: '^1.19' + cache: true + - uses: subosito/flutter-action@v2 + - name: Build + env: + VERSION: ${{ needs.release.outputs.tag_name }} + run: | + go build -tags nosqlite -ldflags="-w -s" -buildmode=c-shared -o ui/flutter/windows/libgopeed.dll github.com/monkeyWie/gopeed/bind/desktop + cd ui/flutter + flutter build windows + cd build/windows + echo @" + ; Script generated by the Inno Setup Script Wizard. + ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! + + #define MyAppName "Gopeed" + #define MyAppVersion "$env:VERSION.substring(1)" + #define MyAppPublisher "monkeyWie" + #define MyAppURL "https://gopeed.com" + #define MyAppExeName "gopeed.exe" + + [Setup] + ; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications. + ; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) + AppId={{5960F34D-1E42-402C-8C85-DE2FF24CBAE4} + AppName={#MyAppName} + AppVersion={#MyAppVersion} + ;AppVerName={#MyAppName} {#MyAppVersion} + AppPublisher={#MyAppPublisher} + AppPublisherURL={#MyAppURL} + AppSupportURL={#MyAppURL} + AppUpdatesURL={#MyAppURL} + DefaultDirName={autopf}\gopeed + DisableProgramGroupPage=yes + LicenseFile=..\..\..\..\LICENSE + ; Remove the following line to run in administrative install mode (install for all users.) + PrivilegesRequired=lowest + OutputBaseFilename=gopeed + SetupIconFile=..\..\assets\icon\icon.ico + Compression=lzma + SolidCompression=yes + WizardStyle=modern + + [Languages] + Name: "english"; MessagesFile: "compiler:Default.isl" + + [Tasks] + Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked + + [Files] + Source: ".\runner\Release\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs + ; NOTE: Don't use "Flags: ignoreversion" on any shared system files + + [Icons] + Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}" + Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon + + [Run] + Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent + "@ > setup.iss + "%programfiles(x86)%\Inno Setup 6\iscc.exe" "setup.iss" + mv "Output\setup.exe" "gopeed-$env:VERSION-windows-amd64.exe" + - name: Upload + uses: shogo82148/actions-upload-release-asset@v1 + with: + upload_url: ${{ needs.release.outputs.upload_url }} + asset_path: ui/flutter/build/windows/Output/* + overwrite: true build-macos-arm64-lib: runs-on: ubuntu-latest needs: [ release ] @@ -114,7 +156,6 @@ jobs: PROJECT_DIR=$(pwd) cd ui/flutter - flutter config --enable-macos-desktop flutter build macos cd build/macos/Build/Products/Release cat>appdmg.json<r<3f7(b04nh9sRS>F=AbonppTbDneY1FI_1fvKRf|r3IF_20#Y^EC1G0`S$ zEXNd#%#4}=R&cp2i$J2lf*AJ&7FbwzpMJl?dzhEqciAw?b$*=lp6Bv=&U2pg?7J%U z5dNj4DE?JvA5-dSrPK=mmeflC*YyXoCz2MixRChoj=DFMg(oq-ysdUqQDxux%7{cf zBGN;IBVo^l-m?{yQ3s%|woA<5tYPdiZUlA#wcBeqPabVM7#R%?gLe66X!b8T;yn0eH4d+M9+mEz`oLS5K|0WUxw^p!9Uql57o zpbQ8Cl2Nxs4m9OT_f(gS&3W22*&**YW@{VTT0Tx;q|dl97#YUrfL{UHE}^uoSSox! zNLBxj;-4FjA?F%p6~6Cz4t9Ry<0||;3&g~LeCajFcwRBwSkwMcU$U$I9q|RaWB9p7 z8FiR1+Bo1UWI7Lzm#tqayl=XWs|&s5NjqI{m#tu{{pL2L$K|Iio;}xD7kTc?Q@1AC zA8`%+q4_WRzEjwYnq8PlyEafY2f0(+dW}Brho5#u&3oi>-+Ac`+zHNy=Tga8e&?jZ zo>h9y8_CFlcO*C@te-r0mg7F|m!JE-QMLm*(RG*QdP|x{>!oGPEt#&ZMqUFw_Q_X)N$$U8>;}(A_T9+P zb!_z!`J(-hoa;U#)XA*dDtjU48QH-#%A&b5ko!XPjLEpCTZ34RN)dy)qu45ga z%1mfl8b_|n;nw}AnZ3GZrb7V(_sejhh4fEGXFNCtib)`G{$$2ItN{7r&&lZWU3qZr6d-U<&Ko^9_88f#*sDu`DuDfh?+yg#{2rr>?~|slMZ1f6mg;r*C7@(M rsTYGvCHs|nv`49jtCd48uBCI`95N$$S^r+1LN literal 0 HcmV?d00001 diff --git a/ui/flutter/lib/core/entry/libgopeed_boot_native.dart b/ui/flutter/lib/core/entry/libgopeed_boot_native.dart index 287f53f7..22a2c284 100644 --- a/ui/flutter/lib/core/entry/libgopeed_boot_native.dart +++ b/ui/flutter/lib/core/entry/libgopeed_boot_native.dart @@ -70,14 +70,17 @@ class LibgopeedBootNative implements LibgopeedBoot { } _ffiInit() { + var libName = "libgopeed."; + if (Platform.isWindows) { + libName += "dll"; + } if (Platform.isMacOS) { - _libgopeed = - LibgopeedFFi(LibgopeedBind(DynamicLibrary.open('libgopeed.dylib'))); + libName += "dylib"; } if (Platform.isLinux) { - _libgopeed = - LibgopeedFFi(LibgopeedBind(DynamicLibrary.open('libgopeed.so'))); + libName += "so"; } + _libgopeed = LibgopeedFFi(LibgopeedBind(DynamicLibrary.open(libName))); } // FFI run in isolate diff --git a/ui/flutter/pubspec.lock b/ui/flutter/pubspec.lock index 869b271d..60e353d6 100644 --- a/ui/flutter/pubspec.lock +++ b/ui/flutter/pubspec.lock @@ -141,6 +141,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.16.0" + console: + dependency: transitive + description: + name: console + url: "https://pub.flutter-io.cn" + source: hosted + version: "4.1.0" context_menus: dependency: "direct main" description: @@ -326,6 +333,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "4.6.5" + get_it: + dependency: transitive + description: + name: get_it + url: "https://pub.flutter-io.cn" + source: hosted + version: "7.2.0" glob: dependency: transitive description: @@ -480,6 +494,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.0.2" + msix: + dependency: "direct dev" + description: + name: msix + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.7.0" package_config: dependency: transitive description: diff --git a/ui/flutter/pubspec.yaml b/ui/flutter/pubspec.yaml index d7e69e0a..0ce94b59 100644 --- a/ui/flutter/pubspec.yaml +++ b/ui/flutter/pubspec.yaml @@ -67,6 +67,7 @@ dev_dependencies: git: url: https://github.com/fluttercommunity/flutter_launcher_icons.git ref: v0.11.0 + msix: ^3.7.0 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec @@ -123,6 +124,14 @@ flutter_icons: generate: true image_path: "assets/icon/icon_macos_1024.png" +msix_config: + display_name: Gopeed + publisher_display_name: gopeed.com + identity_name: com.gopeed + logo_path: assets/icon/icon_1024.png + capabilities: privateNetworkClientServer + install_certificate: false + ffigen: name: LibgopeedBind description: Bindings to gopeed library. diff --git a/ui/flutter/windows/CMakeLists.txt b/ui/flutter/windows/CMakeLists.txt index 7d1c3bdc..40a60cc0 100644 --- a/ui/flutter/windows/CMakeLists.txt +++ b/ui/flutter/windows/CMakeLists.txt @@ -80,6 +80,9 @@ install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR} install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) +install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/libgopeed.dll" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" + COMPONENT Runtime) + if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}"