Skip to content

Commit

Permalink
Add release pipeline
Browse files Browse the repository at this point in the history
Closes: #5
  • Loading branch information
sco1 committed Nov 2, 2023
1 parent 73039fb commit f0ea7eb
Show file tree
Hide file tree
Showing 13 changed files with 151 additions and 191 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/release_artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Build Release Artifacts

on:
release:
types: [published]

jobs:
artifacts:
name: Package & upload release artifacts
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'

- name: Compile skyportal lib
run: |
python -m pip install mpy-cross
python ./compile.py
- name: Build base bundle
run: |
tar -cvf bundle_base.tar \
./assets/* \
./lib/* \
./boot.py \
./code.py \
./constants.py \
./pyportal_startup.bmp \
./pyportal_startup.wav \
./secrets.py
- name: Create non-compiled bundle
run: |
cp bundle_base.tar skyportal_bundle.tar
tar -rvf skyportal_bundle.tar ./skyportal/*
gzip skyportal_bundle.tar
- name: Create compiled bundle
run: |
cp bundle_base.tar skyportal_bundle_compiled.tar
tar -rvf skyportal_bundle_compiled.tar -C ./dist/ .
gzip skyportal_bundle_compiled.tar
- name: Upload artifacts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run:
gh release upload ${{ github.event.release.tag_name }} skyportal_bundle.tar.gz skyportal_bundle_compiled.tar.gz
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,28 @@ Heavily inspired by Bob Hammell"s PyPortal Flight Tracker ([GH](https://github.c
Thank you to [markleoart](https://www.fiverr.com/markleoart) for creating the aircraft icon sprite sheets!

## Getting Started
Users are assumed have read through [Adafruit"s PyPortal learning guide](https://learn.adafruit.com/adafruit-pyportal). CircuitPython v8.2 is currently in use for this repository, no other versions are evaluated.
Users are assumed have read through [Adafruit's PyPortal learning guide](https://learn.adafruit.com/adafruit-pyportal). CircuitPython v8.2 is currently in use for this repository, no other versions are evaluated.

To get up and running, copy the following files to your PyPortal:
**WARNING:** In order to generate the background map tile, this project's `boot.py` modifies the boot process to allow the filesystem to be used as a writeable cache. In the unlikely event that things go horribly awry you may lose the existing contents of your device, so be sure to back them up before working with this project.

### Installation
#### From Source
To get up and running, copy the following files from the repository to your PyPortal:

```
assets/
lib/
skyportal/
airplane_icons.bmp
boot.py
code.py
constants.py
default_map.bmp
heli_icons.bmp
pyportal_startup.bmp
pyportal_startup.wav
secrets.py
splash.bmp
```

**WARNING:** In order to generate the background map tile, this project's `boot.py` modifies the boot process to allow the filesystem to be used as a writeable cache. In the unlikely event that things go horribly awry you may lose the existing contents of your device, so be sure to back them up before working with this project.
#### From GH Release
The Skyportal [Releases page](https://github.com/sco1/skyportal/releases) contains bundled `*.tar.gz` archives, built in CI, that can be downloaded and extracted directly onto the device. Bundles come in two flavors: one pure-python implementation and one compiled `*.mpy` version, which has a decreased overall file size.

### Secrets
The following secrets are required for functionality:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
31 changes: 31 additions & 0 deletions compile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import time
from pathlib import Path

import mpy_cross

SOURCE_DIR = Path("./skyportal")
DEST_DIR = Path("./dist/lib/skyportal")


if __name__ == "__main__":
DEST_DIR.mkdir(parents=True, exist_ok=True)

to_compile = list(SOURCE_DIR.glob("*.py"))
print(f"Found {len(to_compile)} *.py files to compile")
for filepath in to_compile:
mpy_cross.run(filepath)

time.sleep(1) # Lazy wait for subprocesses to finish

compiled = list(SOURCE_DIR.glob("*.mpy"))
if len(compiled) != len(to_compile):
raise RuntimeError(
f"Number of compiled files less than original source ({len(compiled)} < {len(to_compile)}), may need a longer wait" # noqa: E501
)

print(f"Compiled {len(compiled)} files ... moving to {DEST_DIR}")
for filepath in compiled:
dest = DEST_DIR / filepath.name
dest.unlink(missing_ok=True)

filepath.rename(DEST_DIR / filepath.name)
Binary file added lib/adafruit_bitmapsaver.mpy
Binary file not shown.
Loading

0 comments on commit f0ea7eb

Please sign in to comment.