Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Show in the README how many times Peel was downloaded

Țugui Dragoș4580a6905ed7
diff --git a/.github/downloads.json b/.github/downloads.json
new file mode 100644
index 00000000..60e1abfe
--- /dev/null
+++ b/.github/downloads.json
@@ -0,0 +1,7 @@
+{
+ "schemaVersion": 1,
+ "label": "Downloaded",
+ "message": "2,966 times",
+ "labelColor": "201F1D",
+ "color": "FF9933"
+}
diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml
index 9db105fd..65dea5f4 100644
--- a/.github/workflows/checks.yml
+++ b/.github/workflows/checks.yml
@@ -4,6 +4,8 @@ name: Checks
# While it is private, only a run started by hand does anything.
on:
push:
+ paths-ignore:
+ - .github/downloads.json
pull_request:
workflow_dispatch:
diff --git a/.github/workflows/downloads.yml b/.github/workflows/downloads.yml
new file mode 100644
index 00000000..456288e2
--- /dev/null
+++ b/.github/workflows/downloads.yml
@@ -0,0 +1,46 @@
+name: Downloads
+
+on:
+ schedule:
+ - cron: "41 4 16 * *"
+ workflow_dispatch:
+
+permissions: {}
+
+jobs:
+ count:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510
+ id: app
+ with:
+ client-id: ${{ vars.DOWNLOADS_APP_CLIENT_ID }}
+ private-key: ${{ secrets.DOWNLOADS_APP_KEY }}
+ permission-contents: write
+
+ - name: Update the download count
+ shell: bash
+ env:
+ GH_TOKEN: ${{ steps.app.outputs.token }}
+ BADGE_FILE: repos/${{ github.repository }}/contents/.github/downloads.json
+ COMMIT_BODY: |
+ Counted only from the disk images and zips of every release.
+ appcast.xml is left out: installed copies read it to look for updates.
+
+ Thank you to everyone who trusts Peel ❤️
+
+ Co-authored-by: Țugui Dragoș <[email protected]>
+ run: |
+ count=$(gh api --paginate --slurp "repos/$GITHUB_REPOSITORY/releases" | jq -r '
+ def commas: tostring | if length > 3 then (.[:-3] | commas) + "," + .[-3:] else . end;
+ [.[][] | select(.draft | not) | .assets[] | select(.name | test("\\.(dmg|zip)$")) | .download_count]
+ | add | commas')
+ badge=$(jq -n --arg message "$count times" \
+ '{schemaVersion: 1, label: "Downloaded", message: $message, labelColor: "201F1D", color: "FF9933"}')
+ current=$(gh api "$BADGE_FILE")
+ if [ "$(jq -r .content <<<"$current" | base64 -d)" != "$badge" ]; then
+ gh api --method PUT "$BADGE_FILE" \
+ -f message="Update the download count to $count"$'\n\n'"$COMMIT_BODY" \
+ -f sha="$(jq -r .sha <<<"$current")" \
+ -f content="$(base64 -w0 <<<"$badge")"
+ fi
diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md
index 502ab021..d5687a22 100644
--- a/ARCHITECTURE.md
+++ b/ARCHITECTURE.md
@@ -545,7 +545,13 @@ its place (`SettingsView`), whose zap takes Peel's whole folder, `Terminal/` inc
`Scripts/generate_manual.py --check` when the manual page of `peel` is behind the tool.
- The Checks workflow (`.github/workflows/checks.yml`) runs on every push and pull request: the suite, Sparkle's
build, the app in Debug and its own tests, the app in Release with every binary's three slices and its class data
- signed, the accessibility audit's build, and both `--check` scripts.
+ signed, the accessibility audit's build, and both `--check` scripts. It passes over a push that changes only
+ `.github/downloads.json`.
+- The Downloads workflow (`.github/workflows/downloads.yml`) writes that file, which the README's badge shows, on the
+ 16th of each month. It counts only disk images and zips: every installed copy reads `appcast.xml` each day, which
+ downloads nothing, and Homebrew's installs are already in the zips, which its cask downloads from the release.
+ `GITHUB_TOKEN` can't commit to main, which takes only pull requests, so a GitHub App on the ruleset's bypass list
+ does.
## Releases
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 92e5ec7e..a902a69d 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -89,8 +89,8 @@ python3 Scripts/generate_manual.py --check
and check a release.
- `Terminal/`: the Terminal themes and the pictures TERMINAL.md shows.
- `readme-assets/`: the screenshots and pictures the documents show.
-- `.github/`: the Checks workflow, Dependabot's settings, the issue and discussion forms, the pull request template,
- and the sponsor link in FUNDING.yml.
+- `.github/`: the Checks workflow, the monthly count behind the README's downloads badge, Dependabot's settings, the
+ issue and discussion forms, the pull request template, and the sponsor link in FUNDING.yml.
- `docs/`: Peel's website, peel.tuguidragos.com.
- The documents, at the root: [README.md](README.md) says what Peel is and how to get it, [GUIDE.md](GUIDE.md) what
each tool does, [PRIVACY.md](PRIVACY.md) what Peel sends, [SAFETY.md](SAFETY.md) what it protects,
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/DocumentationTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/DocumentationTests.swift
index 076ed5af..cdfc148c 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/DocumentationTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/DocumentationTests.swift
@@ -81,6 +81,9 @@ struct DocumentationTests {
("README.md", "<a href=\"https://peel.tuguidragos.com/languages\">"),
("README.md", "<a href=\"#install\">"),
("README.md", "## Install > [!CAUTION]"),
+ (".github/workflows/downloads.yml", "test(\"\\\\.(dmg|zip)$\")"),
+ (".github/downloads.json", "\"label\": \"Downloaded\""),
+ ("README.md", "<a href=\"https://github.com/TuguiDragos/Peel/releases\"><img src=\"https://img.shields.io/endpoint"),
]
let wrong = try said.filter { try !text($0.0).contains($0.1) }
diff --git a/README.md b/README.md
index 229bc471..9756d8f4 100644
--- a/README.md
+++ b/README.md
@@ -14,6 +14,7 @@
<a href="#install"><img src="https://img.shields.io/badge/macOS%2026%20or%20later-201F1D?style=flat&logo=apple&logoColor=FF9933" height="30" alt="Requires macOS 26 or later"></a>
<a href="https://peel.tuguidragos.com/languages"><img src="https://img.shields.io/badge/18%20languages-201F1D?style=flat&logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI%2BPGcgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjRkY5OTMzIiBzdHJva2Utd2lkdGg9IjEuNyIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIj48Y2lyY2xlIGN4PSIxMiIgY3k9IjEyIiByPSI4LjYiLz48ZWxsaXBzZSBjeD0iMTIiIGN5PSIxMiIgcng9IjQuMSIgcnk9IjguNiIvPjxwYXRoIGQ9Ik0zLjkgOS4xaDE2LjJNMy45IDE0LjloMTYuMiIvPjwvZz48L3N2Zz4%3D" height="30" alt="Available in 18 languages"></a>
<a href="LICENSE"><img src="https://img.shields.io/badge/GPL%203.0%20or%20later-201F1D?style=flat&logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI%2BPGcgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjRkY5OTMzIiBzdHJva2Utd2lkdGg9IjEuNyIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIj48cGF0aCBkPSJNMTIgMy41djE2LjVNOCAyMGg4TTQuNSA3aDE1Ii8%2BPHBhdGggZD0iTTQuNSA3IDIgMTMuNWg1eiIvPjxwYXRoIGQ9Ik0xOS41IDcgMTcgMTMuNWg1eiIvPjwvZz48L3N2Zz4%3D" height="30" alt="License: GNU GPL 3.0 or later"></a>
+ <a href="https://github.com/TuguiDragos/Peel/releases"><img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2FTuguiDragos%2FPeel%2Fmain%2F.github%2Fdownloads.json&style=flat&logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNCAyNCI%2BPGcgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjRkY5OTMzIiBzdHJva2Utd2lkdGg9IjIuMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIj48cGF0aCBkPSJNNSAxOS41di01LjVNMTIgMTkuNVY0LjVNMTkgMTkuNVY5LjUiLz48L2c%2BPC9zdmc%2B" height="30" alt="How many times Peel was downloaded"></a>
</p>
<p align="center">