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:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
working-directory: mediarepo-daemon
steps:
- uses: actions/checkout@v2
if: ${{ !env.ACT }}
@ -50,12 +46,17 @@ jobs:
restore-keys: |
${{ runner.os }}-cargo-
- name: setup python
uses: actions/setup-python@v2
with:
python-version: '^3.7'
- name: Build Daemon
run: cargo build --release --no-default-features --verbose
run: python build.py build --daemon --verbose
- uses: vimtor/action-zip@v1
with:
files: mediarepo-daemon/target/release/mediarepo-daemon mediarepo-daemon/target/release/mediarepo-daemon.exe
files: out/
dest: mediarepo-daemon-${{ runner.os }}.zip
- name: Upload Release Asset
@ -76,10 +77,6 @@ jobs:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
working-directory: mediarepo-ui
steps:
- uses: actions/checkout@v2
if: ${{ !env.ACT }}
@ -99,23 +96,16 @@ jobs:
${{ runner.os }}-release-dependencies-
${{ runner.os }}-dependencies-
- name: setup python
uses: actions/setup-python@v2
with:
python-version: '^3.7'
- name: Use Node.js 16
uses: actions/setup-node@v1
with:
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
uses: knicknic/os-specific-run@v1.0.3
with:
@ -124,11 +114,11 @@ jobs:
DEBIAN_FRONTEND=noninteractive sudo apt-get install libwebkit2gtk-4.0-dev libgtk-3-dev libappindicator3-dev -y
- name: Build project
run: cargo tauri build --verbose
run: python build.py build --ui --verbose
- uses: vimtor/action-zip@v1
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
- 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:
> 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:
```sh
$ python build.py build
$ ./build.py build
```
Daemon only:
```sh
$ python build.py build --daemon
$ ./build.py build --daemon
```
UI only:
```sh
$ python build.py build --ui
$ ./build.py build --ui
```
After building the `out` directory contains all the built binaries and bundles.

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

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

Loading…
Cancel
Save