-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate-json.sh
More file actions
executable file
·53 lines (44 loc) · 1.61 KB
/
update-json.sh
File metadata and controls
executable file
·53 lines (44 loc) · 1.61 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
#!/usr/bin/env bash
set -euo pipefail
FLAKE_REF="github:staticweb-io/wordpress-flake"
SYSTEM=$(nix eval --impure --expr builtins.currentSystem --raw)
echo "Getting wordpress_* packages from $FLAKE_REF for system $SYSTEM..."
# Sort wordpress packages by version descending
wordpress_packages=$(nix eval --json --impure \
--expr "builtins.attrNames (builtins.getFlake \"$FLAKE_REF\").packages.\"$SYSTEM\"" \
| jq -r '.[]' | grep '^wordpress_' \
| sort -t_ -k2,2nr -k3,3nr -k4,4nr)
if [[ -z "$wordpress_packages" ]]; then
echo "No wordpress_* packages found."
exit 1
fi
last_success=""
first_pkg=""
for pkg in $wordpress_packages; do
[[ -z "$first_pkg" ]] && first_pkg="$pkg"
echo -e "\n➡️ Running check for WORDPRESS_PACKAGE=$pkg"
if WORDPRESS_PACKAGE="$pkg" nix flake check --impure ./dev; then
last_success="$pkg"
else
echo "❌ Check failed for $pkg"
break
fi
done
if [[ -n "$last_success" ]]; then
echo -e "\n✅ Last successful version: $last_success"
last_updated=$(git log -1 --format="%ci")
# Extract version from first_pkg (e.g., wordpress_6_8_1 → 6.8.1)
requires="${last_success#wordpress_}"
requires="${requires//_/.}"
requires="${requires%.*}" # Remove the patch version
tested="${first_pkg#wordpress_}"
tested="${tested//_/.}"
tested="${tested%.*}"
# Update using jq
TMPUPDATE=$(mktemp)
jq --arg requires "$requires" --arg tested "$tested" --arg last_updated "$last_updated" \
'.requires = $requires | .tested = $tested | .last_updated = $last_updated' \
update.json > "$TMPUPDATE" && mv "$TMPUPDATE" update.json
else
echo -e "\n❌ No successful checks."
fi