Modify release script to use python script based build

Signed-off-by: trivernis <trivernis@protonmail.com>
pull/15/head
trivernis 3 years ago
parent 3b38f1a8c6
commit 0d85ac6009
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -31,10 +31,6 @@ jobs:
matrix: matrix:
os: [ubuntu-latest, macos-latest, windows-latest] os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
working-directory: mediarepo-daemon
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
if: ${{ !env.ACT }} if: ${{ !env.ACT }}
@ -50,12 +46,17 @@ jobs:
restore-keys: | restore-keys: |
${{ runner.os }}-cargo- ${{ runner.os }}-cargo-
- name: setup python
uses: actions/setup-python@v2
with:
python-version: '^3.7'
- name: Build Daemon - name: Build Daemon
run: cargo build --release --no-default-features --verbose run: python build.py build --daemon --verbose
- uses: vimtor/action-zip@v1 - uses: vimtor/action-zip@v1
with: with:
files: mediarepo-daemon/target/release/mediarepo-daemon mediarepo-daemon/target/release/mediarepo-daemon.exe files: out/
dest: mediarepo-daemon-${{ runner.os }}.zip dest: mediarepo-daemon-${{ runner.os }}.zip
- name: Upload Release Asset - name: Upload Release Asset
@ -76,10 +77,6 @@ jobs:
matrix: matrix:
os: [ubuntu-latest, macos-latest, windows-latest] os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
working-directory: mediarepo-ui
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
if: ${{ !env.ACT }} if: ${{ !env.ACT }}
@ -99,23 +96,16 @@ jobs:
${{ runner.os }}-release-dependencies- ${{ runner.os }}-release-dependencies-
${{ runner.os }}-dependencies- ${{ runner.os }}-dependencies-
- name: setup python
uses: actions/setup-python@v2
with:
python-version: '^3.7'
- name: Use Node.js 16 - name: Use Node.js 16
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: 16 node-version: 16
- name: Install Tauri
run: cargo install tauri-cli --git https://github.com/tauri-apps/tauri
- name: Install Angular CLI
run: npm install -g @angular/cli
- name: Install yarn
run: npm install -g yarn
- name: Install dependencies
run: yarn install
- name: Install OS-specific dependencies - name: Install OS-specific dependencies
uses: knicknic/os-specific-run@v1.0.3 uses: knicknic/os-specific-run@v1.0.3
with: with:
@ -124,11 +114,11 @@ jobs:
DEBIAN_FRONTEND=noninteractive sudo apt-get install libwebkit2gtk-4.0-dev libgtk-3-dev libappindicator3-dev -y DEBIAN_FRONTEND=noninteractive sudo apt-get install libwebkit2gtk-4.0-dev libgtk-3-dev libappindicator3-dev -y
- name: Build project - name: Build project
run: cargo tauri build --verbose run: python build.py build --ui --verbose
- uses: vimtor/action-zip@v1 - uses: vimtor/action-zip@v1
with: with:
files: mediarepo-ui/src-tauri/target/release/bundle mediarepo-ui/src-tauri/target/release/mediarepo-ui mediarepo-ui/src-tauri/target/release/mediarepo-ui.exe files: out/
dest: mediarepo-ui-${{ runner.os }}.zip dest: mediarepo-ui-${{ runner.os }}.zip
- name: Upload Release Asset - name: Upload Release Asset

