Add version control: increment_and_push.sh, version.json, version display in page titles, plus all security audit fixes
This commit is contained in:
Executable
+168
@@ -0,0 +1,168 @@
|
||||
#!/bin/bash
|
||||
|
||||
# increment_and_push.sh
|
||||
#
|
||||
# Automates version bumping based on git tags, then commits, tags, pushes,
|
||||
# and uploads the website to the server.
|
||||
#
|
||||
# Git tag is the authoritative source of truth for the version.
|
||||
#
|
||||
# Usage:
|
||||
# ./increment_and_push.sh "Your commit message here" # Bump patch (default)
|
||||
# ./increment_and_push.sh --minor "Your commit message" # Bump minor
|
||||
# ./increment_and_push.sh --major "Your commit message" # Bump major
|
||||
#
|
||||
# What this script does:
|
||||
# 1. Reads the latest git tag to determine the current version
|
||||
# 2. Increments the version (patch/minor/major)
|
||||
# 3. Updates www/js/version.json with the new version + build date
|
||||
# 4. Updates package.json with the new version number
|
||||
# 5. Rebuilds the PQ crypto bundle
|
||||
# 6. Stages all changes, commits with the provided message
|
||||
# 7. Creates a new git tag for the version
|
||||
# 8. Pushes commits + tags to remote
|
||||
# 9. Uploads the website to the server via upload.sh
|
||||
|
||||
set -e
|
||||
|
||||
VERSION_FILE="www/js/version.json"
|
||||
PACKAGE_FILE="package.json"
|
||||
BUMP_TYPE="patch"
|
||||
COMMIT_MSG=""
|
||||
|
||||
# Parse arguments
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--minor)
|
||||
BUMP_TYPE="minor"
|
||||
shift
|
||||
;;
|
||||
--major)
|
||||
BUMP_TYPE="major"
|
||||
shift
|
||||
;;
|
||||
--patch)
|
||||
BUMP_TYPE="patch"
|
||||
shift
|
||||
;;
|
||||
-*|--*)
|
||||
echo "Unknown option: $1"
|
||||
echo "Usage: $0 [--major|--minor|--patch] [commit message]"
|
||||
exit 1
|
||||
;;
|
||||
*)
|
||||
COMMIT_MSG="$1"
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Get the latest git tag (authoritative version)
|
||||
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
|
||||
echo "🔒 Post-Quantum Nostr — Version Increment"
|
||||
echo "=========================================="
|
||||
echo "Latest tag: $LATEST_TAG"
|
||||
echo "Bump type: $BUMP_TYPE"
|
||||
echo ""
|
||||
|
||||
# Parse version components
|
||||
VERSION=${LATEST_TAG#v} # Remove 'v' prefix
|
||||
MAJOR=$(echo "$VERSION" | cut -d. -f1)
|
||||
MINOR=$(echo "$VERSION" | cut -d. -f2)
|
||||
PATCH=$(echo "$VERSION" | cut -d. -f3)
|
||||
|
||||
# Handle missing components
|
||||
MAJOR=${MAJOR:-0}
|
||||
MINOR=${MINOR:-0}
|
||||
PATCH=${PATCH:-0}
|
||||
|
||||
# Increment version based on bump type
|
||||
case $BUMP_TYPE in
|
||||
major)
|
||||
MAJOR=$((MAJOR + 1))
|
||||
MINOR=0
|
||||
PATCH=0
|
||||
;;
|
||||
minor)
|
||||
MINOR=$((MINOR + 1))
|
||||
PATCH=0
|
||||
;;
|
||||
patch)
|
||||
PATCH=$((PATCH + 1))
|
||||
;;
|
||||
esac
|
||||
|
||||
NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}"
|
||||
NEW_TAG="v${NEW_VERSION}"
|
||||
echo "New version: $NEW_TAG ($BUMP_TYPE bump)"
|
||||
echo ""
|
||||
|
||||
# Prompt for commit message if not provided
|
||||
if [ -z "$COMMIT_MSG" ]; then
|
||||
echo "Enter commit message (or press Enter for default: \"Release $NEW_TAG\"):"
|
||||
read -r COMMIT_MSG
|
||||
if [ -z "$COMMIT_MSG" ]; then
|
||||
COMMIT_MSG="Release $NEW_TAG"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Commit message: $COMMIT_MSG"
|
||||
echo ""
|
||||
|
||||
# Update version.json
|
||||
cat > "$VERSION_FILE" << EOF
|
||||
{
|
||||
"VERSION": "$NEW_TAG",
|
||||
"VERSION_NUMBER": "$NEW_VERSION",
|
||||
"BUILD_DATE": "$(date -u +"%Y-%m-%dT%H:%M:%S.%3NZ")"
|
||||
}
|
||||
EOF
|
||||
echo "✅ Updated $VERSION_FILE"
|
||||
|
||||
# Update package.json version field
|
||||
if [ -f "$PACKAGE_FILE" ]; then
|
||||
# Use sed to replace the version line (works on both macOS and Linux)
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
sed -i '' "s/\"version\": \"[^\"]*\"/\"version\": \"$NEW_VERSION\"/" "$PACKAGE_FILE"
|
||||
else
|
||||
sed -i "s/\"version\": \"[^\"]*\"/\"version\": \"$NEW_VERSION\"/" "$PACKAGE_FILE"
|
||||
fi
|
||||
echo "✅ Updated $PACKAGE_FILE version to $NEW_VERSION"
|
||||
fi
|
||||
|
||||
# Rebuild the PQ crypto bundle
|
||||
echo ""
|
||||
echo "📦 Rebuilding PQ crypto bundle..."
|
||||
node build-pq-bundle.js
|
||||
echo "✅ Bundle rebuilt"
|
||||
echo ""
|
||||
|
||||
# Stage all changes (version files + any other modified/new files)
|
||||
git add .
|
||||
|
||||
# Commit with the provided message
|
||||
git commit -m "$COMMIT_MSG"
|
||||
|
||||
# Create new tag
|
||||
git tag "$NEW_TAG"
|
||||
|
||||
echo ""
|
||||
echo "✅ Committed and tagged: $NEW_TAG"
|
||||
echo ""
|
||||
|
||||
# Push commits + tags to remote
|
||||
git push origin master --tags
|
||||
echo "✅ Pushed to remote"
|
||||
echo ""
|
||||
|
||||
# Upload the website to the server
|
||||
echo "📤 Uploading website to server..."
|
||||
if [ -f "./upload.sh" ]; then
|
||||
chmod +x ./upload.sh
|
||||
./upload.sh
|
||||
else
|
||||
echo "⚠️ upload.sh not found — skipping website upload"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "🎉 Done! Version $NEW_TAG deployed."
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "post_quantum_nostr",
|
||||
"version": "1.1.0",
|
||||
"version": "0.0.1",
|
||||
"description": "A migration strategy for bringing post-quantum security to Nostr without breaking the social graph, without requiring consensus on a single post-quantum algorithm, and without forcing existing users to abandon their identities.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
||||
+14
-1
@@ -238,7 +238,7 @@
|
||||
<div id="divHeader">
|
||||
<div id="divHeaderFlexLeft"></div>
|
||||
<div id="divHeaderFlexCenter">
|
||||
<div class="divHeaderText">Post-Quantum Nostr</div>
|
||||
<div class="divHeaderText" id="divHeaderText">Post-Quantum Nostr</div>
|
||||
</div>
|
||||
<div id="divHeaderFlexRight">
|
||||
<button class="pq-button pq-button-secondary pq-hidden" id="pqSignOutBtn" style="width: auto; padding: 6px 16px; font-size: 13px;">Sign Out</button>
|
||||
@@ -617,6 +617,19 @@
|
||||
<script src="/nostr-login-lite/nostr.bundle.js"></script>
|
||||
<script src="/nostr-login-lite/nostr-lite.js"></script>
|
||||
|
||||
<!-- Version display: fetch version.json and update title + header -->
|
||||
<script>
|
||||
fetch('./js/version.json')
|
||||
.then(r => r.json())
|
||||
.then(v => {
|
||||
const versionText = v.VERSION || '';
|
||||
document.title = 'Post-Quantum Nostr ' + versionText;
|
||||
const header = document.getElementById('divHeaderText');
|
||||
if (header) header.textContent = 'Post-Quantum Nostr ' + versionText;
|
||||
})
|
||||
.catch(() => { /* version.json not found — keep default title */ });
|
||||
</script>
|
||||
|
||||
<script type="module">
|
||||
import {
|
||||
generateSeedPhrase,
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"VERSION": "v0.0.1",
|
||||
"VERSION_NUMBER": "0.0.1",
|
||||
"BUILD_DATE": "2026-07-17T23:05:15.755Z"
|
||||
}
|
||||
+14
-1
@@ -237,7 +237,7 @@
|
||||
<div id="divHeader">
|
||||
<div id="divHeaderFlexLeft"></div>
|
||||
<div id="divHeaderFlexCenter">
|
||||
<div class="divHeaderText">Verify NIP-QR Event</div>
|
||||
<div class="divHeaderText" id="divHeaderText">Verify NIP-QR Event</div>
|
||||
</div>
|
||||
<div id="divHeaderFlexRight"></div>
|
||||
</div>
|
||||
@@ -347,6 +347,19 @@
|
||||
<script src="/nostr-login-lite/nostr.bundle.js"></script>
|
||||
<script src="/nostr-login-lite/nostr-lite.js"></script>
|
||||
|
||||
<!-- Version display: fetch version.json and update title + header -->
|
||||
<script>
|
||||
fetch('./js/version.json')
|
||||
.then(r => r.json())
|
||||
.then(v => {
|
||||
const versionText = v.VERSION || '';
|
||||
document.title = 'Verify NIP-QR Event ' + versionText;
|
||||
const header = document.getElementById('divHeaderText');
|
||||
if (header) header.textContent = 'Verify NIP-QR Event ' + versionText;
|
||||
})
|
||||
.catch(() => { /* version.json not found — keep default title */ });
|
||||
</script>
|
||||
|
||||
<script type="module">
|
||||
import {
|
||||
verifyNIPQRContent,
|
||||
|
||||
Reference in New Issue
Block a user