mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-04-13 12:22:33 -05:00
refactor: consolidate CI pipeline, remove third-party deps
This commit is contained in:
136
.github/workflows/build.yml
vendored
Normal file
136
.github/workflows/build.yml
vendored
Normal file
@@ -0,0 +1,136 @@
|
||||
name: Build & Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
paths: ["bios/**", "platforms/**"]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
force_release:
|
||||
description: "Force release even if rate limited"
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
concurrency:
|
||||
group: build
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
regenerate:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: "3.12"
|
||||
|
||||
- run: pip install pyyaml
|
||||
|
||||
- name: Regenerate database and docs
|
||||
run: |
|
||||
python scripts/generate_db.py --bios-dir bios --output database.json
|
||||
python scripts/generate_readme.py --db database.json --platforms-dir platforms
|
||||
|
||||
- name: Commit if changed
|
||||
id: commit
|
||||
run: |
|
||||
git diff --quiet database.json README.md CONTRIBUTING.md && echo "changed=false" >> "$GITHUB_OUTPUT" && exit 0
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git add database.json README.md CONTRIBUTING.md
|
||||
git commit -m "regenerate database and docs"
|
||||
git push
|
||||
echo "changed=true" >> "$GITHUB_OUTPUT"
|
||||
|
||||
release:
|
||||
needs: regenerate
|
||||
if: needs.regenerate.result == 'success' || github.event.inputs.force_release == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Rate limit
|
||||
if: github.event.inputs.force_release != 'true'
|
||||
id: rate
|
||||
run: |
|
||||
LAST=$(gh release list --repo "${{ github.repository }}" --json createdAt -q '.[0].createdAt' 2>/dev/null || echo "")
|
||||
if [ -n "$LAST" ] && [ "$LAST" != "null" ]; then
|
||||
LAST_TS=$(date -d "$LAST" +%s 2>/dev/null || echo 0)
|
||||
DIFF=$(( ($(date +%s) - LAST_TS) / 86400 ))
|
||||
if [ "$DIFF" -lt 7 ]; then
|
||||
echo "Skipping: last release ${DIFF} days ago"
|
||||
echo "skip=true" >> "$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
echo "skip=false" >> "$GITHUB_OUTPUT"
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- uses: actions/checkout@v6
|
||||
if: steps.rate.outputs.skip != 'true'
|
||||
with:
|
||||
ref: main
|
||||
|
||||
- uses: actions/setup-python@v6
|
||||
if: steps.rate.outputs.skip != 'true'
|
||||
with:
|
||||
python-version: "3.12"
|
||||
|
||||
- name: Build packs
|
||||
if: steps.rate.outputs.skip != 'true'
|
||||
run: |
|
||||
pip install pyyaml
|
||||
python scripts/generate_db.py --bios-dir bios --output database.json
|
||||
python scripts/generate_pack.py --all --output-dir dist/
|
||||
|
||||
- name: Release
|
||||
if: steps.rate.outputs.skip != 'true'
|
||||
run: |
|
||||
DATE=$(date +%Y.%m.%d)
|
||||
EXISTING=$(gh release list --repo "${{ github.repository }}" --json tagName -q ".[].tagName" | grep -c "^v${DATE}" || true)
|
||||
TAG="v${DATE}"
|
||||
[ "$EXISTING" -gt 0 ] && TAG="v${DATE}.$((EXISTING+1))"
|
||||
|
||||
CHANGES=$(git log --oneline -15 --no-merges -- bios/ platforms/ | sed 's/^/- /')
|
||||
TOTAL=$(python3 -c "import json; print(json.load(open('database.json'))['total_files'])")
|
||||
SIZE=$(python3 -c "import json; print(f'{json.load(open(\"database.json\"))[\"total_size\"]/1024/1024:.0f}')")
|
||||
PACKS=$(ls dist/*.zip 2>/dev/null | while read f; do echo "- **$(basename $f)** ($(du -m "$f" | cut -f1) MB)"; done)
|
||||
|
||||
gh release create "$TAG" dist/*.zip \
|
||||
--repo "${{ github.repository }}" \
|
||||
--title "BIOS Pack $TAG" \
|
||||
--notes "${TOTAL} files, ${SIZE} MB, verified checksums.
|
||||
|
||||
### Packs
|
||||
${PACKS}
|
||||
|
||||
### Install
|
||||
Download, extract to your emulator's BIOS directory.
|
||||
|
||||
| Platform | Path |
|
||||
|----------|------|
|
||||
| RetroArch / Lakka | system/ |
|
||||
| Batocera | /userdata/bios/ |
|
||||
| Recalbox | /recalbox/share/bios/ |
|
||||
| RetroBat | bios/ |
|
||||
|
||||
### Changes
|
||||
${CHANGES}
|
||||
" \
|
||||
--latest
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Cleanup old releases
|
||||
if: steps.rate.outputs.skip != 'true'
|
||||
run: |
|
||||
gh release list --repo "${{ github.repository }}" --json tagName,createdAt \
|
||||
--jq 'sort_by(.createdAt) | reverse | .[].tagName' | \
|
||||
grep -v "^large-files$" | tail -n +4 | while read tag; do
|
||||
gh release delete "$tag" --repo "${{ github.repository }}" --yes --cleanup-tag
|
||||
done
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
214
.github/workflows/release.yml
vendored
214
.github/workflows/release.yml
vendored
@@ -1,214 +0,0 @@
|
||||
name: Release BIOS Packs
|
||||
|
||||
on:
|
||||
push:
|
||||
tags: ["v*"]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: "Release version (e.g., v2.0.0)"
|
||||
required: true
|
||||
# Auto-release when update-db finishes (after BIOS push or platform update merge)
|
||||
workflow_run:
|
||||
workflows: ["Update Database"]
|
||||
types: [completed]
|
||||
branches: [main]
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
check-changes:
|
||||
runs-on: ubuntu-latest
|
||||
# Skip auto-release if update-db failed or was triggered by release itself
|
||||
if: >
|
||||
github.event_name == 'push' ||
|
||||
github.event_name == 'workflow_dispatch' ||
|
||||
(github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success')
|
||||
outputs:
|
||||
should_release: ${{ steps.check.outputs.should_release }}
|
||||
version: ${{ steps.version.outputs.tag }}
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 2
|
||||
|
||||
- name: Check if BIOS files changed
|
||||
id: check
|
||||
run: |
|
||||
if [ "${{ github.event_name }}" = "workflow_run" ]; then
|
||||
# Auto-release: check if bios/ or platforms/ changed in the last commit
|
||||
changed=$(git diff --name-only HEAD~1 HEAD | grep -cE '^(bios/|platforms/)' || true)
|
||||
if [ "$changed" -gt 0 ]; then
|
||||
echo "should_release=true" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "should_release=false" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
else
|
||||
echo "should_release=true" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- name: Determine version
|
||||
id: version
|
||||
run: |
|
||||
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
||||
echo "tag=${{ github.event.inputs.version }}" >> "$GITHUB_OUTPUT"
|
||||
elif [ "${{ github.event_name }}" = "push" ]; then
|
||||
echo "tag=${{ github.ref_name }}" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
# Auto-release: use date-based version
|
||||
echo "tag=auto-$(date +%Y%m%d)" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
discover:
|
||||
needs: check-changes
|
||||
if: needs.check-changes.outputs.should_release == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
platforms: ${{ steps.list.outputs.platforms }}
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: "3.12"
|
||||
|
||||
- name: List platforms
|
||||
id: list
|
||||
run: python scripts/list_platforms.py
|
||||
|
||||
build:
|
||||
needs: [check-changes, discover]
|
||||
if: needs.check-changes.outputs.should_release == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
platform: ${{ fromJson(needs.discover.outputs.platforms) }}
|
||||
fail-fast: false
|
||||
max-parallel: 10
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: "3.12"
|
||||
|
||||
- name: Install dependencies
|
||||
run: pip install pyyaml
|
||||
|
||||
- name: Generate database (if not present)
|
||||
run: |
|
||||
if [ ! -f database.json ]; then
|
||||
python scripts/generate_db.py --bios-dir bios --output database.json
|
||||
fi
|
||||
|
||||
- name: Generate pack for ${{ matrix.platform }}
|
||||
run: python scripts/generate_pack.py --platform ${{ matrix.platform }} --output-dir dist/
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v6
|
||||
with:
|
||||
name: pack-${{ matrix.platform }}
|
||||
path: dist/*.zip
|
||||
retention-days: 1
|
||||
|
||||
publish:
|
||||
needs: [check-changes, discover, build]
|
||||
if: needs.check-changes.outputs.should_release == 'true'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Download all pack artifacts
|
||||
uses: actions/download-artifact@v6
|
||||
with:
|
||||
path: dist/
|
||||
pattern: pack-*
|
||||
merge-multiple: true
|
||||
|
||||
- name: Copy database.json
|
||||
run: cp database.json dist/database.json 2>/dev/null || true
|
||||
|
||||
- uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: "3.12"
|
||||
|
||||
- name: Install dependencies
|
||||
run: pip install pyyaml
|
||||
|
||||
- name: Generate release notes
|
||||
id: notes
|
||||
run: |
|
||||
python3 << 'PYEOF'
|
||||
import json, os, subprocess, textwrap
|
||||
|
||||
with open("database.json") as f:
|
||||
db = json.load(f)
|
||||
|
||||
total = db["total_files"]
|
||||
size_mb = db["total_size"] / (1024 * 1024)
|
||||
date = db["generated_at"]
|
||||
|
||||
packs = sorted(f for f in os.listdir("dist") if f.endswith(".zip"))
|
||||
pack_list = "\n".join(f"- **{p}** ({os.path.getsize(f'dist/{p}') / 1024 / 1024:.0f} MB)" for p in packs)
|
||||
|
||||
# Get recent changes
|
||||
try:
|
||||
log = subprocess.run(
|
||||
["git", "log", "--oneline", "-20", "--no-merges", "--", "bios/", "platforms/"],
|
||||
capture_output=True, text=True
|
||||
).stdout.strip()
|
||||
changes = "\n".join(f"- {line}" for line in log.split("\n") if line) if log else "- Initial release"
|
||||
except Exception:
|
||||
changes = "- See commit history"
|
||||
|
||||
notes = textwrap.dedent(f"""\
|
||||
{total} BIOS/firmware files, {size_mb:.0f} MB, 50+ systems, verified checksums.
|
||||
|
||||
### Packs
|
||||
{pack_list}
|
||||
|
||||
### Install
|
||||
Download, extract to your emulator's BIOS directory:
|
||||
|
||||
| Platform | Path |
|
||||
|----------|------|
|
||||
| RetroArch / Lakka | `system/` |
|
||||
| Batocera | `/userdata/bios/` |
|
||||
| Recalbox | `/recalbox/share/bios/` |
|
||||
|
||||
<details><summary>CLI & archived platforms</summary>
|
||||
|
||||
```bash
|
||||
# CLI download
|
||||
python scripts/download.py retroarch ~/RetroArch/system/
|
||||
|
||||
# Archived platforms (RetroPie, etc.)
|
||||
git clone https://github.com/Abdess/retrobios.git
|
||||
cd retrobios && pip install pyyaml
|
||||
python scripts/generate_pack.py --platform retropie -o ~/Downloads/
|
||||
```
|
||||
</details>
|
||||
|
||||
### Changes
|
||||
{changes}
|
||||
|
||||
---
|
||||
*{date} - [Full checksums & file listing](../../blob/main/README.md)*
|
||||
""")
|
||||
|
||||
with open("/tmp/release_notes.md", "w") as f:
|
||||
f.write(notes)
|
||||
PYEOF
|
||||
|
||||
- name: Create Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: ${{ needs.check-changes.outputs.version }}
|
||||
name: "BIOS Pack ${{ needs.check-changes.outputs.version }}"
|
||||
body_path: /tmp/release_notes.md
|
||||
files: dist/*
|
||||
fail_on_unmatched_files: false
|
||||
generate_release_notes: true
|
||||
make_latest: true
|
||||
41
.github/workflows/update-db.yml
vendored
41
.github/workflows/update-db.yml
vendored
@@ -1,41 +0,0 @@
|
||||
name: Update Database
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
- "bios/**"
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
concurrency:
|
||||
group: update-db
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
update:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- uses: actions/setup-python@v6
|
||||
with:
|
||||
python-version: "3.12"
|
||||
|
||||
- name: Install dependencies
|
||||
run: pip install pyyaml
|
||||
|
||||
- name: Generate database
|
||||
run: python scripts/generate_db.py --bios-dir bios --output database.json
|
||||
|
||||
- name: Generate README and CONTRIBUTING
|
||||
run: python scripts/generate_readme.py --db database.json --platforms-dir platforms
|
||||
|
||||
- name: Commit changes
|
||||
uses: stefanzweifel/git-auto-commit-action@v7
|
||||
with:
|
||||
commit_message: "chore: update database and documentation"
|
||||
file_pattern: "database.json README.md CONTRIBUTING.md"
|
||||
commit_author: "github-actions[bot] <github-actions[bot]@users.noreply.github.com>"
|
||||
6
.github/workflows/validate.yml
vendored
6
.github/workflows/validate.yml
vendored
@@ -1,4 +1,4 @@
|
||||
name: Validate PR
|
||||
name: PR Validation
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
@@ -10,6 +10,10 @@ permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
|
||||
concurrency:
|
||||
group: validate-${{ github.event.pull_request.number }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
validate-bios:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
name: Watch Platform Updates
|
||||
name: Weekly Platform Sync
|
||||
|
||||
on:
|
||||
schedule:
|
||||
@@ -8,7 +8,10 @@ on:
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
issues: write
|
||||
|
||||
concurrency:
|
||||
group: watch-updates
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
scrape-and-update:
|
||||
@@ -87,9 +90,9 @@ jobs:
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
|
||||
git checkout -b "$BRANCH"
|
||||
git add -A
|
||||
git add bios/ platforms/ database.json README.md CONTRIBUTING.md
|
||||
git commit -m "chore: auto-update platform data ($DATE)"
|
||||
git push origin "$BRANCH" --force
|
||||
git push origin "$BRANCH" --force-with-lease
|
||||
|
||||
existing_pr=$(gh pr list --head "$BRANCH" --json number --jq '.[0].number' 2>/dev/null || true)
|
||||
|
||||
Reference in New Issue
Block a user