Compare commits
49 Commits
gitea-sync
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4a762b51bb | ||
|
|
cb9ee8ec86 | ||
|
|
84b0a62f26 | ||
|
|
ae3137cef1 | ||
|
|
6ef2df7891 | ||
|
|
446264ddf4 | ||
|
|
944b73fc9e | ||
|
|
ddfb2f3a2e | ||
|
|
e0348c089c | ||
|
|
8def57cfd9 | ||
|
|
904b99f0b9 | ||
|
|
07996c3952 | ||
|
|
643d5e9ea2 | ||
|
|
5d9a8d0728 | ||
|
|
75d93ace0d | ||
|
|
86cc19928d | ||
|
|
1a94942cf5 | ||
|
|
e0e9106b14 | ||
|
|
ab8e03ce57 | ||
|
|
4de4a2fcb2 | ||
|
|
4719842ddb | ||
|
|
138c3d9c5c | ||
|
|
65071a5963 | ||
|
|
41cf13cf53 | ||
|
|
65b5f239f9 | ||
|
|
e4835460be | ||
|
|
962855dd70 | ||
|
|
f5395bbd99 | ||
|
|
b7e8694b42 | ||
| aeea64ac34 | |||
|
|
50c7b5cfb5 | ||
| 9296535bc2 | |||
| 1685214f56 | |||
| 1134e33248 | |||
| 9fddbfe53d | |||
| 3e34aa18ee | |||
| 605bd684ea | |||
| 936273edba | |||
| 5c7b766589 | |||
| fd7cc5fae8 | |||
| 7c96d78c5f | |||
| dfed9b9793 | |||
| a59331b191 | |||
| f00eeea001 | |||
| add398cf30 | |||
| 1a6cdb7a46 | |||
| 9d0f0dd20c | |||
| cbb2b200d9 | |||
| 3aabfeb826 |
5
.github/scripts/requirements.lock
vendored
@@ -1,5 +0,0 @@
|
||||
certifi==2025.4.26
|
||||
charset-normalizer==3.4.2
|
||||
idna==3.10
|
||||
requests==2.32.3
|
||||
urllib3==2.4.0
|
||||
1
.github/scripts/requirements.txt
vendored
@@ -1 +0,0 @@
|
||||
requests
|
||||
291
.github/scripts/update_mod_versions.py
vendored
@@ -1,291 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
import time
|
||||
from datetime import datetime
|
||||
from enum import Enum
|
||||
from pathlib import Path
|
||||
|
||||
import requests
|
||||
|
||||
# GitHub API rate limits are higher with authentication
|
||||
GITHUB_TOKEN = os.environ.get('GITHUB_TOKEN')
|
||||
HEADERS = {'Authorization': f'token {GITHUB_TOKEN}'} if GITHUB_TOKEN else {}
|
||||
|
||||
TIME_NOW = int(time.time())
|
||||
|
||||
def extract_repo_info(repo_url):
|
||||
"""Extract owner and repo name from GitHub repo URL."""
|
||||
match = re.search(r'github\.com/([^/]+)/([^/]+)', repo_url)
|
||||
if match:
|
||||
owner = match.group(1)
|
||||
repo = match.group(2)
|
||||
# Remove .git suffix if present
|
||||
repo = repo.removesuffix('.git')
|
||||
return owner, repo
|
||||
return None, None
|
||||
|
||||
VersionSource = Enum("VersionSource", [
|
||||
("LATEST_TAG", "release"),
|
||||
("HEAD", "commit"),
|
||||
("SPECIFIC_TAG", "specific_tag"),
|
||||
])
|
||||
def get_version_string(source: Enum, owner, repo, start_timestamp, n = 1, tag_data=None):
|
||||
"""Get the version string from a given GitHub repo."""
|
||||
|
||||
if source is VersionSource.LATEST_TAG:
|
||||
url = f'https://api.github.com/repos/{owner}/{repo}/releases/latest'
|
||||
elif source is VersionSource.SPECIFIC_TAG:
|
||||
if not tag_data:
|
||||
print(f"ERROR: SPECIFIC_TAG source requires tag_name")
|
||||
return None
|
||||
|
||||
tag_name = tag_data['name']
|
||||
url = f'https://api.github.com/repos/{owner}/{repo}/releases/tags/{tag_name}'
|
||||
else:
|
||||
if not source is VersionSource.HEAD:
|
||||
print(f"UNIMPLEMENTED(VersionSource): `{source}`,\nfalling back to `HEAD`")
|
||||
source = VersionSource.HEAD
|
||||
url = f'https://api.github.com/repos/{owner}/{repo}/commits'
|
||||
|
||||
try:
|
||||
response = requests.get(url, headers=HEADERS)
|
||||
|
||||
api_rate_limit = int(response.headers.get('x-ratelimit-limit'))
|
||||
api_rate_usage = int(response.headers.get('x-ratelimit-used'))
|
||||
api_rate_remaining = int(response.headers.get('x-ratelimit-remaining'))
|
||||
api_reset_timestamp = int(response.headers.get('x-ratelimit-reset'))
|
||||
api_resource = response.headers.get('x-ratelimit-resource')
|
||||
print(f"GitHub API ({api_resource}) calls: {api_rate_usage}/{api_rate_limit}")
|
||||
|
||||
if response.status_code == 404:
|
||||
# Not found
|
||||
return None
|
||||
|
||||
if response.status_code == 200:
|
||||
data = response.json()
|
||||
|
||||
if source is VersionSource.LATEST_TAG:
|
||||
# Return name of latest tag
|
||||
return data.get('tag_name')
|
||||
|
||||
elif source is VersionSource.SPECIFIC_TAG:
|
||||
assets = data.get('assets', [])
|
||||
if not assets:
|
||||
print(f"⚠️ No assets found in release {tag_name}")
|
||||
return None
|
||||
|
||||
latest_created_at = ""
|
||||
latest_asset = None
|
||||
|
||||
for asset in assets:
|
||||
created_at = asset.get('created_at', '')
|
||||
if created_at > latest_created_at:
|
||||
latest_created_at = created_at
|
||||
latest_asset = asset['name']
|
||||
|
||||
# Convert 2099-12-31T01:02:03Z to 20991231_010203
|
||||
parts = latest_created_at.replace('Z', '').split('T')
|
||||
date_part = parts[0].replace('-', '') # 20991231
|
||||
time_part = parts[1].replace(':', '') # 010203
|
||||
version = f"{date_part}_{time_part}" # 20991231_010203
|
||||
tag_data['file'] = latest_asset
|
||||
return version
|
||||
|
||||
if data and len(data) > 0:
|
||||
# Return shortened commit hash (first 7 characters)
|
||||
return data[0]['sha'][:7]
|
||||
|
||||
print(f"⚠️ Warning: unexpected response format for {source}s:\n{
|
||||
json.dumps(data, indent=2, ensure_ascii=False)
|
||||
}")
|
||||
return
|
||||
|
||||
if api_rate_remaining == 0 or (
|
||||
response.status_code == 403
|
||||
and "rate limit exceeded" in response.text.lower()
|
||||
):
|
||||
print(f"GitHub API access is being rate limited!")
|
||||
current_timestamp = int(time.time())
|
||||
|
||||
# Check if primary rate limit is okay
|
||||
if api_rate_remaining > 0:
|
||||
# Secondary rate limit hit, follow GitHub instructions
|
||||
if 'retry-after' in response.headers:
|
||||
wait_time = int(response.headers.get('retry-after')) + 5
|
||||
print(f"Response retry-after {wait_time}s")
|
||||
else:
|
||||
# Start at 60 seconds and double wait time with each new attempt
|
||||
print(f"Attempt {n}")
|
||||
wait_time = 60 * pow(2, n - 1)
|
||||
else:
|
||||
api_reset_time = datetime.fromtimestamp(api_reset_timestamp).strftime('%H:%M:%S')
|
||||
print(f"GitHub API rate limit resets at {api_reset_time}")
|
||||
wait_time = api_reset_timestamp - current_timestamp + 5
|
||||
|
||||
# Wait only if the wait time would finish less than 1800 seconds (30 min) after program start time
|
||||
if current_timestamp + wait_time - start_timestamp < 1800:
|
||||
print(f"Waiting {wait_time} seconds until next attempt...")
|
||||
time.sleep(wait_time)
|
||||
n += 1
|
||||
return get_version_string(source, owner, repo, start_timestamp, n, tag_data=tag_data) # Retry
|
||||
else:
|
||||
print(f"Next attempt in {wait_time} seconds, but Action run time would exceed 1800 seconds - Stopping...")
|
||||
sys.exit(1)
|
||||
|
||||
else:
|
||||
print(f"Error fetching {source}s: HTTP {response.status_code} - {response.text}")
|
||||
return None
|
||||
except Exception as e:
|
||||
print(f"Exception while fetching {source}s: {str(e)}")
|
||||
return None
|
||||
|
||||
def process_mods(start_timestamp):
|
||||
"""Process all mods and update versions where needed."""
|
||||
mods_dir = Path('mods')
|
||||
updated_mods = []
|
||||
print(f"Scanning {mods_dir} for mods with automatic version control...")
|
||||
|
||||
# Find all mod directories
|
||||
for mod_dir in (d for d in mods_dir.iterdir() if d.is_dir()):
|
||||
meta_file = mod_dir / 'meta.json'
|
||||
|
||||
if not meta_file.exists():
|
||||
continue
|
||||
|
||||
try:
|
||||
if mod := process_mod(start_timestamp, mod_dir.name, mod_dir / 'meta.json'):
|
||||
updated_mods.append(mod)
|
||||
except Exception as e:
|
||||
print(f"❌ Error processing {mod_dir.name}: {str(e)}")
|
||||
|
||||
return updated_mods
|
||||
|
||||
def process_mod(start_timestamp, name, meta_file):
|
||||
if not meta_file.exists():
|
||||
return
|
||||
|
||||
with open(meta_file, 'r', encoding='utf-8') as f:
|
||||
meta = json.load(f)
|
||||
|
||||
# Skip mods without automatic version checking enabled
|
||||
if not meta.get('automatic-version-check'):
|
||||
return
|
||||
|
||||
print(f"Processing {name}...")
|
||||
|
||||
repo_url = meta.get('repo')
|
||||
if not repo_url:
|
||||
print(f"⚠️ Warning: Mod {name} has automatic-version-check but no repo URL")
|
||||
return
|
||||
|
||||
owner, repo = extract_repo_info(repo_url)
|
||||
if not owner or not repo:
|
||||
print(f"⚠️ Warning: Could not extract repo info from {repo_url}")
|
||||
return
|
||||
|
||||
print(f"Checking GitHub repo: `{owner}/{repo}`")
|
||||
|
||||
# If download url links to latest head, use version of latest commit hash
|
||||
download_url = meta.get('downloadURL')
|
||||
|
||||
new_version = None
|
||||
|
||||
if "/archive/refs/heads/" in download_url:
|
||||
print("Download URL links to HEAD, checking latest commit...")
|
||||
source = VersionSource.HEAD
|
||||
new_version = get_version_string(VersionSource.HEAD, owner, repo, start_timestamp)
|
||||
elif (meta.get('fixed-release-tag-updates') == True) and "/releases/download/" in download_url:
|
||||
source = VersionSource.SPECIFIC_TAG
|
||||
tag_data = {}
|
||||
|
||||
# Pattern: /releases/download/{tag}/{file} - tag is second-to-last
|
||||
print("Download URL links to specific release asset, checking that asset's tag...")
|
||||
tag_name = download_url.split('/')[-2]
|
||||
print(f"Checking release tag: {tag_name}")
|
||||
tag_data['name'] = tag_name
|
||||
|
||||
new_version = get_version_string(
|
||||
source, owner, repo, start_timestamp, tag_data=tag_data
|
||||
)
|
||||
else:
|
||||
print("Checking releases for latest version tag...")
|
||||
source = VersionSource.LATEST_TAG
|
||||
new_version = get_version_string(source, owner, repo, start_timestamp)
|
||||
|
||||
if not new_version:
|
||||
print("No releases found, falling back to latest commit instead...")
|
||||
source = VersionSource.HEAD
|
||||
new_version = get_version_string(source, owner, repo, start_timestamp)
|
||||
|
||||
if not new_version:
|
||||
print(f"⚠️ Warning: Could not determine version for {name}")
|
||||
return
|
||||
|
||||
current_version = meta.get('version')
|
||||
# Update version if it changed
|
||||
if current_version == new_version:
|
||||
print(f"ℹ️ No version change for {name} (current: {current_version})")
|
||||
return
|
||||
|
||||
print(
|
||||
f"✅ Updating {name} from {current_version} to {new_version} ({source})"
|
||||
)
|
||||
meta['version'] = new_version
|
||||
meta['last-updated'] = TIME_NOW
|
||||
if "/archive/refs/tags/" in download_url:
|
||||
meta['downloadURL'] = f"{repo_url}/archive/refs/tags/{meta['version']}.zip"
|
||||
elif source == VersionSource.SPECIFIC_TAG:
|
||||
meta['downloadURL'] = f"{repo_url}/releases/download/{tag_data['name']}/{tag_data['file']}"
|
||||
|
||||
with open(meta_file, 'w', encoding='utf-8') as f:
|
||||
# Preserve formatting with indentation
|
||||
json.dump(meta, f, indent=2, ensure_ascii=False)
|
||||
f.write("\n") # Add newline at end of file
|
||||
|
||||
return {
|
||||
'name': meta.get('title', name),
|
||||
'old_version': current_version,
|
||||
'new_version': meta['version'],
|
||||
'source': source
|
||||
}
|
||||
|
||||
|
||||
def generate_commit_message(updated_mods):
|
||||
"""Generate a detailed commit message listing all updated mods."""
|
||||
if not updated_mods:
|
||||
return "No mod versions updated"
|
||||
|
||||
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
message = f"Auto-update mod versions ({timestamp})\n\n"
|
||||
message += "Updated mods:\n"
|
||||
|
||||
for mod in updated_mods:
|
||||
old_ver = mod['old_version'] or 'none'
|
||||
message += f"- {mod['name']}: {old_ver} → {mod['new_version']} ({mod['source']})\n"
|
||||
|
||||
return message
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
start_timestamp = int(time.time())
|
||||
start_datetime = datetime.fromtimestamp(start_timestamp).strftime('%H:%M:%S')
|
||||
print(f"🔄 Starting automatic mod version update at {start_datetime}...")
|
||||
updated_mods = process_mods(start_timestamp)
|
||||
|
||||
if updated_mods:
|
||||
# Write commit message to a file that the GitHub Action can use
|
||||
commit_message = generate_commit_message(updated_mods)
|
||||
with open('commit_message.txt', 'w', encoding='utf-8') as f:
|
||||
f.write(commit_message)
|
||||
|
||||
print(f"✅ Completed. Updated {len(updated_mods)} mod versions.")
|
||||
else:
|
||||
print("ℹ️ Completed. No mod versions needed updating.")
|
||||
|
||||
# Exit with status code 0 even if no updates were made
|
||||
sys.exit(0)
|
||||
45
.github/workflows/fetch-upstream-mods.yml
vendored
@@ -2,7 +2,7 @@ name: fetch upstream mod changes
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '13,43 * * * *'
|
||||
- cron: "13,43 * * * *"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
@@ -10,23 +10,44 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout current Gitea repo
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
lfs: true
|
||||
- name: Clone Gitea repo (skip LFS smudge)
|
||||
run: |
|
||||
rm -rf repo /tmp/upstream
|
||||
GIT_LFS_SKIP_SMUDGE=1 \
|
||||
git clone ssh://git@smallgit.dasguney.com:2222/skyline/balatro-mod-index.git repo
|
||||
|
||||
- name: Configure LFS and fetch objects
|
||||
env:
|
||||
GITEA_TOKEN: ${{ secrets.GT_TOKEN }}
|
||||
run: |
|
||||
cd repo
|
||||
|
||||
# Auth for Git + LFS
|
||||
printf "machine smallgit.dasguney.com\nlogin skyline\npassword %s\n" "$GITEA_TOKEN" > ~/.netrc
|
||||
chmod 600 ~/.netrc
|
||||
|
||||
# Force LFS to use direct Gitea endpoint (no nginx)
|
||||
git config lfs.url "http://smallgit.dasguney.com:3000/skyline/balatro-mod-index.git/info/lfs"
|
||||
git config lfs."http://smallgit.dasguney.com:3000/skyline/balatro-mod-index.git/info/lfs".locksverify false
|
||||
|
||||
# Install hooks and explicitly fetch LFS data
|
||||
git lfs install --local
|
||||
git lfs fetch origin
|
||||
git lfs checkout
|
||||
|
||||
- name: Clone upstream GitHub repo
|
||||
run: |
|
||||
rm -rf /tmp/upstream
|
||||
git clone https://github.com/skyline69/balatro-mod-index.git /tmp/upstream
|
||||
|
||||
- name: Replace mods directory
|
||||
run: |
|
||||
cd repo
|
||||
rm -rf mods
|
||||
cp -a /tmp/upstream/mods ./mods
|
||||
|
||||
- name: Append last-updated timestamp
|
||||
run: |
|
||||
cd repo
|
||||
TIME_NOW=$(date +"%s")
|
||||
git diff -z --name-only | grep -z meta.json | while IFS='' read -r -d '' file; do
|
||||
jq --indent 2 '."last-updated" |= (. // '"$TIME_NOW"')' "$file" | sponge "$file"
|
||||
@@ -34,11 +55,15 @@ jobs:
|
||||
|
||||
- name: Commit and push
|
||||
run: |
|
||||
git config user.name "gitea-bot"
|
||||
git config user.email "bot@smallgit.dasguney.com"
|
||||
cd repo
|
||||
|
||||
git config user.name "jim[bot]"
|
||||
git config user.email "jim[bot]@users.noreply.github.com"
|
||||
|
||||
# Use direct Gitea HTTP endpoint for push
|
||||
git remote set-url origin http://smallgit.dasguney.com:3000/skyline/balatro-mod-index.git
|
||||
|
||||
git add mods
|
||||
if git commit -m "fetch upstream mod changes ($(date --utc +%Y%m%d_%H%M%SZ))"; then
|
||||
git push
|
||||
git push origin main
|
||||
fi
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 130 B |
|
Before Width: | Height: | Size: 377 KiB After Width: | Height: | Size: 131 B |
BIN
mods/AMY@AMY'sWaifus/meta.json
LFS
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 130 B |
|
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 132 B |
|
Before Width: | Height: | Size: 529 KiB After Width: | Height: | Size: 131 B |
BIN
mods/Agarpain@Agarmons/meta.json
LFS
|
Before Width: | Height: | Size: 146 KiB After Width: | Height: | Size: 131 B |
|
Before Width: | Height: | Size: 250 KiB After Width: | Height: | Size: 131 B |
|
Before Width: | Height: | Size: 478 KiB After Width: | Height: | Size: 131 B |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 130 B |
|
Before Width: | Height: | Size: 860 KiB After Width: | Height: | Size: 131 B |
|
Before Width: | Height: | Size: 158 KiB After Width: | Height: | Size: 131 B |
|
Before Width: | Height: | Size: 381 KiB After Width: | Height: | Size: 131 B |
|
Before Width: | Height: | Size: 157 KiB After Width: | Height: | Size: 131 B |
BIN
mods/Aure@SixSuits/meta.json
LFS
|
Before Width: | Height: | Size: 316 KiB After Width: | Height: | Size: 131 B |
|
Before Width: | Height: | Size: 1.3 MiB After Width: | Height: | Size: 132 B |
|
Before Width: | Height: | Size: 189 KiB After Width: | Height: | Size: 131 B |
BIN
mods/Balin-P@Wilder/meta.json
LFS
|
Before Width: | Height: | Size: 610 KiB After Width: | Height: | Size: 131 B |
|
Before Width: | Height: | Size: 310 KiB After Width: | Height: | Size: 131 B |
|
Before Width: | Height: | Size: 158 KiB After Width: | Height: | Size: 131 B |
BIN
mods/Betmma@BetmmaMods/meta.json
LFS
|
Before Width: | Height: | Size: 341 KiB After Width: | Height: | Size: 131 B |
|
Before Width: | Height: | Size: 1.3 MiB After Width: | Height: | Size: 132 B |
BIN
mods/Blazingulag@Prism/meta.json
LFS
|
Before Width: | Height: | Size: 967 KiB After Width: | Height: | Size: 131 B |
|
Before Width: | Height: | Size: 1.3 MiB After Width: | Height: | Size: 132 B |
|
Before Width: | Height: | Size: 341 KiB After Width: | Height: | Size: 131 B |
|
Before Width: | Height: | Size: 213 KiB After Width: | Height: | Size: 131 B |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 130 B |
|
Before Width: | Height: | Size: 189 KiB After Width: | Height: | Size: 131 B |
|
Before Width: | Height: | Size: 296 KiB After Width: | Height: | Size: 131 B |