Skip to content

Commit

Permalink
Merge pull request #11
Browse files Browse the repository at this point in the history
Add Linux AppImage build to workflow, update packages and replace file_selector and lints with their successors, Fix Lint warnings
  • Loading branch information
Hexer10 authored Sep 1, 2021
2 parents 66c84ac + e8e5472 commit bed04f0
Show file tree
Hide file tree
Showing 24 changed files with 215 additions and 296 deletions.
97 changes: 61 additions & 36 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,48 +18,73 @@ jobs:
runs-on: windows-2019

steps:

- name: Checkout
uses: actions/checkout@v2

- name: Setup java
uses: actions/setup-java@v1
with:
java-version: '12.x'

- name: Setup flutter
uses: subosito/flutter-action@v1

- name: Enable desktop support
run: flutter config --enable-windows-desktop
- name: Checkout
uses: actions/checkout@v2

- name: Doctor
run: flutter doctor -v
- name: Setup java
uses: actions/setup-java@v1
with:
java-version: '12.x'

- name: Setup flutter
uses: subosito/flutter-action@master

- name: Enable desktop support
run: flutter config --enable-windows-desktop

- name: Doctor
run: flutter doctor -v

- name: Get dependencies
run: flutter pub get

- name: Get dependencies
run: flutter pub get

- name: Build windows
run: flutter build windows
- name: Build windows
run: flutter build windows

- name: Build apk
run: flutter build apk

- name: Upload apk artifacts
uses: actions/upload-artifact@v1
with:
name: Youtube Downloader.apk
path: ./build/app/outputs/flutter-apk/app-release.apk

- name: Compress Windows App
run: .\tool\compress.ps1
shell: powershell


- name: Upload windows zip artifacts
uses: actions/upload-artifact@v1
with:
name: Youtube Downloader - Windows.zip
path: Youtube Downloader.zip

build-appimage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Setup flutter
uses: subosito/flutter-action@master

- name: Build apk
run: flutter build apk
- name: Install dependencies
run: sudo apt-get update -y && sudo apt-get install -y ninja-build libgtk-3-dev

- name: Upload apk artifacts
uses: actions/upload-artifact@v1
with:
name: Youtube Downloader.apk
path: ./build/app/outputs/flutter-apk/app-release.apk
- name: Enable desktop support
run: flutter config --enable-linux-desktop

- name: Compress Windows App
run: .\tool\compress.ps1
shell: powershell
- name: Build Flutter app
run: flutter build linux

- name: Build AppImage
run: ./create_appimage.sh

- name: Upload windows zip artifacts
uses: actions/upload-artifact@v1
with:
name: Youtube Downloader - Windows.zip
path: Youtube Downloader.zip
- name: Upload linux appimage to artifacts
uses: actions/upload-artifact@v1
with:
name: Youtube Downloader - Linux.AppImage
path: youtube_downloader_flutter-x86_64.AppImage


2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
.buildlog/
.history
.svn/
AppDir/
*.AppImage

# IntelliJ related
*.iml
Expand Down
2 changes: 1 addition & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include: package:lint/analysis_options.yaml
include: package:flutter_lints/flutter.yaml
10 changes: 0 additions & 10 deletions bin/test.dart

This file was deleted.

42 changes: 42 additions & 0 deletions create_appimage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/sh

# Create Application Directory
mkdir -p AppDir

# Create AppRun file(required by AppImage)
echo '#!/bin/sh
cd "$(dirname "$0")"
exec ./youtube_downloader_flutter' > AppDir/AppRun
sudo chmod +x AppDir/AppRun

