Skip to content

Commit 82478b9

Browse files
authored
Automatic builds (#21)
Enable automated build for linux, macos and Windows.
2 parents ec57171 + 20726e5 commit 82478b9

9 files changed

Lines changed: 590 additions & 34 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Manual build workflow for windows
2+
3+
on:
4+
workflow_dispatch:
5+
6+
7+
jobs:
8+
build:
9+
runs-on: ${{ matrix.os }}
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
os: ['windows-latest']
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
- uses: actions/setup-python@v2
18+
with:
19+
python-version: 3.9
20+
- run: pip install -r requirements.txt
21+
- run: python scripts/download-tools.py
22+
- run: pyinstaller openandroidinstaller/openandroidinstaller.py --noconsole --noconfirm --onefile --icon "openandroidinstaller/assets/favicon.ico" --add-data "openandroidinstaller/assets;assets" --add-binary "openandroidinstaller/bin/adb.exe;bin" --add-binary "openandroidinstaller/bin/fastboot.exe;bin" --add-binary "openandroidinstaller/bin/heimdall.exe;bin"
23+
# Optionally verify that it works (provided that it does not need user interaction)
24+
#- run: ./dist/your-code/your-code
25+
- uses: actions/upload-artifact@v3
26+
with:
27+
name: openandroidinstaller-${{ github.sha }}-${{ matrix.os }}
28+
path: dist/

.github/workflows/manual-build.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Manual build workflow
2+
3+
on:
4+
workflow_dispatch:
5+
6+
7+
jobs:
8+
build:
9+
runs-on: ${{ matrix.os }}
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
os: ['ubuntu-latest', 'macos-latest']
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
- uses: actions/setup-python@v2
18+
with:
19+
python-version: 3.9
20+
- run: pip install -r requirements.txt
21+
- run: python scripts/download-tools.py
22+
- run: pyinstaller openandroidinstaller/openandroidinstaller.py --noconsole --noconfirm --onefile --icon "openandroidinstaller/assets/favicon.ico" --add-data "openandroidinstaller/assets:assets" --add-binary "openandroidinstaller/bin/adb:bin" --add-binary "openandroidinstaller/bin/fastboot:bin" --add-binary "openandroidinstaller/bin/heimdall:bin"
23+
# Optionally verify that it works (provided that it does not need user interaction)
24+
#- run: ./dist/your-code/your-code
25+
- uses: actions/upload-artifact@v3
26+
with:
27+
name: openandroidinstaller-${{ github.sha }}-${{ matrix.os }}
28+
path: dist/

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
install:
1+
poetry:
22
curl -sSL https://install.python-poetry.org | python3 -
3+
4+
install:
35
poetry install
46
poetry run python scripts/download-tools.py
57

8+
export:
9+
poetry export -f requirements.txt --output requirements.txt
10+
611
test:
712
poetry run pytest tests/
813

@@ -12,6 +17,5 @@ app:
1217
build-app:
1318
poetry run pyinstaller openandroidinstaller/openandroidinstaller.py --noconsole --noconfirm --onefile --icon "/assets/favicon.ico" --add-data "openandroidinstaller/assets:assets" --add-binary "openandroidinstaller/bin/adb:bin" --add-binary "openandroidinstaller/bin/fastboot:bin" --add-binary "openandroidinstaller/bin/heimdall:bin"
1419

15-
1620
clean-build:
1721
rm -rf build/ dist/

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Currently, only linux is supported.
6060
Currently development is only supported on Ubuntu Linux. MacOS should also work fine.
6161

6262
1. Clone the main branch of this repository
63-
2. Run `make install` to install poetry to manage python and install the requirend dependencies like adb, fastboot and heimdall.
63+
2. Run `make poetry` and `make install` to install poetry to manage python and install the required dependencies like adb, fastboot and heimdall.
6464
3. Run `make app` to start the desktop app from the source.
6565

6666

openandroidinstaller/installer_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def __init__(
5555

5656
@classmethod
5757
def from_file(cls, path):
58-
with open(path, "r") as stream:
58+
with open(path, "r", encoding="utf-8") as stream:
5959
try:
6060
raw_config = yaml.safe_load(stream)
6161
if validate_config(raw_config):

openandroidinstaller/openandroidinstaller.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# If not, see <https://www.gnu.org/licenses/>."""
1414
# Author: Tobias Sterbak
1515

16+
import os
1617
import sys
1718
import webbrowser
1819
from pathlib import Path
@@ -38,8 +39,8 @@
3839

3940
PLATFORM = sys.platform
4041
# Define asset paths
41-
CONFIG_PATH = Path(__file__).parent.joinpath(Path("assets/configs")).resolve()
42-
IMAGE_PATH = Path(__file__).parent.joinpath(Path("assets/imgs")).resolve()
42+
CONFIG_PATH = Path(__file__).parent.joinpath(Path(os.sep.join(["assets", "configs"]))).resolve()
43+
IMAGE_PATH = Path(__file__).parent.joinpath(Path(os.sep.join(["assets", "imgs"]))).resolve()
4344
BIN_PATH = Path(__file__).parent.joinpath(Path("bin")).resolve()
4445

4546

@@ -115,7 +116,7 @@ def check_bootloader_unlocked(e):
115116
self.state.num_total_steps = len(self.state.steps)
116117

117118
self.bootloader_checkbox = Checkbox(
118-
label="Bootlaoder is already unlocked.", on_change=check_bootloader_unlocked, disabled=True
119+
label="Bootloader is already unlocked.", on_change=check_bootloader_unlocked, disabled=True
119120
)
120121

121122
# build up the main view
@@ -324,7 +325,7 @@ def build(self):
324325

325326
def enable_button_if_ready(self, e):
326327
"""Enable the confirm button if both files have been selected."""
327-
if self.selected_image.value and self.selected_recovery.value:
328+
if (".zip" in self.selected_image.value) and (".img" in self.selected_recovery.value):
328329
self.confirm_button.disabled = False
329330
self.right_view.update()
330331
else:
@@ -456,16 +457,22 @@ def pick_image_result(self, e: FilePickerResultEvent):
456457
self.selected_image.value += (
457458
", ".join(map(lambda f: f.name, e.files)) if e.files else "Cancelled!"
458459
)
459-
self.image_path = e.files[0].path
460-
logger.info(f"Selected image from {self.image_path}")
460+
if e.files:
461+
self.image_path = e.files[0].path
462+
logger.info(f"Selected image from {self.image_path}")
463+
else:
464+
logger.info("No image selected.")
461465
self.selected_image.update()
462466

463467
def pick_recovery_result(self, e: FilePickerResultEvent):
464468
self.selected_recovery.value += (
465469
", ".join(map(lambda f: f.name, e.files)) if e.files else "Cancelled!"
466470
)
467-
self.recovery_path = e.files[0].path
468-
logger.info(f"Selected recovery from {self.recovery_path}")
471+
if e.files:
472+
self.recovery_path = e.files[0].path
473+
logger.info(f"Selected recovery from {self.recovery_path}")
474+
else:
475+
logger.info("No image selected.")
469476
self.selected_recovery.update()
470477

471478

@@ -587,7 +594,7 @@ def main(page: Page):
587594
page.horizontal_alignment = "center"
588595

589596
# header
590-
image_path = Path(__file__).parent.joinpath(Path("assets/logo-192x192.png"))
597+
image_path = Path(__file__).parent.joinpath(Path(os.sep.join(["assets", "logo-192x192.png"])))
591598
page.appbar = AppBar(
592599
leading=Image(src=image_path, height=40, width=40, border_radius=40),
593600
leading_width=56,

openandroidinstaller/tool_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ def search_device(platform: str, bin_path: Path) -> Optional[str]:
5454
],
5555
stderr=STDOUT,
5656
).decode()
57-
elif platform == "windows":
57+
elif platform in ("windows", "win32"):
5858
output = check_output(
5959
[
60-
str(bin_path.joinpath(Path("adb"))),
60+
str(bin_path.joinpath(Path("adb.exe"))),
6161
"shell",
6262
"getprop",
6363
"|",

0 commit comments

Comments
 (0)