Update qmods.yml #2
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
# Simple workflow for deploying static content to GitHub Pages | |
name: Build and deploy qmods | |
on: | |
# Runs on pushes targeting the default branch | |
push: | |
branches: ["main"] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. | |
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. | |
concurrency: | |
group: "pages" | |
cancel-in-progress: true | |
jobs: | |
# Single deploy job since we're just deploying | |
deploy: | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Pages | |
uses: actions/configure-pages@v5 | |
- name: Build Core Qmods | |
env: | |
CORE_JSON: "core_mods.json" | |
DEPLOY_PATH: "qmods" | |
run: | | |
mkdir -p "$DEPLOY_PATH" | |
echo "<html><head><title>Beat Saber Core Mods</title></head><body><ul>" >> "$DEPLOY_PATH/index.html" | |
versionGreaterThan() { | |
local version1="$1" | |
local version2="$2" | |
if [[ $(printf "%s\n%s" "$version1" "$version2" | sort -V | head -n 1) != "$version1" ]]; then | |
return 0 | |
else | |
return 1 | |
fi | |
} | |
jq -r 'keys[]' "$CORE_JSON" | while read game_version; do | |
MODLOADER="QuestLoader" | |
if versionGreaterThan "$game_version" "1.28.0_4124311467"; then | |
MODLOADER="Scotland2" | |
fi | |
MOD=" | |
{ | |
\"_QPVersion\": \"0.1.1\", | |
\"name\": \"Core mods for $game_version\", | |
\"id\": \"OculusDB_CoreMods_$game_version\", | |
\"author\": \"OculusDB\", | |
\"description\": \"Downloads all Core mods for Beat Saber version $game_version\", | |
\"version\": \"1.0.0\", | |
\"packageId\": \"com.beatgames.beatsaber\", | |
\"packageVersion\": \"$game_version\", | |
\"modloader\": \"$MODLOADER\", | |
\"modFiles\": [], | |
\"libraryFiles\": [], | |
\"fileCopies\": [], | |
\"copyExtensions\": [], | |
\"dependencies\": [] | |
} | |
" | |
last_updated="$(jq -r --arg version "$game_version" '.[$version].lastUpdated' "$CORE_JSON")" | |
mod_count="$(jq -r --arg version "$game_version" '.[$version].mods | length' "$CORE_JSON")" | |
for (( i=0; i < $mod_count; i++ )); do | |
mod="$(jq -r --arg version "$game_version" --argjson index "$i" '.[$version].mods[$index]' "$CORE_JSON")" | |
mod_id=$(echo "$mod" | jq -r '.id') | |
mod_version=$(echo "$mod" | jq -r '.version') | |
mod_download_link=$(echo "$mod" | jq -r '.downloadLink') | |
dependency="$(jq -n \ | |
--arg id "$mod_id" \ | |
--arg version "^$mod_version" \ | |
--arg downloadIfMissing "$mod_download_link" \ | |
'{id: $id, version: $version, downloadIfMissing: $downloadIfMissing}')" | |
MOD="$(echo "$MOD" | jq --argjson new_object "$dependency" '.dependencies += [$new_object]')" | |
done | |
echo "$MOD" > mod.json | |
zip "$DEPLOY_PATH/$game_version.qmod" mod.json | |
echo "<li><a href=\"$game_version.qmod\">$game_version.qmod</a></li>" >> "$DEPLOY_PATH/index.html" | |
rm mod.json | |
done | |
echo "</ul></body></html>" >> "$DEPLOY_PATH/index.html" | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
# Upload entire repository | |
path: 'qmods' | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 |