Files
marco/scripts/publish-nip.sh
T
raucao 2fce1f532e Add NIP-89 app handler docs and Nostr publishing scripts
Document Marco's NIP-89 app handler (kind 31990) and recommendation
(kind 31989), and how the place NIPs are published on Nostr as kind 30817
custom NIPs.

Add shell scripts that build and publish these events via nak: the app
handler, a recommendation, and the NIP specs. The publishing relay list
lives in scripts/nostr-relays.txt for easy editing. Signing requires an
explicit NOSTR_SECRET_KEY (nsec or NIP-46 bunker URL), and the scripts
refuse to publish from the wrong identity.
2026-11-28 12:39:28 +04:00

77 lines
2.0 KiB
Bash
Executable File

#!/bin/sh
#
# Publish (or re-publish) one of Marco's NIPs as a kind 30817 "Custom NIP"
# ("NIPs on Nostr"). Kind 30817 is addressable, so re-running replaces the
# previous version (same author + "d" tag); the spec is updated, not forked.
#
# See doc/nostr/publishing.md.
#
# Usage:
# NOSTR_SECRET_KEY='...' ./scripts/publish-nip.sh [photos|reviews] [--dry-run]
#
set -eu
. "$(dirname "$0")/nostr-common.sh"
DRY_RUN=0
WHICH=photos
for arg in "$@"; do
case "$arg" in
--dry-run) DRY_RUN=1 ;;
photos | reviews) WHICH="$arg" ;;
*) die "unknown argument: $arg" ;;
esac
done
case "$WHICH" in
photos)
NIP_PATH="doc/nostr/nip-place-photos.md"
NIP_D="place-photos-and-videos"
NIP_TITLE="Place Photos and Videos"
NIP_KIND="360"
;;
reviews)
NIP_PATH="doc/nostr/nip-place-reviews.md"
NIP_D="place-reviews"
NIP_TITLE="Place Reviews"
NIP_KIND="30360"
;;
esac
# Allow running from anywhere: resolve paths against the repo root.
root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
NIP_FILE="$root/$NIP_PATH"
[ -f "$NIP_FILE" ] || die "spec not found: $NIP_FILE"
require_signer
# "status" is NostrHub metadata; the spec-defined tags are d/title/k (see
# doc/nostr/publishing.md). The "client" tag is deliberately not set.
event=$(
nak event --sec "$NAK_SEC" -k 30817 \
-d "$NIP_D" \
-t "title=$NIP_TITLE" \
-t "alt=Nostr Implementation Possibility: $NIP_TITLE" \
-t "k=$NIP_KIND;$NIP_TITLE" \
-t "status=review" \
-c "@$NIP_FILE"
)
pubkey=$(printf '%s\n' "$event" | event_pubkey)
[ -n "$pubkey" ] || die "could not read pubkey from the signed event"
assert_pubkey "$NIP_SPEC_PUBKEY" "$pubkey"
if [ "$DRY_RUN" = 1 ]; then
printf '%s\n' "$event"
echo "dry run: signed by $pubkey, not published" >&2
exit 0
fi
printf '%s\n' "$event" | nak event $NOSTR_RELAYS
echo "published NIP '$NIP_TITLE' (kind 30817) as $pubkey"
naddr=$(nak encode naddr -k 30817 -a "$pubkey" -d "$NIP_D" 2>/dev/null || true)
if [ -n "$naddr" ]; then
echo "naddr: $naddr"
fi