Skip to content

Commit

Permalink
Fix build scripts and github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
justin025 committed Nov 22, 2024
1 parent 9d247ce commit 37c74bb
Show file tree
Hide file tree
Showing 7 changed files with 571 additions and 473 deletions.
133 changes: 110 additions & 23 deletions .github/workflows/release-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,25 @@ on:
types: [published]

jobs:
# Windows Build
windows-build:
runs-on: windows-latest
windows-x86_64-build:
runs-on: [windows-latest, x64]
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: '3.12'

- name: Run Windows Build Script
run: scripts\build_windows.bat
shell: cmd

- name: Upload Windows Executable
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: OnTheSpot.exe
name: OnTheSpot-x86_64.exe
path: dist/OnTheSpot.exe

- name: Upload to Release (Windows)
Expand All @@ -41,12 +40,43 @@ jobs:
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: dist/OnTheSpot.exe
asset_name: OnTheSpot.exe
asset_name: OnTheSpot-x86_64.exe
asset_content_type: application/octet-stream

# Linux Build
linux-build:
runs-on: ubuntu-latest
windows-arm64-build:
runs-on: [windows-latest, x64]
steps:
- name: Checkout Repository
uses: actions/checkout@v4

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

- name: Run Windows Build Script
run: scripts\build_windows.bat
shell: cmd

- name: Upload Windows Executable
uses: actions/upload-artifact@v4
with:
name: OnTheSpot-arm64.exe
path: dist/OnTheSpot.exe

- name: Upload to Release (Windows)
if: github.event_name == 'release'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: dist/OnTheSpot.exe
asset_name: OnTheSpot-arm64.exe
asset_content_type: application/octet-stream

linux-x86_64-build:
runs-on: [ubuntu-latest, x64]
steps:
- name: Checkout Repository
uses: actions/checkout@v4
Expand All @@ -61,9 +91,9 @@ jobs:
shell: bash

- name: Upload Linux Executable
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: OnTheSpot.tar.gz
name: OnTheSpot-x86_64.tar.gz
path: dist/OnTheSpot.tar.gz

- name: Upload to Release (Linux)
Expand All @@ -74,12 +104,70 @@ jobs:
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: dist/OnTheSpot.tar.gz
asset_name: OnTheSpot.tar.gz
asset_name: OnTheSpot-x86_64.tar.gz
asset_content_type: application/gzip

# macOS Build
macos-build:
runs-on: macos-latest
linux-arm64-build:
runs-on: [ubuntu-latest, ARM64]
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y patchelf fuse libfuse2 wget
- name: Run Linux Build Script
run: scripts/build_linux.sh
shell: bash

- name: Upload Linux Executable
uses: actions/upload-artifact@v4
with:
name: OnTheSpot-arm64.tar.gz
path: dist/OnTheSpot.tar.gz

- name: Upload to Release (Linux)
if: github.event_name == 'release'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: dist/OnTheSpot.tar.gz
asset_name: OnTheSpot-arm64.tar.gz
asset_content_type: application/gzip

macos-x86_64-build:
runs-on: [macos-12, x64]
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Run macOS Build Script
run: scripts/build_mac.sh
shell: bash

- name: Upload macOS DMG
uses: actions/upload-artifact@v4
with:
name: OnTheSpot-x86_64.dmg
path: dist/OnTheSpot.dmg

- name: Upload to Release (macOS)
if: github.event_name == 'release'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: dist/OnTheSpot.dmg
asset_name: OnTheSpot-x86_64.dmg
asset_content_type: application/x-apple-diskimage

macos-arm64-build:
runs-on: [macos-latest, ARM64]
steps:
- name: Checkout Repository
uses: actions/checkout@v4
Expand All @@ -89,9 +177,9 @@ jobs:
shell: bash

- name: Upload macOS DMG
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: OnTheSpot.dmg
name: OnTheSpot-arm64.dmg
path: dist/OnTheSpot.dmg

- name: Upload to Release (macOS)
Expand All @@ -102,12 +190,11 @@ jobs:
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: dist/OnTheSpot.dmg
asset_name: OnTheSpot.dmg
asset_name: OnTheSpot-arm64.dmg
asset_content_type: application/x-apple-diskimage

# AppImage Build
appimage-build:
runs-on: ubuntu-latest
appimage-x86_64-build:
runs-on: [ubuntu-latest, x64]
steps:
- name: Checkout Repository
uses: actions/checkout@v4
Expand All @@ -122,7 +209,7 @@ jobs:
shell: bash

- name: Upload AppImage Executable
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: OnTheSpot-x86_64.AppImage
path: dist/OnTheSpot-x86_64.AppImage
Expand Down
7 changes: 4 additions & 3 deletions scripts/build_appimage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ echo " => Fetch Dependencies"
mkdir build
cd build

wget https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage
curl -L -o appimagetool-x86_64.AppImage https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage
chmod +x appimagetool-x86_64.AppImage

wget https://github.com/niess/python-appimage/releases/download/python3.12/python3.12.7-cp312-cp312-manylinux2014_x86_64.AppImage -O python.AppImage
curl -L -o python.AppImage https://github.com/niess/python-appimage/releases/download/python3.12/python3.12.7-cp312-cp312-manylinux2014_x86_64.AppImage
chmod +x python.AppImage

