Added linux to build script, linux compatibility improvements

This commit is contained in:
JHubi1 2024-08-20 17:54:46 +02:00
parent 33f656997c
commit 1f31d51e30
No known key found for this signature in database
GPG Key ID: 7BF82570CBBBD050
6 changed files with 139 additions and 36 deletions

View File

@ -12,6 +12,11 @@ on:
required: true
default: false
type: boolean
buildLinux:
description: Build for Linux
required: true
default: false
type: boolean
jobs:
analyze:
@ -52,15 +57,13 @@ jobs:
run: flutter build apk --obfuscate --split-debug-info=build/debugAndroid
- name: Preparing files
run: |
cp build/app/outputs/flutter-apk/app-release.apk build/app/outputs/flutter-apk/ollama.apk
cp build/app/outputs/flutter-apk/app-release.apk.sha1 build/app/outputs/flutter-apk/ollama.apk.sha1
cp build/app/outputs/flutter-apk/app-release.apk build/app/outputs/flutter-apk/ollama-android-v${{ steps.get_flutter_version.outputs.version_number }}.apk
- name: Uploading APK
uses: actions/upload-artifact@v4
with:
name: ollama-android
path: |
build/app/outputs/flutter-apk/ollama.apk
build/app/outputs/flutter-apk/ollama.apk.sha1
build/app/outputs/flutter-apk/ollama-android-v${{ steps.get_flutter_version.outputs.version_number }}.apk
build-windows-x64:
name: Building for Windows x64
if: ${{ github.event.inputs.buildWindowsX64 == 'true' }}
@ -88,12 +91,43 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: ollama-windows-x64
path: build\windows\x64\runner\ollama-v${{ steps.get_flutter_version.outputs.version_number }}-x64.exe
path: build\windows\x64\runner\ollama-windows-x64-v${{ steps.get_flutter_version.outputs.version_number }}.exe
build-linux:
name: Building for Linux
if: ${{ github.event.inputs.buildLinux == 'true' }}
runs-on: ubuntu-latest
needs: analyze
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
flutter-version: 3.22.1
- name: Get flutter version
id: get_flutter_version
uses: its404/get-flutter-version@v1.0.0
- name: Disabling flutter analytics
run: flutter config --no-analytics
- name: Installing linux dependencies
run: |
sudo apt-get install ninja-build
sudo apt-get install build-essential libgtk-3-dev
- name: Running build
id: compile
run: flutter build linux --obfuscate --split-debug-info=build/debugLinux
- name: Creating archive
run: |
cd build/linux/x64/release/bundle
tar -czf ollama-linux-x64-v${{ steps.get_flutter_version.outputs.version_number }}.tar.gz *
- name: Uploading archive
uses: actions/upload-artifact@v4
with:
name: ollama-linux-x64
path: build/linux/x64/release/bundle/ollama-linux-x64-v${{ steps.get_flutter_version.outputs.version_number }}.tar.gz
bundle:
name: Creating bundle
runs-on: ubuntu-latest
if: ${{ always() }}
needs: [build-android, build-windows-x64]
needs: [build-android, build-windows-x64, build-linux]
steps:
- name: Adding builds
uses: actions/download-artifact@v4
@ -105,4 +139,4 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: ollama
path: ./
path: ./

View File

