Skip to content

Commit 43f4aee

Browse files
ci: add blocking source+sha256 validation to pkgbuild checks (#7)
Verifies pkgver format, that source tracks pkgver, and that the declared sha256 matches the npm registry tarball. Dry-run verified locally against 0.17.1.
1 parent 7e5ad80 commit 43f4aee

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

‎.github/workflows/validate-pkgbuild.yml‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,34 @@ jobs:
9696
namcap PKGBUILD || true
9797
namcap .SRCINFO || true
9898
'
99+
100+
source-sha-validation:
101+
name: Source URL + SHA256 validation
102+
runs-on: ubuntu-latest
103+
steps:
104+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
105+
106+
- name: Verify PKGBUILD source matches registry tarball sha256
107+
run: |
108+
set -euo pipefail
109+
PKGNAME="$(grep -E '^pkgname=' PKGBUILD | cut -d= -f2)"
110+
PKGVER="$(grep -E '^pkgver=' PKGBUILD | cut -d= -f2)"
111+
EXPECTED="$(grep -Eo "[0-9a-f]{64}" PKGBUILD | head -1)"
112+
test -n "$PKGNAME" || { echo "::error::PKGBUILD: no pkgname found"; exit 1; }
113+
test -n "$PKGVER" || { echo "::error::PKGBUILD: no pkgver found"; exit 1; }
114+
test -n "$EXPECTED" || { echo "::error::PKGBUILD: no sha256sum found"; exit 1; }
115+
echo "$PKGVER" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+([a-zA-Z0-9.-]+)?$' || {
116+
echo "::error::PKGBUILD: unexpected pkgver format: $PKGVER"
117+
exit 1
118+
}
119+
grep -E '^source=' PKGBUILD | grep -Eq 'pkgver' || { echo "::error::PKGBUILD: source does not track pkgver"; exit 1; }
120+
URL="https://registry.npmjs.org/${PKGNAME}/-/${PKGNAME}-${PKGVER}.tgz"
121+
TMP="$(mktemp)"
122+
curl -sfL "$URL" -o "$TMP"
123+
ACTUAL="$(sha256sum "$TMP" | cut -d' ' -f1)"
124+
rm -f "$TMP"
125+
if [ "$ACTUAL" != "$EXPECTED" ]; then
126+
echo "::error::PKGBUILD: sha256 mismatch (pkgbuild=$EXPECTED registry=$ACTUAL)"
127+
exit 1
128+
fi
129+
echo "Source + SHA256 OK: $URL"

0 commit comments

Comments
 (0)