./python.AppImage --appimage-extract
Expand All @@ -31,8 +31,9 @@ cd build/OnTheSpot.AppDir
./AppRun -m pip install -r ../../requirements.txt
./AppRun -m pip install ../../dist/onthespot-*-py3-none-any.whl

rm AppRun .DirIcon python.png python*.desktop
rm AppRun .DirIcon python.png python*.desktop usr/share/applications/python*.desktop
cp -t . ../../src/onthespot/resources/icons/onthespot.png ../../src/onthespot/resources/org.onthespot.OnTheSpot.desktop
cp ../../src/onthespot/resources/org.onthespot.OnTheSpot.desktop usr/share/applications/

echo '#! /bin/bash
HERE="$(dirname "$(readlink -f "${0}")")"
Expand Down
34 changes: 27 additions & 7 deletions scripts/build_mac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ echo "========= OnTheSpot macOS Build Script =========="


echo " => Cleaning up previous builds!"
rm -rf dist/onthespot_mac.app dist/onthespot_mac_ffm.app
rm -rf dist


echo " => Creating and activating virtual environment..."
Expand All @@ -19,7 +19,7 @@ venv/bin/pip install -r requirements.txt

echo " => Running PyInstaller to create .app package..."
mkdir build
wget https://evermeet.cx/ffmpeg/ffmpeg-7.1.zip -O build/ffmpeg.zip
curl -L -o build/ffmpeg.zip https://evermeet.cx/ffmpeg/ffmpeg-7.1.zip
unzip build/ffmpeg.zip -d build
pyinstaller --windowed \
--hidden-import="zeroconf._utils.ipaddress" \
Expand All @@ -34,17 +34,37 @@ pyinstaller --windowed \
--icon="src/onthespot/resources/icons/onthespot.png" \
src/portable.py


echo " => Setting executable permissions..."
chmod +x dist/OnTheSpot.app


echo " => Creating dmg..."
mkdir -p dist/OnTheSpot
mv dist/OnTheSpot.app dist/OnTheSpot/OnTheSpot.app
ln -s /Applications dist/OnTheSpot
hdiutil create -srcfolder dist/OnTheSpot -format UDZO -o dist/OnTheSpot.dmg
mkdir -p dist/dmg
mv dist/OnTheSpot.app dist/dmg/OnTheSpot.app
ln -s /Applications dist/dmg

echo "# Login Issues
Newer versions of macOS have restricted networking features
for apps inside the 'Applications' folder. To login to your
account you will need to:
1. Run the following command in terminal, 'echo \"127.0.0.1 \$HOST\" | sudo tee -a /etc/hosts'
2. Launch the app and click add account before dragging into the applications folder.
3. After successfully logging in you can drag the app into the folder.
# Security Issues
After all this, if you experience an error while trying to launch
the app you will need to open the 'Applications' folder, right-click
the app, and click open anyway." > dist/dmg/readme.txt

hdiutil create -srcfolder dist/dmg -format UDZO -o dist/OnTheSpot.dmg


echo " => Cleaning up temporary files..."
rm -rf __pycache__ build venv *.spec

echo " => Done! .dmg available in 'dist/OnTheSpot.dmg'."
echo " => Done! .dmg available in 'dist/OnTheSpot.dmg'."
3 changes: 1 addition & 2 deletions scripts/build_windows.bat
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ powershell -Command "Expand-Archive -Path build\ffmpeg.zip -DestinationPath buil

echo =^> Running PyInstaller to create .exe package...
pyinstaller --onefile --noconsole --noconfirm ^
--hidden-import="onthespot.post_download" ^
--hidden-import="zeroconf._utils.ipaddress" ^
--hidden-import="zeroconf._handlers.answers" ^
--add-data="src/onthespot/resources/translations/*.qm;onthespot/resources/translations" ^
Expand All @@ -54,4 +53,4 @@ del /F /Q *.spec
rmdir /s /q build __pycache__ ffbin_win venvwin


echo =^> Done! Executable available as 'dist/OnTheSpot.exe'.
echo =^> Done! Executable available as 'dist/OnTheSpot.exe'.
3 changes: 1 addition & 2 deletions src/onthespot/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
from librespot.metadata import TrackId, EpisodeId
from .runtimedata import get_logger, download_queue, download_queue_lock, account_pool
from .otsconfig import config
from .post_download import convert_audio_format, embed_metadata, set_music_thumbnail, fix_mp3_metadata, add_to_m3u_file, strip_metadata
from .utils import sanitize_data, format_track_path, convert_audio_format, embed_metadata, set_music_thumbnail, fix_mp3_metadata, add_to_m3u_file, strip_metadata
from .api.spotify import spotify_get_token, spotify_get_track_metadata, spotify_get_episode_metadata, spotify_get_lyrics
from .api.soundcloud import soundcloud_get_token, soundcloud_get_track_metadata
from .api.deezer import deezer_get_track_metadata, get_song_info_from_deezer_website, genurlkey, calcbfkey, decryptfile
from .accounts import get_account_token
from .utils import sanitize_data, format_track_path

logger = get_logger("downloader")

Expand Down
Loading

0 comments on commit 37c74bb

Please sign in to comment.