Skip to content

Commit 239e272

Browse files
authored
Merge pull request #1 from andreas-timm/feature/release
feat(release): semantic-release automation and 0.2.0 changelog
2 parents 674db12 + a51af90 commit 239e272

22 files changed

Lines changed: 4084 additions & 364 deletions

.github/workflows/ci.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,24 @@ jobs:
2828
- name: Setup Bun
2929
uses: oven-sh/setup-bun@v2
3030

31-
- name: Cache Bun dependencies
31+
- name: Setup pnpm
32+
uses: pnpm/action-setup@v6
33+
34+
- name: Cache pnpm store
3235
uses: actions/cache@v4
3336
with:
34-
path: ~/.bun/install/cache
35-
key: ${{ runner.os }}-bun-${{ hashFiles('bun.lock') }}
37+
path: ~/.local/share/pnpm/store
38+
key: ${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
3639
restore-keys: |
37-
${{ runner.os }}-bun-
40+
${{ runner.os }}-pnpm-
3841
3942
- name: Install system test dependencies
4043
run: |
4144
sudo apt-get update
4245
sudo apt-get install -y expect zsh
4346
4447
- name: Install dependencies
45-
run: bun install --frozen-lockfile
48+
run: pnpm install --frozen-lockfile
4649

4750
- name: Lint and typecheck
4851
run: bun lint
@@ -54,7 +57,7 @@ jobs:
5457
run: bun run build
5558

5659
- name: Audit dependencies
57-
run: bun audit --audit-level=moderate
60+
run: pnpm audit --audit-level=moderate
5861

5962
- name: Check npm package contents
6063
run: npm pack --dry-run --json

.github/workflows/publish.yml

Lines changed: 0 additions & 117 deletions
This file was deleted.
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
required_vars=(
5+
GITHUB_ENV
6+
GITHUB_RUN_ATTEMPT
7+
GITHUB_RUN_ID
8+
RELEASE_GIT_EMAIL
9+
RELEASE_GIT_NAME
10+
RELEASE_GPG_PRIVATE_KEY
11+
RUNNER_TEMP
12+
)
13+
14+
for var in "${required_vars[@]}"; do
15+
if [ -z "${!var:-}" ]; then
16+
echo "::error::Set ${var} before configuring release signing."
17+
exit 1
18+
fi
19+
done
20+
21+
mkdir -m 700 -p ~/.gnupg
22+
chmod 700 ~/.gnupg
23+
echo "allow-loopback-pinentry" >> ~/.gnupg/gpg-agent.conf
24+
gpgconf --kill gpg-agent || true
25+
26+
# Accept either a raw ASCII-armored key or a base64-encoded one.
27+
release_key="$RELEASE_GPG_PRIVATE_KEY"
28+
if ! printf '%s' "$release_key" | grep -q 'BEGIN PGP PRIVATE KEY'; then
29+
release_key="$(printf '%s' "$RELEASE_GPG_PRIVATE_KEY" | base64 --decode 2>/dev/null || true)"
30+
fi
31+
if ! printf '%s' "$release_key" | grep -q 'BEGIN PGP PRIVATE KEY'; then
32+
echo "::error::RELEASE_GPG_PRIVATE_KEY is neither an ASCII-armored nor base64-encoded private key block."
33+
echo "::error::Re-run: gpg --armor --export-secret-subkeys '<SIGNING_SUBKEY_FPR>!' | gh secret set RELEASE_GPG_PRIVATE_KEY --body-file -"
34+
exit 1
35+
fi
36+
printf '%s\n' "$release_key" | gpg --batch --yes --import
37+
38+
cat > "$RUNNER_TEMP/gpg-loopback" <<'EOF'
39+
#!/usr/bin/env bash
40+
exec gpg --batch --yes --pinentry-mode loopback "$@"
41+
EOF
42+
chmod 700 "$RUNNER_TEMP/gpg-loopback"
43+
44+
cat > "$RUNNER_TEMP/semantic-release-tag-editor" <<'EOF'
45+
#!/usr/bin/env bash
46+
printf 'semantic-release signed release tag\n' > "$1"
47+
EOF
48+
chmod 700 "$RUNNER_TEMP/semantic-release-tag-editor"
49+
50+
# Derive the signing (sub)key fingerprint from the imported key material,
51+
# preferring a signing-capable subkey and falling back to the primary.
52+
signing_fpr="$(
53+
gpg --batch --with-colons --list-secret-keys --with-subkey-fingerprints |
54+
awk -F: '
55+
$1 == "ssb" && $12 ~ /s/ { want = 1; next }
56+
$1 == "fpr" && want { print $10; exit }
57+
$1 == "sec" || $1 == "ssb" { want = 0 }
58+
'
59+
)"
60+
if [ -z "$signing_fpr" ]; then
61+
signing_fpr="$(
62+
gpg --batch --with-colons --list-secret-keys --with-subkey-fingerprints |
63+
awk -F: '
64+
$1 == "sec" && $12 ~ /s/ { want = 1; next }
65+
$1 == "fpr" && want { print $10; exit }
66+
'
67+
)"
68+
fi
69+
if [ -z "$signing_fpr" ]; then
70+
echo "::error::RELEASE_GPG_PRIVATE_KEY has no signing-capable key."
71+
exit 1
72+
fi
73+
74+
git config user.name "$RELEASE_GIT_NAME"
75+
git config user.email "$RELEASE_GIT_EMAIL"
76+
git config user.signingkey "${signing_fpr}!"
77+
git config gpg.program "$RUNNER_TEMP/gpg-loopback"
78+
git config commit.gpgsign true
79+
git config tag.gpgSign true
80+
81+
test_tag="semantic-release-gpg-check-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
82+
trap 'git tag -d "$test_tag" >/dev/null 2>&1 || true' EXIT
83+
GIT_EDITOR="$RUNNER_TEMP/semantic-release-tag-editor" git tag "$test_tag" HEAD
84+
git tag -v "$test_tag"
85+
86+
{
87+
echo "GIT_AUTHOR_NAME=$RELEASE_GIT_NAME"
88+
echo "GIT_AUTHOR_EMAIL=$RELEASE_GIT_EMAIL"
89+
echo "GIT_COMMITTER_NAME=$RELEASE_GIT_NAME"
90+
echo "GIT_COMMITTER_EMAIL=$RELEASE_GIT_EMAIL"
91+
echo "GIT_EDITOR=$RUNNER_TEMP/semantic-release-tag-editor"
92+
} >> "$GITHUB_ENV"

0 commit comments

Comments
 (0)