@ -69,21 +69,21 @@ You also need to have a working [python](https://www.python.org/) installation o
After all required dependencies are installed and tools are accessible in the `PATH`, you can build the project like follows: After all required dependencies are installed and tools are accessible in the `PATH`, you can build the project like follows:
> Note: On some systems you need to use the `python3` command instead of `python`. > Note: You might need to make the `build.py` file executable with `chmod +x build.py`.
All Componens: All Componens:
```sh ```sh
$ python build.py build $ ./build.py build
``` ```
Daemon only: Daemon only:
```sh ```sh
$ python build.py build --daemon $ ./build.py build --daemon
``` ```
UI only: UI only:
```sh ```sh
$ python build.py build --ui $ ./build.py build --ui
``` ```
After building the `out` directory contains all the built binaries and bundles. After building the `out` directory contains all the built binaries and bundles.

@ -1,11 +1,24 @@
#!/bin/env python3
import shutil as shut import shutil as shut
import os import os
import subprocess
tauri_cli_version = '1.0.0-rc.5'
build_output = 'out' build_output = 'out'
verbose = False
windows = os.name == 'nt'
def exec(cmd: str, dir: str = None) -> str:
print('Running: {}'.format(cmd))
child = subprocess.run(cmd, shell=True, cwd=dir)
child.check_returncode()
def check_exec(name: str): def check_exec(name: str):
print('Checking {}...'.format(name)) print('Checking {}...'.format(name))
if shut.which(name) is None: if shut.which(name) is None:
raise Exception('{} not found'.format(name)) raise Exception('{} not found'.format(name))
exec(name + ' --version') exec(name + ' --version')
@ -13,63 +26,68 @@ def check_exec(name: str):
def check_yarn(): def check_yarn():
print('Checking yarn...') print('Checking yarn...')
if shut.which('yarn') is None: if shut.which('yarn') is None:
print('installing yarn...') print('installing yarn...')
exec('npm install -g yarn') npm('install -g yarn')
check_exec('yarn') check_exec('yarn')
exec('yarn --version') exec('yarn --version')
def check_ng(): def check_ng():
print('Checking ng...') print('Checking ng...')
if shut.which('ng') is None: if shut.which('ng') is None:
print('installing ng...') print('installing ng...')
exec('npm install -g @angular/cli') npm('install -g @angular/cli')
check_exec('ng') check_exec('ng')
exec('ng --version') exec('ng --version')
def exec(cmd: str, dir: str = None) -> str:
import subprocess
child = subprocess.run(cmd, shell=True, cwd=dir)
child.check_returncode()
def store_artifact(path: str): def store_artifact(path: str):
print('Storing {}'.format(path)) print('Storing {}'.format(path))
if os.path.isdir(path): if os.path.isdir(path):
shut.copytree(path, os.path.join(build_output, os.path.basename(path)), dirs_exist_ok=True) shut.copytree(path, os.path.join(
build_output, os.path.basename(path)), dirs_exist_ok=True)
else: else:
shut.copy(path, build_output) shut.copy(path, build_output)
def cargo(cmd: str, dir: str = None) -> str: def cargo(cmd: str, dir: str = None):
print('cargo {}'.format(cmd)) if verbose:
exec('cargo {}'.format(cmd), dir) exec('cargo {} --verbose'.format(cmd), dir)
else:
exec('cargo {}'.format(cmd), dir)
def npm(cmd: str, dir: str = None):
exec('npm {}'.format(cmd), dir)
def yarn(cmd: str, dir: str = None): def yarn(cmd: str, dir: str = None):
print('yarn {}'.format(cmd))
exec('yarn {}'.format(cmd), dir) exec('yarn {}'.format(cmd), dir)
def build_daemon(): def build_daemon():
'''Builds daemon'''
cargo('fetch', 'mediarepo-daemon') cargo('fetch', 'mediarepo-daemon')
cargo('build --release --frozen --verbose', 'mediarepo-daemon') cargo('build --release --frozen', 'mediarepo-daemon')
if os.name == 'nt': if windows:
store_artifact('mediarepo-daemon/target/release/mediarepo-daemon.exe') store_artifact('mediarepo-daemon/target/release/mediarepo-daemon.exe')
else: else:
store_artifact('mediarepo-daemon/target/release/mediarepo-daemon') store_artifact('mediarepo-daemon/target/release/mediarepo-daemon')
def build_ui(): def build_ui():
cargo('install tauri-cli --version ^1.0.0-rc.4') '''Builds UI'''
cargo('install tauri-cli --version ^{}'.format(tauri_cli_version))
yarn('install', 'mediarepo-ui') yarn('install', 'mediarepo-ui')
cargo('tauri build --verbose', 'mediarepo-ui') cargo('tauri build', 'mediarepo-ui')
if os.name == 'nt': if windows:
store_artifact('mediarepo-ui/src-tauri/target/release/mediarepo-ui.exe') store_artifact(
'mediarepo-ui/src-tauri/target/release/mediarepo-ui.exe')
else: else:
store_artifact('mediarepo-ui/src-tauri/target/release/mediarepo-ui') store_artifact('mediarepo-ui/src-tauri/target/release/mediarepo-ui')
@ -77,11 +95,13 @@ def build_ui():
def check_daemon(): def check_daemon():
'''Checks dependencies for daemon'''
check_exec('clang') check_exec('clang')
check_exec('cargo') check_exec('cargo')
def check_ui(): def check_ui():
'''Checks dependencies for UI'''
check_exec('clang') check_exec('clang')
check_exec('cargo') check_exec('cargo')
check_exec('wget') check_exec('wget')
@ -92,35 +112,40 @@ def check_ui():
check_yarn() check_yarn()
check_ng() check_ng()
def check(): def check():
'''Checks dependencies'''
check_daemon() check_daemon()
check_ui() check_ui()
print('All checks passed') print('All checks passed')
def create_output_dir(): def create_output_dir():
'''Creates build output directory'''
if not os.path.exists(build_output): if not os.path.exists(build_output):
os.mkdir(build_output) os.mkdir(build_output)
def clean(): def clean():
'''Removes build output'''
if os.path.exists(build_output): if os.path.exists(build_output):
shut.rmtree(build_output) shut.rmtree(build_output)
print('Cleaned') print('Cleaned')
def build(daemon=True, ui=True): def build(daemon=True, ui=True):
'''Builds both daemon and UI'''
clean() clean()
create_output_dir() create_output_dir()
if daemon: if daemon:
check_daemon() check_daemon()
build_daemon() build_daemon()
if ui: if ui:
check_ui() check_ui()
build_ui() build_ui()
print('Build complete') print('Build complete')
@ -129,13 +154,18 @@ def parse_args():
parser = argparse.ArgumentParser(description='Build mediarepo') parser = argparse.ArgumentParser(description='Build mediarepo')
subparsers = parser.add_subparsers(dest='command') subparsers = parser.add_subparsers(dest='command')
subparsers.required = True subparsers.required = True
subparsers.add_parser('check') subparsers.add_parser('check')
build_parser = subparsers.add_parser('build') build_parser = subparsers.add_parser('build')
build_parser.add_argument('--daemon', action='store_true', help='Build daemon') build_parser.add_argument(
'--daemon', action='store_true', help='Build daemon')
build_parser.add_argument('--ui', action='store_true', help='Build UI') build_parser.add_argument('--ui', action='store_true', help='Build UI')
build_parser.add_argument(
'--verbose', action='store_true', help='Verbose build')
build_parser.add_argument(
'--output', action='store', help='Build output directory')
subparsers.add_parser('clean') subparsers.add_parser('clean')
args = parser.parse_args() args = parser.parse_args()
return args return args
@ -143,9 +173,14 @@ def parse_args():
def main(): def main():
opts = parse_args() opts = parse_args()
print(opts)
if opts.command == 'build': if opts.command == 'build':
global build_output
build_output = opts.output if opts.output else build_output
global verbose
verbose = opts.verbose
if opts.daemon: if opts.daemon:
build(True, False) build(True, False)
elif opts.ui: elif opts.ui:
@ -159,4 +194,4 @@ def main():
if __name__ == '__main__': if __name__ == '__main__':
main() main()

@ -43,6 +43,9 @@ yarn-error.log
testem.log testem.log
/typings /typings
# only using yarn
package-lock.json
# System Files # System Files
.DS_Store .DS_Store
Thumbs.db Thumbs.db

Loading…
Cancel
Save