@ -13,6 +13,7 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:bitsdojo_window/bitsdojo_window.dart';
import 'package:file_picker/file_picker.dart';
import 'package:file_selector/file_selector.dart' as file_selector;
import 'package:intl/intl.dart';
import 'package:dynamic_color/dynamic_color.dart';
@ -49,6 +50,7 @@ class _ScreenSettingsExportState extends State<ScreenSettingsExport> {
var content =
jsonEncode(prefs!.getStringList("chats") ?? []);
if (kIsWeb) {
// web fallback
final bytes = utf8.encode(content);
final blob = html.Blob([bytes]);
final url = html.Url.createObjectUrlFromBlob(blob);
@ -64,12 +66,22 @@ class _ScreenSettingsExportState extends State<ScreenSettingsExport> {
html.document.body!.children.remove(anchor);
html.Url.revokeObjectUrl(url);
} else {
var path = await FilePicker.platform.saveFile(
type: FileType.custom,
allowedExtensions: ["json"],
fileName: name,
bytes: utf8.encode(jsonEncode(
prefs!.getStringList("chats") ?? [])));
String? path = "";
try {
path = (await file_selector
.getSaveLocation(acceptedTypeGroups: [
const file_selector.XTypeGroup(
label: "Ollama App File", extensions: ["json"])
], suggestedName: name))
?.path;
} catch (_) {
path = await FilePicker.platform.saveFile(
type: FileType.custom,
allowedExtensions: ["json"],
fileName: name,
bytes: utf8.encode(jsonEncode(
prefs!.getStringList("chats") ?? [])));
}
selectionHaptic();
if (path == null) return;
if (desktopFeature()) {
@ -103,30 +115,54 @@ class _ScreenSettingsExportState extends State<ScreenSettingsExport> {
TextButton(
onPressed: () async {
selectionHaptic();
FilePickerResult? result =
await FilePicker.platform
.pickFiles(
type: FileType.custom,
allowedExtensions: [
"json"
]);
if (result == null) {
// ignore: use_build_context_synchronously
Navigator.of(context).pop();
return;
}
String content;
try {
File file = File(
result.files.single.path!);
if (kIsWeb) {
throw Exception(
"web must use file picker");
}
file_selector.XFile? result =
await file_selector.openFile(
acceptedTypeGroups: [
const file_selector
.XTypeGroup(
label:
"Ollama App File",
extensions: ["json"])
]);
if (result == null) {
// ignore: use_build_context_synchronously
Navigator.of(context).pop();
return;
}
content =
await file.readAsString();
await result.readAsString();
} catch (_) {
content = utf8.decode(result
.files
.single
.bytes as List<int>);
FilePickerResult? result =
await FilePicker.platform
.pickFiles(
type:
FileType.custom,
allowedExtensions: [
"json"
]);
if (result == null) {
// ignore: use_build_context_synchronously
Navigator.of(context).pop();
return;
}
try {
File file = File(result
.files.single.path!);
content =
await file.readAsString();
} catch (_) {
// web fallback
content = utf8.decode(result
.files
.single
.bytes as List<int>);
}
}
List<dynamic> tmpHistory =
jsonDecode(content);

View File

@ -225,6 +225,30 @@ packages:
url: "https://pub.dev"
source: hosted
version: "8.1.2"
file_selector:
dependency: "direct main"
description:
name: file_selector
sha256: "5019692b593455127794d5718304ff1ae15447dea286cdda9f0db2a796a1b828"
url: "https://pub.dev"
source: hosted
version: "1.0.3"
file_selector_android:
dependency: transitive
description:
name: file_selector_android
sha256: "77f23eb5916fd0875946720d1f286f809a28a867d4882db6ac2cf053e2d5f7c6"
url: "https://pub.dev"
source: hosted
version: "0.5.1+6"
file_selector_ios:
dependency: transitive
description:
name: file_selector_ios
sha256: "38ebf91ecbcfa89a9639a0854ccaed8ab370c75678938eebca7d34184296f0bb"
url: "https://pub.dev"
source: hosted
version: "0.5.3"
file_selector_linux:
dependency: transitive
description:
@ -249,6 +273,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.6.2"
file_selector_web:
dependency: transitive
description:
name: file_selector_web
sha256: c4c0ea4224d97a60a7067eca0c8fd419e708ff830e0c83b11a48faf566cec3e7
url: "https://pub.dev"
source: hosted
version: "0.9.4+2"
file_selector_windows:
dependency: transitive
description:

View File

@ -28,6 +28,7 @@ dependencies:
restart_app: ^1.2.1
flutter_markdown: ^0.7.1
file_picker: ^8.0.3
file_selector: ^1.0.3
bitsdojo_window: ^0.1.6
install_referrer: ^1.2.1
package_info_plus: ^8.0.0

View File

@ -1,7 +1,7 @@
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
; #define AppVersion "1.0.1"
;#define AppVersion "1.0.1"
#define AppName "Ollama App"
#define AppPublisher "JHubi1"
@ -27,7 +27,7 @@ UninstallDisplayName={#AppName}
DefaultDirName={autopf}\OllamaApp
OutputDir=build\windows\{#AppArchitectures}\runner
OutputBaseFilename=ollama-v{#AppVersion}-{#AppArchitectures}
OutputBaseFilename=ollama-windows-{#AppArchitectures}-v{#AppVersion}
AppSupportURL=https://github.com/JHubi1/ollama-app/issues
AppUpdatesURL=https://github.com/JHubi1/ollama-app/releases

View File

@ -28,7 +28,7 @@ UninstallDisplayName={#AppName}
DefaultDirName={autopf}\OllamaApp
OutputDir=build\windows\{#AppArchitectures}\runner
OutputBaseFilename=ollama-v{#AppVersion}-{#AppArchitectures}
OutputBaseFilename=ollama-windows-{#AppArchitectures}-v{#AppVersion}
AppSupportURL=https://github.com/JHubi1/ollama-app/issues
AppUpdatesURL=https://github.com/JHubi1/ollama-app/releases