Build FujiNet-PC Launcher #57
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build FujiNet-PC Launcher | |
on: | |
# push: | |
# branches: [ master ] | |
# pull_request: | |
# branches: [ master ] | |
workflow_dispatch: | |
inputs: | |
releaseBuild: | |
description: 'Prepare release bundle (adds tag)' | |
type: boolean | |
default: false | |
doRelease: | |
description: 'Create GitHub Release' | |
type: boolean | |
default: false | |
draftRelease: | |
description: 'Draft' | |
type: boolean | |
default: false | |
releaseVersion: | |
description: 'Release version, blank for auto' | |
jobs: | |
build-prep: | |
# prepare to build a release: create tag release-{version} pointing to head | |
runs-on: ubuntu-latest | |
name: Prepare | |
steps: | |
- name: Not release build | |
if: ${{ github.event.inputs.releaseBuild == 'false' }} | |
run: | | |
echo 'This build in not a release build.' | |
echo 'Release tag will not be created.' | |
echo 'However if release tag exists on HEAD, it will be used to make a release build.' | |
- name: Prepeare for release build | |
if: ${{ github.event.inputs.releaseBuild == 'true' }} | |
run: | | |
echo 'This build is release build.' | |
echo 'New release tag will be created (or existing tag on HEAD will be used) to make a release build.' | |
- name: '🧰 Checkout' | |
if: ${{ github.event.inputs.releaseBuild == 'true' }} | |
uses: actions/checkout@v3 | |
- name: Fetch tags | |
if: ${{ github.event.inputs.releaseBuild == 'true' }} | |
run: git fetch --prune --unshallow --tags | |
- name: Prepare release tag | |
if: ${{ github.event.inputs.releaseBuild == 'true' }} | |
run: python build_version.py release:push ${{ github.event.inputs.releaseVersion }} | |
scripts: | |
name: 'Bundle scripts (no binaries)' | |
needs: build-prep | |
runs-on: ubuntu-latest | |
if: ${{ github.event.inputs.releaseBuild == 'true' }} | |
outputs: | |
release_version: ${{ steps.version.outputs.release }} | |
launcher_version: ${{ steps.version.outputs.launcher }} | |
steps: | |
- name: '🧰 Checkout Launcher' | |
uses: actions/checkout@v3 | |
with: | |
path: fujinet-pc-launcher | |
- name: '🧰 Checkout Emulator Bridge' | |
uses: actions/checkout@v3 | |
with: | |
repository: FujiNetWIFI/fujinet-emulator-bridge | |
path: fujinet-emulator-bridge | |
- name: Fetch tags | |
working-directory: fujinet-pc-launcher | |
run: git fetch --prune --unshallow --tags | |
- name: Update launcher version | |
working-directory: fujinet-pc-launcher | |
run: python build_version.py | |
- name: Get launcher version | |
id: version | |
working-directory: fujinet-pc-launcher/launcher | |
# prevent __pycache__ to be created | |
env: | |
PYTHONDONTWRITEBYTECODE: 1 | |
run: | | |
python -c 'import version; print(version.VERSION_FULL)' | |
echo "launcher=$(python -c 'import version; print(version.VERSION_FULL)')" >> $GITHUB_OUTPUT | |
echo "release=$(python -c 'import version; print(version.VERSION_FULL)' | sed 's/\(\.[1-9]\)\..*/\1/')" >> $GITHUB_OUTPUT | |
- name: Populate dist directory | |
run: | | |
mkdir dist | |
mkdir dist/emulator | |
cp -av fujinet-pc-launcher/launcher dist | |
cp -av fujinet-emulator-bridge/fujinet-bridge/netsiohub dist | |
cp -av fujinet-emulator-bridge/altirra-custom-device dist/emulator/Altirra | |
mkdir dist/fujinet-pc | |
echo 'This directory is for FujiNet-PC executable.' > dist/fujinet-pc/README.txt | |
echo 'Visit https://github.com/FujiNetWIFI/fujinet-pc/releases to download binaries for your OS.' >> dist/fujinet-pc/README.txt | |
echo 'Place extracted files here.' >> dist/fujinet-pc/README.txt | |
- name: List dist | |
run: ls -lR dist | |
- name: Upload build artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: fujinet-pc-scripts_${{ steps.version.outputs.release }} | |
path: dist/** | |
build: | |
# Build binary bundles | |
needs: build-prep | |
strategy: | |
fail-fast: false | |
matrix: | |
name: [Windows] | |
target: [windows-x64] | |
runner: [windows-latest] | |
include: | |
# - name: Ubuntu 22.04 | |
# target: ubuntu-22.04-amd64 | |
# runner: ubuntu-22.04 | |
# default-shell: bash | |
# - name: Ubuntu 18.04 | |
# target: ubuntu-18.04-amd64 | |
# runner: ubuntu-18.04 | |
# default-shell: bash | |
- name: macOS 11 | |
target: macos-11 | |
runner: macos-11 | |
# continue-on-error: true | |
name: Build ${{ matrix.name }} | |
runs-on: ${{ matrix.runner }} | |
steps: | |
- name: '🧰 Checkout Launcher' | |
uses: actions/checkout@v3 | |
with: | |
path: fujinet-pc-launcher | |
- name: '🧰 Checkout Emulator Bridge' | |
uses: actions/checkout@v3 | |
with: | |
repository: FujiNetWIFI/fujinet-emulator-bridge | |
path: fujinet-emulator-bridge | |
- name: Fetch tags | |
working-directory: fujinet-pc-launcher | |
run: git fetch --prune --unshallow --tags | |
- name: 'Copy NetSIO hub module' | |
shell: bash | |
run: cp -av fujinet-emulator-bridge/fujinet-bridge/netsiohub fujinet-pc-launcher | |
- name: 'List directories' | |
shell: bash | |
run: | | |
pwd | |
ls -lR . | |
- name: Install Python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: '3.10' | |
architecture: 'x64' | |
- name: List versions | |
run: | | |
python --version | |
pip --version | |
- name: Install requirements | |
working-directory: fujinet-pc-launcher | |
run: pip install -r requirements_build.txt | |
- name: Update launcher version | |
working-directory: fujinet-pc-launcher | |
run: python build_version.py | |
- name: '🚧 [Windows] Build FujiNet-PC Launcher' | |
if: ${{ startsWith(matrix.target, 'windows') }} | |
working-directory: fujinet-pc-launcher | |
run: pyinstaller --clean --onedir --noconfirm --noconsole --python-option u --name launcher --icon launcher\images\launcher-bg.ico --add-data "launcher\images;images" launcher\__main__.py | |
- name: '🚧 [macOS] Build FujiNet-PC Launcher' | |
if: ${{ startsWith(matrix.target, 'macos') }} | |
working-directory: fujinet-pc-launcher | |
run: pyinstaller --clean --onedir --noconfirm --noconsole --python-option u --name launcher --icon launcher/images/launcher-bg.ico --add-data launcher/images:images launcher/__main__.py | |
- name: 'Get launcher version' | |
id: version | |
working-directory: fujinet-pc-launcher | |
shell: bash | |
run: | | |
python -m launcher -V | |
echo "launcher=$(python -m launcher -V | awk '{if(tolower($1)=="fujinet-pc" && tolower($2)=="launcher") print $3}')" >> $GITHUB_OUTPUT | |
echo "release=$(python -m launcher -V | awk '{if(tolower($1)=="fujinet-pc" && tolower($2)=="launcher") print $3}' | sed 's/\(\.[1-9][0-9]*\)\..*/\1/')" >> $GITHUB_OUTPUT | |
- name: Update dist with emulator files | |
if: ${{ github.event.inputs.releaseBuild == 'true' }} | |
shell: bash | |
run: | | |
mkdir -p fujinet-pc-launcher/dist/emulator | |
cp -av fujinet-emulator-bridge/altirra-custom-device fujinet-pc-launcher/dist/emulator/Altirra | |
- name: '[Windows] Download latest FujiNet-PC release' | |
if: ${{ startsWith(matrix.target, 'windows') && github.event.inputs.releaseBuild == 'true' }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
python fujinet-pc-launcher/launcher/download_release.py "fujinet-pc_*_${{ matrix.target }}.*" | |
# TODO: remove, temporary workaround for missing fujinet-pc release for macos-11 | |
- name: '[macOS] Download latest FujiNet-PC release' | |
if: ${{ startsWith(matrix.target, 'macos') && github.event.inputs.releaseBuild == 'true' }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
python fujinet-pc-launcher/launcher/download_release.py "fujinet-pc_*_macos-*.*" | |
- name: '[Windows] Unzip FujiNet-PC into dist' | |
if: ${{ startsWith(matrix.target, 'windows') && github.event.inputs.releaseBuild == 'true' }} | |
run: 7z x -ofujinet-pc-launcher/dist fujinet-pc_*_${{ matrix.target }}.zip | |
# TODO use matrix.target instead of macos-* | |
- name: '[macOS] Uncompress FujiNet-PC into launcher.app' | |
if: ${{ startsWith(matrix.target, 'macos') && github.event.inputs.releaseBuild == 'true' }} | |
run: tar -xzf fujinet-pc_*_macos-*.tar.gz -C fujinet-pc-launcher/dist/launcher.app/Contents | |
- name: '[macOS] Remove dist/launcher (keep launcher.app only)' | |
if: ${{ startsWith(matrix.target, 'macos') && github.event.inputs.releaseBuild == 'true' }} | |
run: rm -rf fujinet-pc-launcher/dist/launcher | |
- name: List dist | |
shell: bash | |
run: ls -lR fujinet-pc-launcher/dist | |
# To preserve executable bit on files (GH artifacts are automatically zipped and executable bit is lost) | |
- name: 'Tar dist files' | |
shell: bash | |
working-directory: fujinet-pc-launcher/dist | |
run: | | |
tar -czf ../fujinet-pc-bundle_${{ steps.version.outputs.release }}_${{ matrix.target }}.tgz * | |
- name: Upload build artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: fujinet-pc-bundle_${{ steps.version.outputs.release }}_${{ matrix.target }} | |
path: fujinet-pc-launcher/fujinet-pc-bundle_${{ steps.version.outputs.release }}_${{ matrix.target }}.tgz | |
release: | |
if: ${{ github.event.inputs.releaseBuild == 'true' && github.event.inputs.doRelease == 'true'}} | |
# Create release | |
runs-on: ubuntu-latest | |
name: Release | |
needs: [scripts, build] | |
steps: | |
- name: Download build artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
path: release | |
- name: Display structure of downloaded files | |
run: ls -lR release | |
- name: 'Zip release files (scripts and windows)' | |
working-directory: release | |
run: | | |
for D in fujinet-pc-scripts_* | |
do | |
zip -r ${D}.zip $D | |
tar -czvf ${D}.tar.gz $D | |
done | |
for D in fujinet-pc-bundle_*windows* | |
do | |
( | |
cd $D | |
F=(fujinet-pc-bundle_*.tgz) | |
mkdir dist | |
tar -xzvf $F -C dist | |
rm -f $F | |
cd dist | |
zip -r ../${F%.*}.zip * | |
) | |
done | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
name: "FujiNet-PC Launcher ${{ needs.scripts.outputs.release_version }}" | |
tag_name: release-${{ needs.scripts.outputs.release_version }} | |
draft: ${{ github.event.inputs.draftRelease }} | |
files: | | |
release/fujinet-pc-scripts_*.tar.gz | |
release/fujinet-pc-scripts_*.zip | |
release/fujinet-pc-bundle_*/fujinet-pc-bundle_*.tgz | |
release/fujinet-pc-bundle_*/fujinet-pc-bundle_*.zip |