Move natsort and opencc to Tauon, move more imports to top #839
This file contains hidden or 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 and release | |
on: | |
push: | |
pull_request: | |
jobs: | |
build-linux: | |
name: "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 \ | |
gir1.2-notify-0.7 \ | |
gir1.2-girepository-3.0-dev \ | |
kde-config-gtk-style \ | |
libcanberra-gtk3-module \ | |
libgirepository1.0-dev \ | |
libgirepository-2.0-dev \ | |
libglib2.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 | |
python -c "import sdl3" | |
# https://github.com/pyinstaller/pyinstaller/archive/develop.zip | |
- 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 | |
#- name: Run Tauon for testing | |
# run: | | |
# source .venv/bin/activate | |
# tauonmb | |
build-flatpak: | |
name: "Flatpak" | |
runs-on: ubuntu-24.04 | |
container: | |
image: bilelmoussaoui/flatpak-github-actions:freedesktop-24.08 | |
options: --privileged | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Download jq | |
run: | | |
mkdir -p $HOME/bin | |
curl -Lo $HOME/bin/jq https://github.com/stedolan/jq/releases/latest/download/jq-linux64 | |
chmod +x $HOME/bin/jq | |
echo "$HOME/bin" >> $GITHUB_PATH | |
- name: Install rustup | |
run: | | |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | |
- name: Run rustup | |
run: | | |
. "$HOME/.cargo/env" | |
rustup toolchain install stable | |
- name: Clone Flatpak repo | |
run: | | |
git clone --recurse-submodules https://github.com/flathub/com.github.taiko2k.tauonmb.git tauon-flatpak | |
# cd tauon-flatpak; git checkout tekoreless | |
- name: "[DEBUG] List all files" | |
run: find . | |
- name: Get repository and commit info | |
run: | | |
REPO_URL="https://github.com/${{ github.repository }}.git" | |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then | |
COMMIT_SHA="${{ github.event.pull_request.head.sha }}" | |
else | |
COMMIT_SHA="${{ github.sha }}" | |
fi | |
echo "Repository URL: $REPO_URL" | |
echo "Commit SHA: $COMMIT_SHA" | |
# Modify JSON file | |
jq --arg repo "$REPO_URL" --arg commit "$COMMIT_SHA" ' | |
(.modules[] | select(type == "object" and .name == "tauonmb-git").sources[] | select(.type == "git")) |= {type: "git", url: $repo, commit: $commit} | |
' tauon-flatpak/com.github.taiko2k.tauonmb.json > updated.json | |
mv updated.json tauon-flatpak/com.github.taiko2k.tauonmb.json | |
- name: Verify JSON changes | |
run: cat tauon-flatpak/com.github.taiko2k.tauonmb.json | |
# https://github.com/marketplace/actions/flatpak-builder | |
- name: Build Flatpak | |
uses: flatpak/flatpak-github-actions/[email protected] | |
with: | |
bundle: tauonmb.flatpak | |
manifest-path: tauon-flatpak/com.github.taiko2k.tauonmb.json | |
cache-key: flatpak-builder-${{ github.sha }} | |
build-macos: | |
name: "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/pip install --break-system-packages \ | |
-r requirements.txt \ | |
build \ | |
pyinstaller | |
# https://github.com/pyinstaller/pyinstaller/archive/develop.zip | |
# $(brew --prefix python)/libexec/bin/python -m pip install --break-system-packages --upgrade pip | |
# $(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 | |
# FIXME: Undo this overengineered crap once the following issue gets figured out: | |
# https://github.com/actions/runner-images/issues/7522 | |
i=0 | |
until hdiutil create -volname "${APP_NAME}" -srcfolder "${APP_PATH}" -ov -format UDZO "${DMG_PATH}"; do | |
if [[ ${i} -eq 10 ]]; then | |
echo "Error: hdiutil did not succeed even after 10 tries." | |
exit 1 | |
fi | |
i=$((i+1)) | |
done | |
- 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-macos-x64: | |
name: "macOS_x64" | |
runs-on: macos-13 | |
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 with a workaround for https://github.com/actions/runner-images/issues/9966 | |
run: | | |
brew update | |
brew unlink [email protected] | |
brew unlink [email protected] | |
brew link --overwrite [email protected] | |
brew link --overwrite [email protected] | |
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 | |
- name: Hack opusfile - https://github.com/xiph/opusfile/pull/47 | |
run: | | |
sed 's,<opus_multistream.h>,<opus/opus_multistream.h>,' /usr/local/include/opus/opusfile.h > /tmp/opusfile.h | |
sudo mv /tmp/opusfile.h /usr/local/include/opus/opusfile.h | |
# 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/pip install --user --break-system-packages \ | |
-r requirements.txt \ | |
build | |
$(brew --prefix python)/libexec/bin/pip install --break-system-packages \ | |
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 pip install --break-system-packages --upgrade pip | |
# $(brew --prefix python)/libexec/bin/python -m pip show -f pyinstaller | |
# $(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}-x64.dmg" | |
# Create a .dmg package | |
# FIXME: Undo this overengineered crap once the following issue gets figured out: | |
# https://github.com/actions/runner-images/issues/7522 | |
i=0 | |
until hdiutil create -volname "${APP_NAME}" -srcfolder "${APP_PATH}" -ov -format UDZO "${DMG_PATH}"; do | |
if [[ ${i} -eq 10 ]]; then | |
echo "Error: hdiutil did not succeed even after 10 tries." | |
exit 1 | |
fi | |
i=$((i+1)) | |
done | |
- name: Upload DMG artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: TauonMusicBox-x64-dmg | |
path: dist/dmg/TauonMusicBox-x64.dmg | |
build-windows: | |
name: "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 }} | |
- name: Update CA trust and hack opusfile - https://github.com/xiph/opusfile/pull/47 | |
shell: msys2 {0} | |
run: | | |
update-ca-trust | |
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 | |
# https://github.com/pyinstaller/pyinstaller/archive/develop.zip | |
# 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.1.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.1.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-flatpak, build-windows, build-macos, build-macos-x64] | |
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="Taiko2k/Tauon" | |
for file in "$ARTIFACTS_DIR"/*.zip; do | |
filename=$(basename "$file") | |
# 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 |