# Copy All build files to AppDir
cp -r build/linux/x64/release/bundle/* AppDir

## Add Application metadata
# Copy app icon
sudo mkdir -p AppDir/usr/share/icons/hicolor/256x256/apps/
cp android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png AppDir/youtube_downloader_flutter.png
sudo cp AppDir/youtube_downloader_flutter.png AppDir/usr/share/icons/hicolor/256x256/apps/youtube_downloader_flutter.png

sudo mkdir -p AppDir/usr/share/applications

# Either copy .desktop file content from file or with echo command
# cp assets/youtube_downloader_flutter.desktop AppDir/youtube_downloader_flutter.desktop

echo '[Desktop Entry]
Version=1.0
Type=Application
Name=Youtube downloader flutter
Icon=youtube_downloader_flutter
Exec=youtube_downloader_flutter %u
StartupWMClass=youtube_downloader_flutter
Categories=Utility;' > AppDir/youtube_downloader_flutter.desktop

# Also copy the same .desktop file to usr folder
sudo cp AppDir/youtube_downloader_flutter.desktop AppDir/usr/share/applications/youtube_downloader_flutter.desktop

## Start build
test ! -e appimagetool-x86_64.AppImage && curl -L https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage -o appimagetool-x86_64.AppImage
sudo chmod +x appimagetool-x86_64.AppImage
ARCH=x86_64 ./appimagetool-x86_64.AppImage AppDir/ youtube_downloader_flutter-x86_64.AppImage
14 changes: 9 additions & 5 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,17 @@ void main() {
SetProcessDpiAwareness(1);
}
}
runApp(MyApp());
runApp(const MyApp());
}

class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return ProviderScope(
observers: [MainObserver()],
child: AppInit(),
child: const AppInit(),
);
}
}
Expand All @@ -40,24 +42,26 @@ class MainObserver implements ProviderObserver {
@override
void didAddProvider(
ProviderBase provider, Object? value, ProviderContainer container) {
print('Added: $provider : $value(${value.runtimeType})');
debugPrint('Added: $provider : $value(${value.runtimeType})');
}

@override
void didDisposeProvider(ProviderBase provider, ProviderContainer container) {
print('Disposed: $provider');
debugPrint('Disposed: $provider');
}

@override
void didUpdateProvider(ProviderBase provider, Object? previousValue,
Object? newValue, ProviderContainer container) {
print('Update: $provider : $newValue');
debugPrint('Update: $provider : $newValue');
}
}

class AppInit extends HookConsumerWidget {
static final scaffoldKey = GlobalKey<ScaffoldMessengerState>();

const AppInit({Key? key}) : super(key: key);

@override
Widget build(BuildContext context, WidgetRef ref) {
final fetched = useState<bool>(false);
Expand Down
126 changes: 0 additions & 126 deletions lib/src/components/linux_folderpicker.dart

This file was deleted.

4 changes: 2 additions & 2 deletions lib/src/models/download_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ class DownloadManagerImpl extends ChangeNotifier implements DownloadManager {

process.stdout.listen((event) {
final data = utf8.decode(event);
print('OUT: $data');
debugPrint('OUT: $data');

final timeStr = RegExp(r'out_time_ms=(\d+)').firstMatch(data)?.group(1);
if (timeStr == null) {
Expand Down Expand Up @@ -578,7 +578,7 @@ class SingleTrack extends ChangeNotifier {

void cancelDownload() {
if (_cancelCallback == null) {
print('Tried to cancel an uncancellable video');
debugPrint('Tried to cancel an uncancellable video');
return;
}
_cancelCallback!();
Expand Down
2 changes: 1 addition & 1 deletion lib/src/search_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import 'package:youtube_downloader_flutter/src/widgets/search_view/search_result
import 'widgets/search_view/suggestion_list.dart';

class SearchBar extends HookWidget {
const SearchBar();
const SearchBar({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
Expand Down
4 changes: 2 additions & 2 deletions lib/src/services/search_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ abstract class SearchService extends ChangeNotifier {
factory SearchService(YoutubeExplode yt, String query) {
final cid = ChannelId.parseChannelId(query);
if (cid != null) {
print('Channel!');
debugPrint('Channel!');
return _ChannelSearchServiceImpl(yt, cid);
}
print('Video!');
debugPrint('Video!');
return _VideoSearchServiceImpl(yt, query);
}
}
Expand Down
Loading

0 comments on commit bed04f0

Please sign in to comment.