Skip to content

Refactor t_phazor.py to put classes in root of the module #113

Refactor t_phazor.py to put classes in root of the module

Refactor t_phazor.py to put classes in root of the module #113

name: Build and release
on:
push:
pull_request:
jobs:
build-linux:
runs-on: ubuntu-24.04
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
submodules: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Install deps
run: |
sudo apt-get update
sudo apt-get install -y \
gettext \
gobject-introspection \
gir1.2-rsvg-2.0 \
kde-config-gtk-style \
libcanberra-gtk3-module \
libgirepository1.0-dev \
python3-gi-cairo \
libayatana-appindicator3-dev \
libcairo2-dev \
libpipewire-0.3-dev \
libdbus-1-dev \
libjxl-dev \
libflac-dev \
libgme-dev \
libmpg123-dev \
libopenmpt-dev \
libopusfile-dev \
libsamplerate0-dev \
libvorbis-dev \
libwavpack-dev \
p7zip
# JPEG-XL hack since 24.04 is too old
sudo apt-get install -y \
libgif7 \
wget
wget http://mirrors.kernel.org/ubuntu/pool/universe/j/jpeg-xl/libjxl-dev_0.10.3-4ubuntu1_amd64.deb
wget http://mirrors.kernel.org/ubuntu/pool/universe/j/jpeg-xl/libjxl0.10_0.10.3-4ubuntu1_amd64.deb
wget http://mirrors.kernel.org/ubuntu/pool/universe/h/highway/libhwy-dev_1.2.0-3ubuntu2_amd64.deb
wget http://mirrors.kernel.org/ubuntu/pool/universe/h/highway/libhwy1t64_1.2.0-3ubuntu2_amd64.deb
wget http://mirrors.kernel.org/ubuntu/pool/main/l/lcms2/liblcms2-dev_2.14-2build1_amd64.deb
sudo dpkg -i *.deb
# libsdl2-image-dev \
- name: Install Python dependencies and setup venv
run: |
python -m pip install --upgrade pip
python -m venv .venv
source .venv/bin/activate
pip install \
-r requirements.txt \
build \
pyinstaller
- name: Build the project using python-build
run: |
source .venv/bin/activate
python -m compile_translations
python -m build --wheel
- name: Install the project into a venv
run: |
source .venv/bin/activate
pip install --prefix ".venv" dist/*.whl
- name: "[DEBUG] List all files"
run: find .
- name: Build Linux App with PyInstaller
run: |
source .venv/bin/activate
pyinstaller --log-level=DEBUG linux.spec
- name: Create 7Z
run: |
APP_NAME="TauonMusicBox"
cd "dist/${APP_NAME}"
ARCHIVE_PATH="../../${APP_NAME}.7z"
7z a -r "${ARCHIVE_PATH}" "."
- name: Upload 7Z artifact
uses: actions/upload-artifact@v4
with:
name: TauonMusicBox-linux
path: TauonMusicBox.7z
build-macos:
runs-on: macos-latest
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
submodules: true
# - name: Set up Python
# uses: actions/setup-python@v5
# with:
# python-version: '3.13'
- name: brew update and upgrade
run: brew update && brew upgrade
- name: Install brew dependencies
run: |
brew install \
gobject-introspection \
gtk+3 \
pango \
pillow \
sdl3 \
sdl3_image \
jpeg-xl \
ffmpeg \
librsvg \
opusfile \
libopenmpt \
wavpack \
game-music-emu
# This generates 30MB of logs, enable it only when actively debugging something
# - name: "[DEBUG] List all Cellar files"
# run: find /opt/homebrew/Cellar
- name: Install Python dependencies and setup venv
run: |
export CXXFLAGS="-I/opt/homebrew/include"
export LDFLAGS="-L/opt/homebrew/lib"
$(brew --prefix python)/libexec/bin/python -m pip install --break-system-packages --upgrade pip
$(brew --prefix python)/libexec/bin/pip install --break-system-packages \
-r requirements.txt \
build \
pyinstaller
# $(brew --prefix python)/libexec/bin/pip install --break-system-packages https://github.com/pyinstaller/pyinstaller/archive/develop.zip
# $(brew --prefix python)/libexec/bin/python -m venv --system-site-packages .venv
# source .venv/bin/activate
# CFLAGS: "-I/opt/homebrew/include"
- name: Build the project using python-build
run: |
$(brew --prefix python)/libexec/bin/python -m compile_translations
$(brew --prefix python)/libexec/bin/python -m build --wheel
# source .venv/bin/activate
- name: Install the project into a venv
run: |
$(brew --prefix python)/libexec/bin/pip install --prefix ".venv" dist/*.whl
# $(brew --prefix python)/libexec/bin/pip install --break-system-packages dist/*.whl
# source .venv/bin/activate
- name: "[DEBUG] List all files"
run: find .
- name: Build macOS app with PyInstaller
run: |
pyinstaller --log-level=DEBUG mac.spec
# source .venv/bin/activate
env:
DYLD_LIBRARY_PATH: "/opt/homebrew/lib"
- name: "[DEBUG] List all files in .app"
run: find "dist/TauonMusicBox.app"
- name: Create DMG
run: |
mkdir -p dist/dmg
APP_NAME="TauonMusicBox"
APP_PATH="dist/${APP_NAME}.app"
DMG_PATH="dist/dmg/${APP_NAME}.dmg"
# Create a .dmg package
hdiutil create -volname "$APP_NAME" -srcfolder "$APP_PATH" -ov -format UDZO "$DMG_PATH"
- name: Upload DMG artifact
uses: actions/upload-artifact@v4
with:
name: TauonMusicBox-dmg
path: dist/dmg/TauonMusicBox.dmg
# - name: Run Tauon for testing
# run: |
# hdiutil attach dist/dmg/TauonMusicBox.dmg
# /Volumes/TauonMusicBox/TauonMusicBox.app/Contents/MacOS/Tauon\ Music\ Box
build-windows:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: true
# TODO(Martin): p7zip should be 7zip but MINGW64 hasn't updated at the time of writing, try switching it later
- name: Read Package List
id: read_packages
run: |
$packages = Get-Content extra/msyspac.txt -Raw | Out-String
$packages = $packages -replace "`r`n", " " -replace "`n", " "
$packages = $packages.Trim() + " p7zip"
echo "packages=$packages" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8
- name: Set up MSYS2 MinGW-W64
uses: msys2/setup-msys2@v2
with:
msystem: mingw64
update: true
install: ${{ env.packages }}
# ca-certificates
# mingw-w64-x86_64-python-zeroconf
# mingw-w64-x86_64-zlib
- name: Update CA trust and hack opusfile
shell: msys2 {0}
run: |
update-ca-trust
# https://github.com/xiph/opusfile/pull/47
sed -i 's,<opus_multistream.h>,<opus/opus_multistream.h>,' /mingw64/include/opus/opusfile.h
- name: Install Python dependencies and setup venv
shell: msys2 {0}
run: |
python -m pip install --break-system-packages --upgrade pip
python -m venv .venv
export CFLAGS="-I/mingw64/include"
export PIP_FIND_LINKS=https://github.com/ddelange/python-magic/releases/expanded_assets/0.4.28.post8
.venv/bin/python -m pip install \
-r requirements.txt \
build \
pyinstaller
# export PIP_FIND_LINKS=https://github.com/ddelange/python-magic/releases/expanded_assets/0.4.28.post8
- name: Build the project using python-build
shell: msys2 {0}
run: |
source .venv/bin/activate
python -m compile_translations
python -m build --wheel
- name: Install the project into a venv
shell: msys2 {0}
run: |
source .venv/bin/activate
pip install --prefix ".venv" dist/*.whl
# https://github.com/Taiko2k/Tauon/pull/931#issuecomment-1464880133
- name: Download optionals from latest release files and notofonts' GitHub
shell: msys2 {0}
run: |
curl -L -o librespot.exe https://github.com/Taiko2k/Tauon/releases/download/v7.8.3/librespot.exe # v0.6.0 - https://github.com/librespot-org/librespot/releases
curl -L -o TaskbarLib.tlb https://github.com/Taiko2k/Tauon/releases/download/v7.8.3/TaskbarLib.tlb
curl -L -o TauonSMTC.dll https://github.com/Taiko2k/Tauon/releases/download/v7.8.3/TauonSMTC.dll
mkdir fonts
curl -L -o fonts/NotoSans-ExtraCondensed.ttf https://github.com/notofonts/notofonts.github.io/raw/refs/heads/main/fonts/NotoSans/full/ttf/NotoSans-ExtraCondensed.ttf # 800KB
curl -L -o fonts/NotoSans-ExtraCondensedBold.ttf https://github.com/notofonts/notofonts.github.io/raw/refs/heads/main/fonts/NotoSans/full/ttf/NotoSans-ExtraCondensedBold.ttf # 800KB
curl -L -o fonts/NotoSans-Bold.ttf https://github.com/notofonts/notofonts.github.io/raw/refs/heads/main/fonts/NotoSans/full/ttf/NotoSans-Bold.ttf # 800KB
curl -L -o fonts/NotoSans-Medium.ttf https://github.com/notofonts/notofonts.github.io/raw/refs/heads/main/fonts/NotoSans/full/ttf/NotoSans-Medium.ttf # 800KB
curl -L -o fonts/NotoSans-Regular.ttf https://github.com/notofonts/notofonts.github.io/raw/refs/heads/main/fonts/NotoSans/full/ttf/NotoSans-Regular.ttf # 800KB
curl -L -o fonts/NotoSansCJKjp-Bold.otf https://github.com/notofonts/noto-cjk/raw/refs/heads/main/Sans/OTF/Japanese/NotoSansCJKjp-Bold.otf # 16MB
curl -L -o fonts/NotoSansCJKjp-Medium.otf https://github.com/notofonts/noto-cjk/raw/refs/heads/main/Sans/OTF/Japanese/NotoSansCJKjp-Medium.otf # 16MB
curl -L -o fonts/NotoSansCJKjp-Regular.otf https://github.com/notofonts/noto-cjk/raw/refs/heads/main/Sans/OTF/Japanese/NotoSansCJKjp-Regular.otf # 16MB
- name: "[DEBUG] List all files"
shell: msys2 {0}
run: find .
- name: Build Windows App with PyInstaller
shell: msys2 {0}
run: |
source .venv/bin/activate
pyinstaller --log-level=DEBUG windows.spec
- name: Create 7Z
shell: msys2 {0}
run: |
APP_NAME="TauonMusicBox"
cd "dist/${APP_NAME}"
ARCHIVE_PATH="../../${APP_NAME}.7z"
7z a -r "${ARCHIVE_PATH}" "."
# - name: "[DEBUG] List all files after pyinstaller"
# shell: msys2 {0}
# run: find .
- name: Upload 7Z artifact
uses: actions/upload-artifact@v4
with:
name: TauonMusicBox-windows
path: TauonMusicBox.7z
- name: Replace Tauon version in .ISS
run: |
sed -i 's|{{ tauon_version }}|8.0.0|g' extra/setup.iss
- name: Compile .ISS to .EXE Installer
uses: Minionguyjpro/[email protected]
with:
path: extra/setup.iss
options: /O+
# - name: "[DEBUG] List all files after Inno"
# shell: msys2 {0}
# run: find .
- name: Upload EXE installer
uses: actions/upload-artifact@v4
with:
name: TauonMusicBox-windows-installer
path: extra/Output/tauonsetup-8.0.0.exe
get-info:
runs-on: ubuntu-24.04
outputs:
date: ${{ steps.vars.outputs.date }}
shorthash: ${{ steps.vars.outputs.shorthash }}
fullhash: ${{ steps.vars.outputs.fullhash }}
steps:
- uses: actions/checkout@v4
- name: Get date and git hash
id: vars
run: |
echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
echo "shorthash=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
echo "fullhash=$(git rev-parse HEAD)" >> $GITHUB_ENV
echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
echo "shorthash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "fullhash=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
pre-release:
if: github.ref == 'refs/heads/master' && github.repository == 'Taiko2k/Tauon' && github.event_name == 'push'
needs: [get-info, build-linux, build-windows, build-macos]
runs-on: ubuntu-24.04
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: ~/artifacts
- name: Compress individual directories (without parent directory)
run: |
cd ~/artifacts
for dir in */; do
if [ -d "$dir" ]; then
dir_name=${dir%/}
echo "Creating zip for $dir_name"
(cd "$dir_name" && zip -r "../${dir_name}.zip" .)
fi
done
- name: Get latest release information
id: get_latest_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
api_url="https://api.github.com/repos/${{ github.repository }}"
latest_release_info=$(curl -H "Authorization: token $GITHUB_TOKEN" "$api_url/releases/latest")
echo "last_release_tag=$(echo "$latest_release_info" | jq -r '.tag_name')" >> $GITHUB_ENV
- name: Checkout the repository
uses: actions/checkout@v4
- name: Process template release_body.md
run: |
sed -i 's|RELEASE_TAG|Pre-release-Tauon-${{ needs.get-info.outputs.date }}-${{ needs.get-info.outputs.shorthash }}|g' ${{ github.workspace }}/.github/release_body.md
- name: Create Pre-Release on GitHub
id: create_release
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: "Pre-release-Tauon-${{ needs.get-info.outputs.date }}-${{ needs.get-info.outputs.shorthash }}"
tag: "Pre-release-Tauon-${{ needs.get-info.outputs.date }}-${{ needs.get-info.outputs.shorthash }}"
draft: false
prerelease: true
# body: "Full Changelog: [${{ env.last_release_tag }}...${{ needs.get-info.outputs.shorthash }}](https://github.com/Taiko2k/Tauon/compare/${{ env.last_release_tag }}...${{ needs.get-info.outputs.fullhash }})"
bodyFile: ${{ github.workspace }}/.github/release_body.md
artifacts: ~/artifacts/*.zip
- name: Publish to Release Repository
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
ARTIFACTS_DIR=~/artifacts
REPO_WINDOWS="Taiko2k/Tauon"
REPO_LINUX="Taiko2k/Tauon"
REPO_MAC="Taiko2k/Tauon"
for file in "$ARTIFACTS_DIR"/*.zip; do
filename=$(basename "$file")
REPO=""
# Determine repository based on file name
if [[ "$filename" == *"windows"* ]]; then
REPO=$REPO_WINDOWS
elif [[ "$filename" == *"linux"* ]]; then
REPO=$REPO_LINUX
elif [[ "$filename" == *"macos"* ]]; then
REPO=$REPO_MAC
fi
# If REPO is empty, skip file
if [[ -z "$REPO" ]]; then
echo "No matching repository for $filename"
continue
fi
# Check if release already exists and get ID
release_id=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/$REPO/releases/tags/Pre-release-Tauon-${{ needs.get-info.outputs.date }}-${{ needs.get-info.outputs.shorthash }}" | jq -r '.id')
if [[ "$release_id" == "null" ]]; then
echo "Creating release in $REPO for $filename"
release_id=$(curl -s -X POST -H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
-d '{
"tag_name": "Pre-release-Tauon-${{ needs.get-info.outputs.date }}-${{ needs.get-info.outputs.shorthash }}",
"name": "Pre-release-Tauon-${{ needs.get-info.outputs.date }}-${{ needs.get-info.outputs.shorthash }}",
"draft": false,
"prerelease": true,
"body": "Commit: [${{ needs.get-info.outputs.fullhash }}](https://github.com/Taiko2k/Tauon/commit/${{ needs.get-info.outputs.fullhash }})"
}' "https://api.github.com/repos/$REPO/releases" | jq -r '.id')
else
echo "Release already exists in $REPO with ID $release_id"
fi
# Artifact upload
echo "Uploading $filename to release $release_id in $REPO"
upload_url="https://uploads.github.com/repos/$REPO/releases/$release_id/assets?name=$filename"
curl -X POST -H "Authorization: token $GITHUB_TOKEN" -H "Content-Type: application/octet-stream" --data-binary @"$file" "$upload_url"
done
- name: Get current pre-release information
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
api_url="https://api.github.com/repos/${{ github.repository }}/releases"
# Get all releases (sorted by date)
releases=$(curl -H "Authorization: token $GITHUB_TOKEN" "$api_url")
# Capture the most recent pre-release (assuming the first one is the latest)
current_release=$(echo "$releases" | jq -c '.[] | select(.prerelease == true) | .published_at' | sort -r | head -n 1)
# Remove extra quotes from captured date
current_release=$(echo $current_release | tr -d '"')
# Export the current published_at to be available for the next step
echo "CURRENT_PUBLISHED_AT=$current_release" >> $GITHUB_ENV
- name: Delete old pre-releases and tags
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
api_url="https://api.github.com/repos/${{ github.repository }}/releases"
# Get current pre-releases
releases=$(curl -H "Authorization: token $GITHUB_TOKEN" "$api_url")
# Remove extra quotes from captured date
CURRENT_PUBLISHED_AT=$(echo $CURRENT_PUBLISHED_AT | tr -d '"')
# Convert CURRENT_PUBLISHED_AT para timestamp Unix
current_published_ts=$(date -d "$CURRENT_PUBLISHED_AT" +%s)
# Identify pre-releases
echo "$releases" | jq -c '.[] | select(.prerelease == true)' | while read -r release; do
release_date=$(echo "$release" | jq -r '.published_at')
release_id=$(echo "$release" | jq -r '.id')
release_tag=$(echo "$release" | jq -r '.tag_name')
# Remove extra quotes from captured date
release_date=$(echo $release_date | tr -d '"')
# Convert release_date para timestamp Unix
release_date_ts=$(date -d "$release_date" +%s)
# Compare timestamps and delete old pre-releases
if [[ "$release_date_ts" -lt "$current_published_ts" ]]; then
echo "Deleting old pre-release: $release_id from $release_date with tag: $release_tag"
# Delete the pre-release
curl -X DELETE -H "Authorization: token $GITHUB_TOKEN" "$api_url/$release_id"
# Delete the tag
curl -X DELETE -H "Authorization: token $GITHUB_TOKEN" "https://api.github.com/repos/${{ github.repository }}/git/refs/tags/$release_tag"
else
echo "Skipping pre-release: $release_id (newer or same date)"
fi
done