Skip to content

Free fork of NotProton: Windows Steam games in Mac Steam, on CodeWeavers' Wine and Apple's Game Porting Toolkit

ci(stats): snapshot stars and release downloads daily to the stats branch

raymondchinsa2ffd0346496
diff --git a/.github/workflows/stats.yml b/.github/workflows/stats.yml
new file mode 100644
index 0000000..5fadee5
--- /dev/null
+++ b/.github/workflows/stats.yml
@@ -0,0 +1,59 @@
+# Daily snapshot of public GitHub numbers for this repository.
+# GitHub only exposes running totals, so this records them once a day on the
+# `stats` branch.
+# repo.csv date,stars,forks,watchers,open_issues
+# downloads.csv date,tag,asset,downloads
+# appcast.xml downloads ~ Sparkle update checks, a rough active-install signal.
+name: stats
+
+on:
+ schedule:
+ - cron: "17 0 * * *"
+ workflow_dispatch:
+
+permissions:
+ contents: write
+
+concurrency: stats
+
+jobs:
+ snapshot:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Snapshot Bridgeplay stats
+ env:
+ GH_TOKEN: ${{ github.token }}
+ SRC: ${{ github.repository }}
+ run: |
+ set -euo pipefail
+ remote="https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
+ if git ls-remote --exit-code --heads "$remote" stats >/dev/null; then
+ git clone -q --depth 1 --branch stats "$remote" out
+ else
+ git init -q -b stats out
+ git -C out remote add origin "$remote"
+ fi
+ cd out
+ today=$(date -u +%F)
+
+ [ -f repo.csv ] || echo "date,stars,forks,watchers,open_issues" > repo.csv
+ [ -f downloads.csv ] || echo "date,tag,asset,downloads" > downloads.csv
+ # Re-running on the same day replaces that day's rows.
+ for f in repo.csv downloads.csv; do
+ grep -v "^${today}," "$f" > "$f.tmp" || true
+ mv "$f.tmp" "$f"
+ done
+
+ gh api "repos/$SRC" \
+ --jq "[\"$today\", .stargazers_count, .forks_count, .subscribers_count, .open_issues_count] | @csv" \
+ | tr -d '"' >> repo.csv
+ gh api --paginate "repos/$SRC/releases?per_page=100" \
+ --jq ".[] | .tag_name as \$t | .assets[] | [\"$today\", \$t, .name, .download_count] | @csv" \
+ | tr -d '"' >> downloads.csv
+
+ git add repo.csv downloads.csv
+ if git diff --cached --quiet; then exit 0; fi
+ git -c user.name="github-actions[bot]" \
+ -c user.email="41898282+github-actions[bot]@users.noreply.github.com" \
+ commit -q -m "stats: ${today}"
+ git push -q origin stats