diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cfa87166a..4a2457c31 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,10 +21,16 @@ jobs: python-version: '3.8' - name: Preprocess run: | - cd lib/server - wget -q ${{ secrets.SECRET_SALT }} - wget -q ${{ secrets.SECRET_WSALT }} - cd ../.. + # cd lib/server + # wget -q ${{ secrets.SECRET_SALT }} + # wget -q ${{ secrets.SECRET_WSALT }} + # cd ../.. + cat >> lib/server/salt.dart << EOF + String getValid(foo) {return foo;} + EOF + cat >> lib/server/wsalt.dart << EOF + String getValid(foo) {return foo;} + EOF python3 preprocess-ios.py - name: Podfile run: | @@ -48,6 +54,56 @@ jobs: name: ipa-build path: Payload.ipa + # https://github.com/AppImageCrafters/appimage-builder-flutter-example/blob/main/.github/workflows/appimage.yml + linux-build: + name: Build + runs-on: Ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - uses: subosito/flutter-action@v1 + # with: + # flutter-version: '1.22.4' + - run: flutter channel beta + - run: flutter upgrade + - run: flutter config --enable-linux-desktop + - name: "Install dependencies" + run: | + sudo apt-get update + sudo apt-get install -y cmake ninja-build build-essential pkg-config curl file git unzip xz-utils zip libgtk-3-dev + - name: Build flutter app + run: | + # cd lib/server + # wget -q ${{ secrets.SECRET_SALT }} + # wget -q ${{ secrets.SECRET_WSALT }} + # cd ../.. + python3 preprocess-linux.py + cat >> lib/server/salt.dart << EOF + String getValid(foo) {return foo;} + EOF + cat >> lib/server/wsalt.dart << EOF + String getValid(foo) {return foo;} + EOF + flutter build linux + - name: Build AppImage unsing appimage-builder + uses: docker://appimagecrafters/appimage-builder:0.8.5 + with: + entrypoint: appimage-builder + args: --recipe ./AppImageBuilder.yml --skip-test + - name: Save build Artifact + uses: actions/upload-artifact@v2 + with: + name: AppImage + path: './*.AppImage*' + - name: Release AppImage + uses: marvinpinto/action-automatic-releases@latest + with: + title: Continuous build + automatic_release_tag: 'continuous' + prerelease: true + draft: false + files: './*.AppImage*' + repo_token: ${{ secrets.GITHUB_TOKEN }} + android-build: runs-on: ubuntu-latest steps: @@ -66,10 +122,10 @@ jobs: python-version: '3.8' - name: Preprocess run: | - cd lib/server - wget -q ${{ secrets.SECRET_SALT }} - wget -q ${{ secrets.SECRET_WSALT }} - cd ../.. + # cd lib/server + # wget -q ${{ secrets.SECRET_SALT }} + # wget -q ${{ secrets.SECRET_WSALT }} + # cd ../.. python3 preprocess-android.py - name: Build run: | diff --git a/.gitignore b/.gitignore index 0efcc6c57..a4ae24dcc 100644 --- a/.gitignore +++ b/.gitignore @@ -31,6 +31,9 @@ migrate_working_dir/ .pub-cache/ .pub/ /build/ +/AppDir/ +*.AppImage +*.appimage # Web related lib/generated_plugin_registrant.dart @@ -62,4 +65,4 @@ emulator.bat img/* test/db test/*.7z -test/rawdata-korean \ No newline at end of file +test/rawdata-korean diff --git a/AppImageBuilder.yml b/AppImageBuilder.yml new file mode 100644 index 000000000..56b1b6877 --- /dev/null +++ b/AppImageBuilder.yml @@ -0,0 +1,73 @@ +# appimage-builder recipe see https://appimage-builder.readthedocs.io for details +version: 1 +script: + - rm -rf AppDir || true + - cp -r build/linux/x64/release/bundle AppDir + - mkdir -p AppDir/usr/share/icons/hicolor/64x64/apps/ + - cp assets/images/logo.png AppDir/usr/share/icons/hicolor/64x64/apps/ +AppDir: + path: ./AppDir + app_info: + id: org.appimagecrafters.hello-flutter + name: Hello Flutter + icon: logo + version: latest + exec: hello_flutter + exec_args: $@ + apt: + arch: amd64 + allow_unauthenticated: true + sources: + - sourceline: deb http://archive.ubuntu.com/ubuntu/ bionic main restricted + - sourceline: deb http://archive.ubuntu.com/ubuntu/ bionic-updates main restricted + - sourceline: deb http://archive.ubuntu.com/ubuntu/ bionic universe + - sourceline: deb http://archive.ubuntu.com/ubuntu/ bionic-updates universe + - sourceline: deb http://archive.ubuntu.com/ubuntu/ bionic multiverse + - sourceline: deb http://archive.ubuntu.com/ubuntu/ bionic-updates multiverse + - sourceline: deb http://archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse + - sourceline: deb http://security.ubuntu.com/ubuntu bionic-security main restricted + - sourceline: deb http://security.ubuntu.com/ubuntu bionic-security universe + - sourceline: deb http://security.ubuntu.com/ubuntu bionic-security multiverse + include: + - libgtk-3-0 + exclude: + - humanity-icon-theme + - hicolor-icon-theme + - adwaita-icon-theme + - ubuntu-mono + files: + exclude: + - usr/share/man + - usr/share/doc/*/README.* + - usr/share/doc/*/changelog.* + - usr/share/doc/*/NEWS.* + - usr/share/doc/*/TODO.* + runtime: + env: + GIO_MODULE_DIR: $APPDIR/usr/lib/x86_64-linux-gnu/gio/modules/ + test: + fedora: + image: appimagecrafters/tests-env:fedora-30 + command: ./AppRun + use_host_x: true + debian: + image: appimagecrafters/tests-env:debian-stable + command: ./AppRun + use_host_x: true + arch: + image: appimagecrafters/tests-env:archlinux-latest + command: ./AppRun + use_host_x: true + centos: + image: appimagecrafters/tests-env:centos-7 + command: ./AppRun + use_host_x: true + ubuntu: + image: appimagecrafters/tests-env:ubuntu-xenial + command: ./AppRun + use_host_x: true +AppImage: + arch: x86_64 + update-information: guess + sign-key: None + diff --git a/preprocess-ios.py b/preprocess-ios.py index 961247eae..8b29715ed 100644 --- a/preprocess-ios.py +++ b/preprocess-ios.py @@ -109,4 +109,4 @@ def create_dummy_valid(path): process_yaml(root + '/' + filename) # create_dummy_valid('./lib/server/salt.dart') -# create_dummy_valid('./lib/server/wsalt.dart') \ No newline at end of file +# create_dummy_valid('./lib/server/wsalt.dart') diff --git a/preprocess-linux.py b/preprocess-linux.py new file mode 100644 index 000000000..92d132722 --- /dev/null +++ b/preprocess-linux.py @@ -0,0 +1,112 @@ +# This source code is a part of Project Violet. +# Copyright (C) 2021.violet-team. Licensed under the Apache-2.0 License. + +import sys +import os +import os.path +import re + +target = 'linux' + +def process_dart(path): + f = open(path, 'r') + w = [] + nl = False + op = False + for line in f.readlines(): + if '//' in line: + annote = re.split(r': |, | ',line.split('//')[-1].strip()) + + if not annote[0].startswith('@dependent'): + if nl or op: + nl = False + else: + w.append(line) + continue + + if annote[1] == target: + w.append(line) + continue + + if len(annote) == 2: + continue + + if annote[2] == '=>': + nl = True + continue + + if annote[2] == '[': + op = True + continue + + if annote[2] == ']': + op = False + continue + else: + if nl or op: + nl = False + else: + w.append(line) + f.close() + f = open(path, 'w+') + f.writelines(w) + f.close() + +def process_yaml(path): + f = open(path, 'r') + w = [] + nl = False + op = False + for line in f.readlines(): + if '#' in line: + annote = re.split(r': |, | ', line.split('#')[-1].strip()) + + if not annote[0].startswith('@dependent'): + if nl or op: + nl = False + else: + w.append(line) + continue + + if annote[1] == target: + w.append(line) + continue + + if len(annote) == 2: + continue + + if annote[2] == '=>': + nl = True + continue + + if annote[2] == '[': + op = True + continue + + if annote[2] == ']': + op = False + continue + else: + if nl or op: + nl = False + else: + w.append(line) + f.close() + f = open(path, 'w+') + f.writelines(w) + f.close() + +def create_dummy_valid(path): + f = open(path, 'w') + f.writelines(['String getValid(foo) {return foo;}']) + f.close() + +for root, subdirs, files in os.walk('./'): + for filename in files: + if filename.endswith(".dart"): + process_dart(root + '/' + filename) + elif filename.endswith(".yaml"): + process_yaml(root + '/' + filename) + +# create_dummy_valid('./lib/server/salt.dart') +# create_dummy_valid('./lib/server/wsalt.dart')