Skip to content

Commit

Permalink
Merge pull request nasa#106 from doizuc/bundle
Browse files Browse the repository at this point in the history
Added GitHub Workflow to automatically bundle application
  • Loading branch information
oceancolorcoder authored Oct 26, 2023
2 parents 3b1b3a5 + 7e42a75 commit d7bdca9
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 6 deletions.
86 changes: 86 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
on:
push:
branches:
- main
- dev
- workflow

jobs:
build:
runs-on: ${{ matrix.os }}
defaults: # Required for conda environment activation
run:
shell: bash -el {0}
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']

steps:
- name: Get System Information
uses: kenchan0130/actions-system-info@master
id: system-info
- name: Echo Host Information
run: |
echo "OS: ${{ runner.os }}"
echo "CPU Core: ${{ steps.system-info.outputs.cpu-core }}"
echo "CPU Model: ${{ steps.system-info.outputs.cpu-model }}"
echo "Hostname: ${{ steps.system-info.outputs.hostname }}"
echo "Kernel release: ${{ steps.system-info.outputs.kernel-release }}"
echo "Kernel version: ${{ steps.system-info.outputs.kernel-version }}"
echo "Name: ${{ steps.system-info.outputs.name }}"
echo "Platform: ${{ steps.system-info.outputs.platform }}"
echo "Release: ${{ steps.system-info.outputs.release }}"
echo "Total memory bytes: ${{ steps.system-info.outputs.totalmem }}"
- name: Extract Branch Name
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: ${{ steps.extract_branch.outputs.branch }}

# - name: Cache conda
# uses: actions/cache@v2
# env:
# # Increase this value to reset cache if etc/example-environment.yml has not changed
# CACHE_NUMBER: 0
# with:
# path: ~/conda_pkgs_dir
# key:
# ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('environment.yml') }}
- name: Setup conda environment
uses: conda-incubator/setup-miniconda@v2
with:
auto-activate-base: false
activate-environment: hypercp
environment-file: environment.yml
# use-only-tar-bz2: true
- name: Install PyInstaller
run: conda install --channel=conda-forge pyinstaller==6.0
- name: Capture conda environment
run: |
conda info
conda list
- name: Make Bundle
run: |
python make.py
echo "BUNDLE_NAME=$(ls Bundled/dist | xargs)" >> $GITHUB_ENV
- name: Zip Bundle
uses: thedoctor0/[email protected]
with:
type: 'zip'
directory: 'Bundled/dist/'
path: '${{ env.BUNDLE_NAME }}'
filename: '${{ env.BUNDLE_NAME }}.zip'

- name: Upload Bundle
uses: actions/upload-artifact@v3
with:
name: ${{ env.BUNDLE_NAME }}
path: Bundled/dist/${{ env.BUNDLE_NAME }}.zip
# Known issue of double zip: https://github.com/actions/upload-artifact/issues/39
# However, need to zip before upload as too many files to send otherwise (very slow)
27 changes: 21 additions & 6 deletions README_bundle.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# HyperCP build executable


## Bundle Locally
To bundle the application, first install PyInstaller in your `hypercp` environment. Note that only version 6.0.0 of PyInstaller was tested.

conda activate hypercp
conda install pyinstaller

On Windows, the command above might install PyInstaller 5.6.2 which could result in build failure (at execution time), a fix was to upgrade as follow

pip install --upgrade auto-py-to-exe
conda install --channel=conda-forge pyinstaller==6.0

To bundle the application run the `make.py` script

Expand All @@ -17,4 +15,21 @@ If the command is executed successfully, you will find an executable in the fold

On macOS the executable should work on both Intel and Apple Silicon processors despite the host used for building the application. However, this feature wasn't tested.

These steps were tested on macOS Ventura and Windows 10 only.
These steps were tested on macOS Ventura, Sonoma, and Windows 10 only.

## Bundle with GitHub Workflow
On any push to the main, dev, or workflow branch the application will be bundled

On macOS, bundled application are not signed, hence macOS Gatekeeper will raise a warning and prevent the application to run. The preferred workaround is to authorize the application to run.

cd HyperCP-v1.2.0-Darwin
sudo xattr -r -d com.apple.quarantine HyperCP-v1.2.0-Darwin
sudo xattr -r -d com.apple.quarantine _internal/*.dylib

Another workaround (not recommended) is to disable macOS Gatekeeper only during the time HyperCP is used.

sudo spctl --master-disable

When done running HyperCP do not forget to re-enable macOS Gatekeeper.

sudo spctl --master-enable

0 comments on commit d7bdca9

Please sign in to comment.