Skip to content

Commit

Permalink
Launcher V3 (#86)
Browse files Browse the repository at this point in the history
* uberlauncher

* java installer script PoC

* migrate to requests library

* Barebones PyInstaller build launcher action

* add todo note

* mega refactor

* java auto-installer and locator

* update build action

* win, mac, linux builds

* aarch64 build test

* alternative python docker image

* sudo?

* update docker action versions

* release action test

* rename and update artifact upload

* correct paths

* update artifact release

* build matrix

* backslashes

* set as prerelease

* launcher-python script

* non-native python launcher artifact

* fix path

* launcher update test

* ensure pip requirements are installed

* windows relauncher fix

* publish hashes as release artifact

* fix windows hash path

* check published hashes to determine if launcher should update

* remove any existing launcher files in launcher dir

* already computed

* py launcher fixes

* getting py launcher to relaunch

* propagate args to skip launcher update check

* correct executable

* java and linux on a single github release

* launcher arg to run setup

* skip launcher update if expected local executable not found

* backwards compatible releases

* still publish old launcher.py file so we don't break everyone still using it

* python launcher pip installed checks

* fixing a couple issues

* rename launcher executables to prevent file name conflicts

* ambiguous redirect fix?

* try fixing tags

* set envs like this

* fix unzip not persisting file perms

* move deprecated launcher.py to scripts folder

* reduce pip install verbosity

* install pip in cloud-init script

* show how to install pip on ubuntu

* requests refactor

* also check for java in JAVA_HOME env variable

* allow double clicking the launcher.exe on windows

* remove possibly confusing log

* use port 25565 by default on empty setup input

* reformatting python src

* Print out which files have been extracted from zips

* Don't log launcher update stuff when there's no update

* Invalid release channel selected rescue routine

* stop if data is none, shouldn't reach this

* this should be a critical error

* small refactor and logic cleanup

* error varargs function

* remove log

* rephrase up to date log

* update actions/checkout

* adding a few informational logs

* update readme and scripts for launcher v3

* rearrange readme sections

* use drop-down menu's to reduce noise

* drop down formatting

* try this formatting

* this should work

* add recommended terminals dropdown

* move dropdowns after the numbered list

* mac os aarch64 support

* determine platform smarter

* this is actually provided by default

* update readme

* refactoring launcher update exec

* prevent file name conflicts

* platform and arch enums

* renaming and rewording

* add launcher exe icon on windows

* pyinstaller paths what

* replace none checks with exceptions

* catch any errors during zenith update check

* embed release tag into jar

* somehow missed this

* grab exe name without preceding path

* keep .py file on old release

* git launcher scripts

* remove old launcher v1 scripts

* add comments for how to run the git launcher scripts

* remove cacert

* add executable perms to scripts

* update launcher release action

* validate cpu architecture in setup
  • Loading branch information
rfresh2 authored Feb 4, 2024
1 parent 57a7b2a commit 5063e42
Show file tree
Hide file tree
Showing 43 changed files with 1,590 additions and 5,254 deletions.
115 changes: 115 additions & 0 deletions .github/workflows/act-build-launcher.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: Build Launcher

on:
workflow_dispatch:

env:
python_version: '3.12'

jobs:
build-matrix:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ 'ubuntu-20.04' ]
include:
- os: 'ubuntu-20.04'
artifact-name: 'launcher-linux-amd64'
move-command: 'mv dist/__main__ dist/launch'
zip-command: 'zip -j dist/ZenithProxy-launcher-linux-amd64.zip dist/launch'
sha1-command: 'sha1sum -b dist/launch | cut -d" " -f 1'
steps:
- name: Check out repository
uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: ${{ env.python_version }}

- name: Install PyInstaller
run: |
pip install -U pyinstaller
pip install -r ./src/launcher/requirements.txt
- name: Build launcher
run: |
pyinstaller --specpath ./build -p ./src/launcher --onefile --noconfirm ./src/launcher/__main__.py
- name: Rename executable
run: |
${{ matrix.move-command }}
- name: Create zip
run: |
${{ matrix.zip-command }}
- name: Upload Binary
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.artifact-name }}
path: dist/ZenithProxy-${{ matrix.artifact-name }}.zip

