Skip to content

Commit 6c9748d

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

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
@@ -58,5 +58,46 @@ jobs:
5858
curl --fail --silent "https://nodejs.org/dist/${VERSION}/SHASUMS256.txt.asc" \
5959
| gpgv --keyring=./pubring.kbx
6060
}
61+
62+
lint-pubring:
63+
if: github.event.pull_request.draft == false
64+
runs-on: ubuntu-latest
65+
steps:
66+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
67+
with:
68+
fetch-depth: 0 # We need 0 to validate the git commit signatures.
69+
persist-credentials: false
70+
71+
- name: Check if there are any keyring changes
72+
id: keyring-changes
73+
run: |
74+
git diff --exit-code --quiet ${{ github.event_name == 'push' && github.event.before || 'HEAD^' }} -- gpg/ || echo "HAS_CHANGED=true" >> "$GITHUB_OUTPUT"
75+
git diff --exit-code --quiet ${{ github.event_name == 'push' && github.event.before || 'HEAD^' }} -- gpg-only-active-keys/ || echo "HAS_ACTIVE_CHANGED=true" >> "$GITHUB_OUTPUT"
76+
77+
- name: Export pubring content
78+
run: |
79+
for dir in gpg gpg-only-active-keys; do
80+
gpg --no-default-keyring --keyring "$dir/pubring.kbx" --list-keys --with-colons > "$dir/all-keys.list"
81+
gpg --no-default-keyring --keyring "$dir/pubring.kbx" --export --armor > "$dir/all-keys.asc"
82+
git add "$dir/all-keys.list" "$dir/all-keys.asc"
83+
done
84+
- name: Re-generate gpg folders
85+
run: |
86+
./generate-gpg-dir.sh
87+
for dir in gpg gpg-only-active-keys; do
88+
gpg --no-default-keyring --keyring "$dir/pubring.kbx" --list-keys --with-colons > "$dir/all-keys.list"
89+
gpg --no-default-keyring --keyring "$dir/pubring.kbx" --export --armor > "$dir/all-keys.asc"
90+
done
91+
- 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
92+
93+
- name: Validate that all non-v0.x releases can be verified using the keyring
94+
if: steps.keyring-changes.outputs.HAS_CHANGED == 'true'
95+
run: |
96+
curl -fs https://nodejs.org/dist/index.json \
97+
| jq -er '.[].version | select(startswith("v0.") | not)' \
98+
| while read -r VERSION; do
99+
echo "Checking $VERSION..."
100+
curl -fs "https://nodejs.org/dist/${VERSION}/SHASUMS256.txt.asc" \
101+
| gpgv --keyring="gpg/pubring.kbx"
61102
done
62103
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)