Skip to content

Commit 8d492e7

Browse files
committed
chore(ci): add workflow to validate gpg/ folder content
1 parent 8df28d5 commit 8d492e7

File tree

5 files changed

+58
-1
lines changed

5 files changed

+58
-1
lines changed

.github/workflows/ci.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,29 @@ jobs:
3838
echo
3939
sed -n '\#^<!-- /Retired keys -->$#,$p' README.md
4040
} | diff README.md -
41+
42+
lint-pubring:
43+
if: github.event.pull_request.draft == false
44+
runs-on: ubuntu-latest
45+
steps:
46+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
47+
with:
48+
persist-credentials: false
49+
- name: Export pubring content
50+
run: |
51+
gpg --no-default-keyring --keyring "gpg/pubring.kbx" --list-keys --with-colons > all-keys.list
52+
gpg --no-default-keyring --keyring "gpg/pubring.kbx" --export --armor > all-keys.asc
53+
git add all-keys.list all-keys.asc
54+
- name: Re-generate gpg folder
55+
run: |
56+
./generate-gpg-dir.sh
57+
gpg --no-default-keyring --keyring "gpg/pubring.kbx" --list-keys --with-colons > all-keys.list
58+
gpg --no-default-keyring --keyring "gpg/pubring.kbx" --export --armor > all-keys.asc
59+
- run: git diff --exit-code -- all-keys.list all-keys.asc
60+
61+
- name: Validate that all non-v0.x releases can be verified using the keyring
62+
run: |
63+
curl https://nodejs.org/dist/index.json | jq -r '.[].version | select(startswith("v0.") | not)' | while read -r VERSION; do
64+
echo "Checking $VERSION..."
65+
curl --silent "https://nodejs.org/dist/${VERSION}/SHASUMS256.txt.asc" | gpgv --keyring="gpg/pubring.kbx"
66+
done

generate-gpg-dir.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/sh
2+
3+
set -ex
4+
5+
GNUPGHOME=${1:-"$(cd "$(dirname "$0")"; pwd)/gpg"}
6+
ONLY_ACTIVE_KEYS=${2:-"$GNUPGHOME-only-active-keys"}
7+
8+
if [ -d "$GNUPGHOME" ]; then
9+
# If folder exists, move it to a temp dir
10+
# Removing it could be dangerous
11+
TRASH=$(mktemp -d)
12+
mv "$GNUPGHOME" "$TRASH"
13+
fi
14+
if [ -d "$ONLY_ACTIVE_KEYS" ]; then
15+
# If folder exists, move it to a temp dir
16+
# Removing it could be dangerous
17+
TRASH=$(mktemp -d)
18+
mv "$ONLY_ACTIVE_KEYS" "$TRASH"
19+
fi
20+
21+
mkdir -p "$GNUPGHOME"
22+
23+
awk -F'`' '/^<!-- Active releasers keys -->$/,/^<!-- .Active releasers keys -->$/ {if($1 == " [") print substr($3, 3, length($3) - 3) }' README.md | while read -r KEY_PATH; do
24+
GNUPGHOME="$GNUPGHOME" gpg --import "$KEY_PATH"
25+
done
26+
27+
# TODO: add a "active-keys-only" keyring
28+
# cp -R "$GNUPGHOME" "$ONLY_ACTIVE_KEYS"
29+
30+
awk -F'`' '/^<!-- Retired keys -->$/,/^<!-- .Retired keys -->$/ {if($1 == " [") print substr($3, 3, length($3) - 3) }' README.md | while read -r KEY_PATH; do
31+
GNUPGHOME="$GNUPGHOME" gpg --import "$KEY_PATH"
32+
done

gpg/crls.d/DIR.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

gpg/pubring.kbx

720 Bytes
Binary file not shown.

gpg/trustdb.gpg

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)