Skip to content
This repository has been archived by the owner on Nov 16, 2024. It is now read-only.

Install update #13

Merged
merged 3 commits into from
Feb 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
name: build and release

on:
push:
branch:
Expand All @@ -12,16 +14,19 @@ jobs:
- windows
- macos
architecture: ['x64']
app: ['cli', 'api']
app: ['cli', 'api', updater]
include:
- os: windows
data-file: "data/schema.sql;schema.sql"
name: windows
- os: macos
data-file: "data/schema.sql:schema.sql"
name: macos
- os: ubuntu
data-file: "data/schema.sql:schema.sql"
name: linux
runs-on: ${{ matrix.os }}-latest
name: ${{ matrix.app }}-${{ matrix.os }}-${{ matrix.architecture }}
name: ${{ matrix.app }}-${{ matrix.name }}-${{ matrix.architecture }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
Expand All @@ -31,11 +36,11 @@ jobs:
- run: pip install -r requirements.txt pyinstaller
- run: mkdir build
- run: mkdir bin
- run: pyinstaller --distpath bin --clean --add-data "${{ matrix.data-file }}" --onefile --name npbc_${{ matrix.app }}-${{ matrix.os }}-${{ matrix.architecture }} npbc_${{ matrix.app }}.py
- run: pyinstaller --distpath bin --clean --add-data "${{ matrix.data-file }}" --onefile --name npbc_${{ matrix.app }}-${{ matrix.name }}-${{ matrix.architecture }} npbc_${{ matrix.app }}.py
- uses: actions/upload-artifact@v2
with:
path: bin
name: npbc_${{ matrix.app }}-${{ matrix.os }}-${{ matrix.architecture }}
name: npbc_${{ matrix.app }}-${{ matrix.name }}-${{ matrix.architecture }}

release:
needs:
Expand Down
12 changes: 0 additions & 12 deletions install/install.bat

This file was deleted.

9 changes: 0 additions & 9 deletions install/install.sh

This file was deleted.

9 changes: 0 additions & 9 deletions install/piinstall.sh

This file was deleted.

62 changes: 62 additions & 0 deletions npbc_updater.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
from subprocess import call
from platform import system as get_platform_data
from sys import argv
from pathlib import Path
from urllib.request import urlopen


location_data = {
"Linux": {
"name": "ubuntu-x64",
"path": Path.home() / 'bin' / 'npbc'
},
"Windows": {
"name": "win-x64.exe",
"path": Path('C:') / 'Program Files' / 'npbc'
},
"Darwin": {
"name": "mac-x64",
"path": Path.home() / 'Applictaions' / 'npbc'
}
}


class NPBC_updater:
def __init__(self):
self.current_platform_data = location_data[get_platform_data()]
self.current_platform_data['path'].mkdir(parents=True, exist_ok=True)
self.cli_path = self.current_platform_data['path'] / \
f"npbc_cli-{self.current_platform_data['name']}"
self.api_path = self.current_platform_data['path'] / \
f"npbc_api-{self.current_platform_data['name']}"
self.cli_url = f"https://github.com/eccentricOrange/npbc/releases/latest/download/npbc_cli-{self.current_platform_data['name']}"
self.api_url = f"https://github.com/eccentricOrange/npbc/releases/latest/download/npbc_api-{self.current_platform_data['name']}"

def read_args(self):
if argv[1].strip().lower() == "update":
self.update()

else:
self.execute()

def update(self):
cli_download = urlopen(self.cli_url).read()
api = urlopen(self.api_url).read()

with open(self.cli_path, 'wb') as cli_file:
cli_file.write(cli_download)

with open(self.api_path, 'wb') as api_file:
api_file.write(api)

def execute(self):
call([self.cli_path, *argv[1:]])


def main():
updater = NPBC_updater()
updater.read_args()


if __name__ == "__main__":
main()