- name: Get Binary Hash
run: ${{ matrix.sha1-command }} > ZenithProxy-${{ matrix.artifact-name }}.sha1

- name: Upload Launcher Hash Version
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.artifact-name }}.sha1
path: ZenithProxy-${{ matrix.artifact-name }}.sha1

package-python:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Create Python executable zip
run: zip -j launcher-py.zip src/launcher/*.py

- name: Elevate script permissions
run: |
chmod +x src/launcher/launch.sh
- name: Create release zip
run: zip -j ZenithProxy-launcher-python.zip launcher-py.zip src/launcher/requirements.txt src/launcher/launch.sh src/launcher/launch.bat

- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: launcher-python
path: ZenithProxy-launcher-python.zip

- name: Get Binary Hash
run: sha1sum -b launcher-py.zip | cut -d" " -f 1 > ZenithProxy-launcher-python.sha1

- name: Upload Launcher Hash Version
uses: actions/upload-artifact@v3
with:
name: launcher-python.sha1
path: ZenithProxy-launcher-python.sha1

release-artifacts:
needs:
- build-matrix
- package-python
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Download job artifacts
uses: actions/download-artifact@v3
with:
path: artifacts/

- name: Compile Hashes
run: |
cat artifacts/**/*.sha1 > hashes.txt
- name: Upload Hashes Version
uses: actions/upload-artifact@v3
with:
name: hashes.txt
path: hashes.txt
2 changes: 1 addition & 1 deletion .github/workflows/act-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Check out repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup GraalVM
uses: graalvm/setup-graalvm@v1
Expand Down
11 changes: 0 additions & 11 deletions .github/workflows/build-launcher.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Gradle Wrapper Verification
uses: gradle/wrapper-validation-action@v1
Expand Down
27 changes: 0 additions & 27 deletions .github/workflows/publish_launcher.yml

This file was deleted.

184 changes: 184 additions & 0 deletions .github/workflows/release-launcher.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
name: Release Launcher

on:
workflow_dispatch:

env:
python_version: '3.12'

jobs:
build-matrix:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ 'windows-2019', 'ubuntu-20.04', 'macos-11', 'macos-14' ]
include:
- os: 'windows-2019'
artifact-name: 'launcher-windows-amd64'
move-command: 'Move-Item -Path .\dist\__main__.exe -Destination .\dist\launch.exe'
zip-command: 'Compress-Archive -Path .\dist\launch.exe -DestinationPath .\dist\ZenithProxy-launcher-windows-amd64.zip'
sha1-command: '(Get-FileHash -Path dist\launch.exe -Algorithm sha1).Hash.ToLower()'
- os: 'ubuntu-20.04'
artifact-name: 'launcher-linux-amd64'
move-command: 'mv dist/__main__ dist/launch'
zip-command: 'zip -j dist/ZenithProxy-launcher-linux-amd64.zip dist/launch'
sha1-command: 'sha1sum -b dist/launch | cut -d" " -f 1'
- os: 'macos-11'
artifact-name: 'launcher-macos-amd64'
move-command: 'mv dist/__main__ dist/launch'
zip-command: 'zip -j dist/ZenithProxy-launcher-macos-amd64.zip dist/launch'
sha1-command: 'sha1sum -b dist/launch | cut -d" " -f 1'
- os: 'macos-14'
artifact-name: 'launcher-macos-aarch64'
move-command: 'mv dist/__main__ dist/launch'
zip-command: 'zip -j dist/ZenithProxy-launcher-macos-aarch64.zip dist/launch'
sha1-command: 'sha1sum -b dist/launch | cut -d" " -f 1'
steps:
- name: Check out repository
uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: ${{ env.python_version }}

