-
Notifications
You must be signed in to change notification settings - Fork 44
102 lines (82 loc) · 3.29 KB
/
plugin-updater.yml
File metadata and controls
102 lines (82 loc) · 3.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
name: 🔍 Check for Plugin Updates
on:
schedule:
- cron: "0 2 * * *"
workflow_dispatch:
permissions:
contents: read
issues: write
jobs:
check-updates:
runs-on: ubuntu-latest
env:
VERSION_FILE: .github/dependency_versions.json
steps:
- name: 🧰 Checkout
uses: actions/checkout@v4
- name: 📦 Install jq & gh
run: |
sudo apt-get update
sudo apt-get install -y jq
gh --version || sudo apt-get install -y gh
- name: 🔍 Check for new releases
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
mapfile -t ROWS < <(jq -r '
to_entries[]
| [
(.value.repo),
(.value.message // "v0.0.0"),
(.value.allow_prerelease // false)
]
| @tsv
' "$VERSION_FILE")
norm() { sed -E 's/^v//'; }
for row in "${ROWS[@]}"; do
repo="$(cut -f1 <<< "$row")"
prev_tag="$(cut -f2 <<< "$row")"
allow_pre_flag="$(cut -f3 <<< "$row")"
echo "🔎 Checking $repo (pinned: $prev_tag, allow_prerelease=$allow_pre_flag)"
if [[ "$allow_pre_flag" == "true" ]]; then
latest_tag="$(curl -s "https://api.github.com/repos/$repo/releases" \
| jq -r '[.[] | select(.draft==false) | .tag_name] | first // empty')"
else
latest_tag="$(curl -s "https://api.github.com/repos/$repo/releases/latest" \
| jq -r '.tag_name // empty')"
fi
if [[ -z "$latest_tag" ]]; then
latest_tag=$(curl -s "https://api.github.com/repos/$repo/tags" \
| jq -r 'if type=="array" and length>0 then .[0].name else empty end')
fi
if [[ -z "$latest_tag" ]]; then
latest_tag="v0.0.0"
fi
prev_norm="$(printf '%s' "$prev_tag" | norm)"
latest_norm="$(printf '%s' "$latest_tag" | norm)"
if [[ "$latest_norm" != "$prev_norm" && "$latest_tag" != "v0.0.0" ]]; then
echo "New release detected for $repo: $prev_tag → $latest_tag"
existing_number="$(gh issue list \
--state open \
--label dependencies \
--search "\"$repo\" \"$latest_tag\"" \
--json number 2>/dev/null \
| jq -r 'if type=="array" and length>0 then .[0].number else empty end' || true)"
if [[ -n "$existing_number" ]]; then
echo "Open issue #$existing_number already exists for $repo $latest_tag; skipping create"
continue
fi
gh issue create \
--title "Incorporate $repo $latest_tag" \
--label dependencies \
--body "**Plugin**: \`$repo\`
**Version**: \`$latest_tag\`
Please update the DLL and modify the following files accordingly.
\`.github/dependency_versions.json\`
\`.github/badges/[plugin].json\`
[Release notes](https://github.com/$repo/releases/tag/$latest_tag)"
else
echo "No update needed for $repo ($prev_tag)"
fi
done