11name : " Generate list of latest keyrings for Debian & Ubuntu"
2+
23on :
34 workflow_dispatch :
45 repository_dispatch :
@@ -13,41 +14,145 @@ jobs:
1314 runs-on : ubuntu-24.04
1415 name : " Generate Keyring Data"
1516 steps :
16-
1717 - name : Checkout repository
1818 uses : actions/checkout@v5
1919 with :
2020 fetch-depth : 0
2121 path : armbian.github.io
2222
23- - name : " Generate keyring files"
23+ - name : " Find and download latest keyrings"
24+ shell : bash
2425 run : |
25- NEWEST_SUITE=$(curl --max-time 30 --compressed -fLs https://changelogs.ubuntu.com/meta-release | grep '^Dist:'| tail -n 1 | awk '{print $NF}')
26- # NOTE: this service on PUC returns a long list of ISO-3166-2 country code prefixed archive.ubuntu.com mirrors [among others]
27- # We remove that prefix as it's better to use the rotation. the number in the regex is b/c nz has nz and nz2
28- # example URL returned: http://nz2.archive.ubuntu.com/ubuntu/pool/main/u/ubuntu-keyring/ubuntu-keyring_2023.11.28.1_all.deb
29- PKG_URL=$(curl --max-time 30 --compressed -fLs "https://packages.ubuntu.com/${NEWEST_SUITE}/all/ubuntu-keyring/download" | \
30- grep -oP 'https?://\S+archive.ubuntu.com/ubuntu/pool/main/u/\S+\.deb' | tail -n 1 | sed -E 's#://[a-z][a-z][0-9]?\.#://#')
31- [[ -z "${PKG_URL}" ]] && (echo "fetch_newest_keyring failed - unable to find newest ubuntu-keyring package"; exit 1)
32- echo $PKG_URL > latest-ubuntu-keyring.txt
33-
34- for p in debian-archive-keyring debian-ports-archive-keyring; do
35- PKG_URL=$(curl --max-time 30 --compressed -fLs "https://packages.debian.org/sid/all/${p}/download" | \
36- grep -oP "https?://(deb|ftp)\.debian\.org/debian/pool/main/d/${p}/${p}_\S+\.deb")
37- [[ -z "${PKG_URL}" ]] && (echo "fetch_newest_keyring failed - unable to find newest $p package"; exit 1)
38- echo $PKG_URL > latest-$p.txt
26+ set -euo pipefail
27+
28+ retry_curl() {
29+ # Usage: retry_curl <url> [output]
30+ local url="$1"
31+ local out="${2:-}"
32+ if [[ -n "$out" ]]; then
33+ curl --max-time 60 --retry 3 --retry-all-errors --compressed -fL "$url" -o "$out"
34+ else
35+ curl --max-time 60 --retry 3 --retry-all-errors --compressed -fL "$url"
36+ fi
37+ }
38+
39+ workdir="$(mktemp -d)"
40+ echo "Workdir: $workdir"
41+
42+ # --- Ubuntu latest suite and keyring URL ---
43+ # Use Ubuntu meta-release to determine the newest listed suite.
44+ NEWEST_SUITE=$(retry_curl "https://changelogs.ubuntu.com/meta-release" \
45+ | grep '^Dist:' | awk '{print $NF}' | tail -n 1)
46+
47+ if [[ -z "${NEWEST_SUITE:-}" ]]; then
48+ echo "ERROR: Unable to detect Ubuntu newest suite" >&2
49+ exit 1
50+ fi
51+
52+ echo "Newest Ubuntu suite: $NEWEST_SUITE"
53+
54+ # Grab an archive.ubuntu.com link to ubuntu-keyring .deb, prefer rotation (drop cc/ccN prefix).
55+ UB_PAGE_URL="https://packages.ubuntu.com/${NEWEST_SUITE}/all/ubuntu-keyring/download"
56+ UB_PKG_URL=$(retry_curl "$UB_PAGE_URL" \
57+ | grep -oP 'https?://\S+archive\.ubuntu\.com/ubuntu/pool/main/u/\S+\.deb' \
58+ | tail -n 1 \
59+ | sed -E 's#://[a-z][a-z][0-9]?\.#://#')
60+
61+ if [[ -z "${UB_PKG_URL:-}" ]]; then
62+ echo "ERROR: Unable to find ubuntu-keyring package URL from $UB_PAGE_URL" >&2
63+ exit 1
64+ fi
65+
66+ echo "Ubuntu keyring URL: $UB_PKG_URL"
67+
68+ # --- Debian keyrings (sid pages list the latest available versions) ---
69+ declare -a DEB_PKGS=(debian-archive-keyring debian-ports-archive-keyring)
70+ declare -A DEB_URLS=()
71+
72+ for p in "${DEB_PKGS[@]}"; do
73+ DEB_PAGE_URL="https://packages.debian.org/sid/all/${p}/download"
74+ # Prefer deb.debian.org or ftp.debian.org
75+ url=$(retry_curl "$DEB_PAGE_URL" \
76+ | grep -oP 'https?://(deb|ftp)\.debian\.org/debian/pool/main/d/[^/]+/[^"]+\.deb' \
77+ | head -n 1 || true)
78+ if [[ -z "${url:-}" ]]; then
79+ echo "ERROR: Unable to find ${p} package URL from $DEB_PAGE_URL" >&2
80+ exit 1
81+ fi
82+ DEB_URLS["$p"]="$url"
83+ echo "Debian $p URL: ${DEB_URLS[$p]}"
84+ done
85+
86+ # --- Download all files to the temp workdir ---
87+ declare -a DOWNLOADED=()
88+
89+ fname_ubuntu="$(basename "$UB_PKG_URL")"
90+ retry_curl "$UB_PKG_URL" "$workdir/$fname_ubuntu"
91+ DOWNLOADED+=("$workdir/$fname_ubuntu")
92+
93+ for p in "${DEB_PKGS[@]}"; do
94+ f="$(basename "${DEB_URLS[$p]}")"
95+ retry_curl "${DEB_URLS[$p]}" "$workdir/$f"
96+ DOWNLOADED+=("$workdir/$f")
97+ done
98+
99+ # --- Stage into repo folder armbian.github.io/keyrings ---
100+ pushd armbian.github.io >/dev/null
101+
102+ # Work on the 'data' branch as before (create if missing locally)
103+ if ! git rev-parse --verify data >/dev/null 2>&1; then
104+ git fetch origin data || true
105+ fi
106+ git checkout data
107+
108+ mkdir -p keyrings
109+
110+ # Move files in (overwrite existing versions)
111+ for f in "${DOWNLOADED[@]}"; do
112+ base="$(basename "$f")"
113+ mv -f "$f" "keyrings/$base"
39114 done
115+
116+ # --- Create/update symlinks ---
117+ # Per-package latest symlinks
118+ # Resolve the expected basenames we just saved to infer symlink targets.
119+ ub_target="$fname_ubuntu"
120+ ln -sfn "$ub_target" "keyrings/latest-ubuntu-keyring.deb"
121+
122+ # Find the files we downloaded for Debian packages and symlink them
123+ for p in "${DEB_PKGS[@]}"; do
124+ # match first file starting with package name
125+ cand="$(ls -1 keyrings/${p}_*.deb 2>/dev/null | sort | tail -n 1 || true)"
126+ if [[ -n "$cand" ]]; then
127+ ln -sfn "$(basename "$cand")" "keyrings/latest-${p}.deb"
128+ fi
129+ done
130+
131+ # Generic 'latest' -> most recently modified of the just-downloaded files in keyrings
132+ latest_target="$(ls -1t keyrings/*.deb | head -n 1)"
133+ if [[ -n "$latest_target" ]]; then
134+ ln -sfn "$(basename "$latest_target")" "keyrings/latest"
135+ fi
136+
137+ popd >/dev/null
138+
40139 - name : Commit changes if any
140+ shell : bash
41141 run : |
142+ set -euo pipefail
42143 cd armbian.github.io
43144 git checkout data
44- mkdir -p data/
45- mv ${{ github.workspace }}/latest-*keyring*.txt data/
145+
46146 git config --global user.name "github-actions"
47147 git config --global user.email "[email protected] " 48- git add data/.
49- git diff --cached --quiet || git commit -m "Update keyring data files"
50- git push
148+ git add keyrings/
149+
150+ if ! git diff --cached --quiet; then
151+ git commit -m "Update keyrings: download latest .deb files and symlinks"
152+ git push
153+ else
154+ echo "No changes to commit."
155+ fi
51156
52157 - name : " Run Bigin update action"
53158 uses : peter-evans/repository-dispatch@v4
0 commit comments