- name: Install PyInstaller
run: |
pip install -U pyinstaller
pip install -r ./src/launcher/requirements.txt
- name: Build launcher
run: >
pyinstaller --specpath ./build
-p ./src/launcher --onefile --noconfirm
-i ../src/launcher/icon.ico
./src/launcher/__main__.py
- name: Rename executable
run: |
${{ matrix.move-command }}
- name: Create zip
run: |
${{ matrix.zip-command }}
- name: Upload Binary
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact-name }}
path: dist/ZenithProxy-${{ matrix.artifact-name }}.zip

- name: Get Binary Hash
run: ${{ matrix.sha1-command }} > ZenithProxy-${{ matrix.artifact-name }}.sha1

- name: Upload Launcher Hash Version
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact-name }}.sha1
path: ZenithProxy-${{ matrix.artifact-name }}.sha1

build-linux-aarch64:
runs-on: 'ubuntu-latest'
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build binary on emulated aarch64
run: |
docker run --rm --platform linux/arm64 --volume "${PWD}:/repo" python:${{ env.python_version }}-bullseye /bin/sh -c " \
cd /repo && \
python3 -m pip install -U pyinstaller && \
python3 -m pip install -r ./src/launcher/requirements.txt && \
pyinstaller --specpath ./build -p ./src/launcher --onefile --noconfirm ./src/launcher/__main__.py
"
- name: Rename executable
run: |
sudo mv dist/__main__ dist/launch
- name: Elevate binary permissions
run: sudo chmod +x dist/launch

- name: Create zip
run: sudo zip -j dist/ZenithProxy-launcher-linux-aarch64.zip dist/launch

- name: Upload Binary
uses: actions/upload-artifact@v4
with:
name: launcher-linux-aarch64
path: dist/ZenithProxy-launcher-linux-aarch64.zip

- name: Get Binary Hash
run: sha1sum -b dist/launch | cut -d" " -f 1 > ZenithProxy-launcher-linux-aarch64.sha1

- name: Upload Launcher Hash Version
uses: actions/upload-artifact@v4
with:
name: launcher-linux-aarch64.sha1
path: ZenithProxy-launcher-linux-aarch64.sha1

package-python:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Create Python executable zip
run: zip -j launcher-py.zip src/launcher/*.py

- name: Elevate script permissions
run: |
chmod +x src/launcher/launch.sh
- name: Create release zip
run: zip -j ZenithProxy-launcher-python.zip launcher-py.zip src/launcher/requirements.txt src/launcher/launch.sh src/launcher/launch.bat

- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: launcher-python
path: ZenithProxy-launcher-python.zip

- name: Get Binary Hash
run: sha1sum -b launcher-py.zip | cut -d" " -f 1 > ZenithProxy-launcher-python.sha1

- name: Upload Launcher Hash Version
uses: actions/upload-artifact@v4
with:
name: launcher-python.sha1
path: ZenithProxy-launcher-python.sha1

release-artifacts:
needs:
- build-matrix
- build-linux-aarch64
- package-python
runs-on: ubuntu-latest
steps:
- name: Download job artifacts
uses: actions/download-artifact@v4
with:
merge-multiple: true
path: artifacts/

- name: Compile Hashes
run: |
cat artifacts/*.sha1 > hashes.txt
- name: Publish Release Artifacts
uses: ncipollo/release-action@v1
with:
tag: "launcher-v3"
artifacts: "artifacts/*.zip,hashes.txt"
allowUpdates: true
replacesArtifacts: true
omitBodyDuringUpdate: true
prerelease: true
removeArtifacts: true
makeLatest: true
6 changes: 5 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Check out repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup GraalVM
uses: graalvm/setup-graalvm@v1
Expand Down Expand Up @@ -41,6 +41,10 @@ jobs:
run: |
echo "GRAALVM_PGO_INSTRUMENT=true" >> "$GITHUB_ENV"
- name: Export Tag
run: |
echo "RELEASE_TAG=${{ github.ref_name }}" >> "$GITHUB_ENV"
- name: Build ZenithProxy Java
uses: gradle/gradle-build-action@v2
with:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ gradle.properties
dist/
/*.spec
__pycache__/
*.exe
*.zip
/launcher-python*
Loading

0 comments on commit 5063e42

Please sign in to comment.