Skip to content

Commit 8a4cc54

Browse files
committed
chore(ci): add workflow to validate gpg/ folders content (#36)
1 parent d6919b2 commit 8a4cc54

File tree

5 files changed

+72
-1
lines changed

5 files changed

+72
-1
lines changed

.github/workflows/ci.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,44 @@ 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+
fetch-depth: 0 # We need 0 to validate the git commit signatures.
49+
persist-credentials: false
50+
- name: Export pubring content
51+
run: |
52+
for dir in gpg gpg-only-active-keys; do
53+
gpg --no-default-keyring --keyring "$dir/pubring.kbx" --list-keys --with-colons > "$dir/all-keys.list"
54+
gpg --no-default-keyring --keyring "$dir/pubring.kbx" --export --armor > "$dir/all-keys.asc"
55+
git add "$dir/all-keys.list" "$dir/all-keys.asc"
56+
done
57+
- name: Re-generate gpg folders
58+
run: |
59+
./generate-gpg-dir.sh
60+
for dir in gpg gpg-only-active-keys; do
61+
gpg --no-default-keyring --keyring "$dir/pubring.kbx" --list-keys --with-colons > "$dir/all-keys.list"
62+
gpg --no-default-keyring --keyring "$dir/pubring.kbx" --export --armor > "$dir/all-keys.asc"
63+
done
64+
- run: git diff --exit-code -- gpg/all-keys.list gpg/all-keys.asc gpg-only-active-keys/all-keys.list gpg-only-active-keys/all-keys.asc
65+
66+
- name: Verify if there are any keyring changes
67+
id: keyring-changes
68+
run: |
69+
git diff --exit-code --quiet ${{ github.event.before || 'HEAD^' }} -- gpg/ || echo "HAS_CHANGED=true" >> "$GITHUB_OUTPUT"
70+
git diff --exit-code --quiet ${{ github.event.before || 'HEAD^' }} -- gpg-only-active-keys/ || echo "HAS_ACTIVE_CHANGED=true" >> "$GITHUB_OUTPUT"
71+
72+
- name: Validate that all non-v0.x releases can be verified using the keyring
73+
if: steps.keyring-changes.outputs.HAS_CHANGED == 'true'
74+
run: |
75+
curl https://nodejs.org/dist/index.json \
76+
| jq -r '.[].version | select(startswith("v0.") | not)' \
77+
| while read -r VERSION; do
78+
echo "Checking $VERSION..."
79+
curl --silent "https://nodejs.org/dist/${VERSION}/SHASUMS256.txt.asc" \
80+
| gpgv --keyring="gpg/pubring.kbx"
81+
done

generate-gpg-dir.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
cp -R "$GNUPGHOME" "$ONLY_ACTIVE_KEYS"
28+
29+
awk -F'`' '/^<!-- Retired keys -->$/,/^<!-- .Retired keys -->$/ {if($1 == " [") print substr($3, 3, length($3) - 3) }' README.md | while read -r KEY_PATH; do
30+
GNUPGHOME="$GNUPGHOME" gpg --import "$KEY_PATH"
31+
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)