From abbd9eda34acc7dc60fc8e430f487ed59c535d9e Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Mon, 13 Jul 2026 16:06:41 -0700 Subject: [PATCH] Read signing key from 1pw --- README.md | 2 +- bin/omarchy-iso-sign | 46 ++++++++++++++++++++++++++++++++++++++------ 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 5a2b9c9..d83ccd3 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Run `./bin/omarchy-iso-boot [release/omarchy.iso]`. ## Signing the ISO -Run `./bin/omarchy-iso-sign [gpg-user] [release/omarchy.iso]`. +Run `./bin/omarchy-iso-sign [release/omarchy.iso]`. The signing key is retrieved from the shared Omarchy vault with the 1Password CLI. ## Uploading the ISO diff --git a/bin/omarchy-iso-sign b/bin/omarchy-iso-sign index f852cbf..9d8865d 100755 --- a/bin/omarchy-iso-sign +++ b/bin/omarchy-iso-sign @@ -1,14 +1,48 @@ #!/bin/bash -if [ $# -eq 0 ]; then +set -euo pipefail + +if [[ $# -ne 1 ]]; then echo "usage: omarchy-iso-sign [release/omarchy.iso]" exit 1 fi -if ! pacman -Q gnupg >/dev/null; then - sudo pacman -S --noconfirm --needed --quiet gnupg - echo "You'll need to import key with: gpg --import path/to/signing-key.asc" +iso="$1" +key_ref="op://Shared/Omarchy GPG Private Key/omarchy-private.asc" + +if [[ ! -f $iso ]]; then + echo "ISO not found: $iso" >&2 + exit 1 fi -gnupg_user_key=$(gpg --list-secret-keys --keyid-format=long | awk '/^[[:space:]]/{print $1; exit}') -gpg --local-user "$gnupg_user_key" --output $1.sig --detach-sig $1 +if ! command -v op >/dev/null; then + echo "1Password CLI is required to retrieve the signing key." >&2 + exit 1 +fi + +if ! pacman -Q gnupg >/dev/null 2>&1; then + sudo pacman -S --noconfirm --needed --quiet gnupg +fi + +gnupg_home="$(mktemp -d)" +chmod 700 "$gnupg_home" +trap 'rm -rf "$gnupg_home"' EXIT + +op read "$key_ref" --account Omarchy | + gpg --batch --homedir "$gnupg_home" --import >/dev/null + +signing_key="$( + gpg --batch --homedir "$gnupg_home" --with-colons --list-secret-keys | + awk -F: '$1 == "fpr" { print $10; exit }' +)" + +if [[ -z $signing_key ]]; then + echo "No private signing key found in $key_ref" >&2 + exit 1 +fi + +gpg --batch --yes \ + --homedir "$gnupg_home" \ + --local-user "$signing_key" \ + --output "$iso.sig" \ + --detach-sig "$iso"