diff --git a/increment_and_push.sh b/increment_and_push.sh new file mode 100755 index 0000000..b2914a0 --- /dev/null +++ b/increment_and_push.sh @@ -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." diff --git a/package.json b/package.json index 357598d..1a608fd 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/www/index.html b/www/index.html index cb4b345..3650b1e 100644 --- a/www/index.html +++ b/www/index.html @@ -238,7 +238,7 @@