Skip to content

Commit 3c3933d

Browse files
committed
chore(ci): add workflow to validate gpg/ folders content (#36)
1 parent c8a2744 commit 3c3933d

File tree

5 files changed

+74
-1
lines changed

5 files changed

+74
-1
lines changed

.github/workflows/ci.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,46 @@ jobs:
6060
}
6161
done
6262
shell: bash # See https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference, we want the pipefail option.
63+
64+
lint-pubring:
65+
if: github.event.pull_request.draft == false
66+
runs-on: ubuntu-latest
67+
steps:
68+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
69+
with:
70+
fetch-depth: 0 # We need 0 to validate the git commit signatures.
71+
persist-credentials: false
72+
73+
- name: Check if there are any keyring changes
74+
id: keyring-changes
75+
run: |
76+
git diff --exit-code --quiet ${{ github.event_name == 'push' && github.event.before || 'HEAD^' }} -- gpg/ || echo "HAS_CHANGED=true" >> "$GITHUB_OUTPUT"
77+
git diff --exit-code --quiet ${{ github.event_name == 'push' && github.event.before || 'HEAD^' }} -- gpg-only-active-keys/ || echo "HAS_ACTIVE_CHANGED=true" >> "$GITHUB_OUTPUT"
78+
79+
- name: Export pubring content
80+
run: |
81+
for dir in gpg gpg-only-active-keys; do
82+
gpg --no-default-keyring --keyring "$dir/pubring.kbx" --list-keys --with-colons > "$dir/all-keys.list"
83+
gpg --no-default-keyring --keyring "$dir/pubring.kbx" --export --armor > "$dir/all-keys.asc"
84+
git add "$dir/all-keys.list" "$dir/all-keys.asc"
85+
done
86+
- name: Re-generate gpg folders
87+
run: |
88+
./generate-gpg-dir.sh
89+
for dir in gpg gpg-only-active-keys; do
90+
gpg --no-default-keyring --keyring "$dir/pubring.kbx" --list-keys --with-colons > "$dir/all-keys.list"
91+
gpg --no-default-keyring --keyring "$dir/pubring.kbx" --export --armor > "$dir/all-keys.asc"
92+
done
93+
- 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
94+
95+
- name: Validate that all non-v0.x releases can be verified using the keyring
96+
if: steps.keyring-changes.outputs.HAS_CHANGED == 'true'
97+
run: |
98+
curl -fs https://nodejs.org/dist/index.json \
99+
| jq -er '.[].version | select(startswith("v0.") | not)' \
100+
| while read -r VERSION; do
101+
echo "Checking $VERSION..."
102+
curl -fs "https://nodejs.org/dist/${VERSION}/SHASUMS256.txt.asc" \
103+
| gpgv --keyring="gpg/pubring.kbx"
104+
done
105+
shell: bash # See https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference, we want the pipefail option.

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)