diff --git a/.github/workflows/bump-version.yml b/.github/workflows/bump-version.yml new file mode 100644 index 00000000..de50d24c --- /dev/null +++ b/.github/workflows/bump-version.yml @@ -0,0 +1,68 @@ +name: Bump version on PR merge + +on: + pull_request: + branches: [master] + types: [closed] + +permissions: + contents: write + +jobs: + bump: + # Only run when the PR was actually merged (not just closed) + if: github.event.pull_request.merged == true + + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v5 + with: + # fetch-depth 2 so git diff HEAD~1 HEAD works for detecting changed files + fetch-depth: 2 + # Use a token so the pushed commit triggers deploy.yml + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Set up Node + uses: actions/setup-node@v6 + with: + node-version: lts/* + cache: npm + + - name: Determine bump type from PR labels + id: bump + run: | + LABELS='${{ toJSON(github.event.pull_request.labels.*.name) }}' + if echo "$LABELS" | grep -q '"major"'; then + echo "type=major" >> "$GITHUB_OUTPUT" + elif echo "$LABELS" | grep -q '"minor"'; then + echo "type=minor" >> "$GITHUB_OUTPUT" + else + echo "type=patch" >> "$GITHUB_OUTPUT" + fi + + - name: Run version bump script + run: node scripts/bump-version.js ${{ steps.bump.outputs.type }} + + - name: Commit and push bump + run: | + NEW_VERSION=$(node -e " + const m = require('fs') + .readFileSync('public/versioning.js', 'utf8') + .match(/const VERSION = \"([\d.]+)\"/); + console.log(m[1]); + ") + + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add . + + # Only commit if something actually changed + if ! git diff --cached --quiet; then + git commit -m "chore: bump version to $NEW_VERSION" + git push + echo "Pushed version bump → $NEW_VERSION" + else + echo "Nothing changed, skipping commit." + fi diff --git a/package-lock.json b/package-lock.json index fc45ca85..e607bc5c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "fantasy-map-generator", - "version": "1.113.6", + "version": "1.113.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "fantasy-map-generator", - "version": "1.113.6", + "version": "1.113.3", "license": "MIT", "dependencies": { "alea": "^1.0.1", diff --git a/package.json b/package.json index 190974d6..c6aa0ee6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fantasy-map-generator", - "version": "1.113.10", + "version": "1.113.3", "description": "Azgaar's _Fantasy Map Generator_ is a free web application that helps fantasy writers, game masters, and cartographers create and edit fantasy maps.", "homepage": "https://github.com/Azgaar/Fantasy-Map-Generator#readme", "bugs": { diff --git a/public/versioning.js b/public/versioning.js index 825a6306..9639d4dc 100644 --- a/public/versioning.js +++ b/public/versioning.js @@ -5,15 +5,18 @@ * We use Semantic Versioning: major.minor.patch. Refer to https://semver.org * Our .map file format is considered the public API. * - * Update the version MANUALLY on each merge to main: + * Update the version on each merge to main: * 1. MAJOR version: Incompatible changes that break existing maps * 2. MINOR version: Additions or changes that are backward-compatible but may require old .map files to be updated - * 3. PATCH version: Backward-compatible bug fixes and small features that do not affect the .map file format + * 3. PATCH version: Backward-compatible bug fixes and small features that don't affect the .map file format * * Example: 1.102.2 -> Major version 1, Minor version 102, Patch version 2 + * Version bumping is automated via GitHub Actions on PR merge. + * + * For the changes that may be interesting to end users, update the `latestPublicChanges` array below (new changes on top). */ -const VERSION = "1.113.10"; +const VERSION = "1.113.3"; if (parseMapVersion(VERSION) !== VERSION) alert("versioning.js: Invalid format or parsing function"); { @@ -26,6 +29,22 @@ if (parseMapVersion(VERSION) !== VERSION) alert("versioning.js: Invalid format o setTimeout(showUpdateWindow, 6000); } + const latestPublicChanges = [ + "Search input in Overview dialogs", + "Custom burg grouping and icon selection", + "Ability to set custom image as Marker or Regiment icon", + "Submap and Transform tools rework", + "Azgaar Bot to answer questions and provide help", + "Labels: ability to set letter spacing", + "Zones performance improvement", + "Notes Editor: on-demand AI text generation", + "New style preset: Dark Seas", + "New routes generation algorithm", + "Routes overview tool", + "Configurable longitude", + "Export zones to GeoJSON" + ]; + function showUpdateWindow() { const changelog = "https://github.com/Azgaar/Fantasy-Map-Generator/wiki/Changelog"; const reddit = "https://www.reddit.com/r/FantasyMapGenerator"; @@ -37,19 +56,7 @@ if (parseMapVersion(VERSION) !== VERSION) alert("versioning.js: Invalid format o
Join our Discord server and Reddit community to ask questions, share maps, discuss the Generator and Worlbuilding, report bugs and propose new features.
diff --git a/scripts/bump-version.js b/scripts/bump-version.js index 5604eb80..af4c35a3 100644 --- a/scripts/bump-version.js +++ b/scripts/bump-version.js @@ -12,8 +12,8 @@ * Usage: * node scripts/bump-version.js # interactive prompt * node scripts/bump-version.js patch # non-interactive - * node scripts/bump-version.js minor - * node scripts/bump-version.js major + * node scripts/bump-version.js minor # non-interactive + * node scripts/bump-version.js major # non-interactive * node scripts/bump-version.js --dry-run # preview only, no writes */ diff --git a/scripts/install-hooks.js b/scripts/install-hooks.js deleted file mode 100644 index d6bd825e..00000000 --- a/scripts/install-hooks.js +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env node -// Installs scripts/pre-push as .git/hooks/pre-push. -// Runs automatically via the `prepare` npm lifecycle hook (npm install). - -const fs = require("fs"); -const path = require("path"); - -const repoRoot = path.resolve(__dirname, ".."); -const hooksDir = path.join(repoRoot, ".git", "hooks"); -const source = path.join(repoRoot, "scripts", "pre-push"); -const target = path.join(hooksDir, "pre-push"); - -if (!fs.existsSync(path.join(repoRoot, ".git"))) { - // Not a git repo (e.g. Docker / CI build from tarball) — skip silently. - process.exit(0); -} - -if (!fs.existsSync(hooksDir)) { - fs.mkdirSync(hooksDir, {recursive: true}); -} - -try { - // Symlink so changes to scripts/pre-push are reflected immediately. - if (fs.existsSync(target) || fs.lstatSync(target).isSymbolicLink()) { - fs.unlinkSync(target); - } -} catch { - // Target doesn't exist yet — that's fine. -} - -fs.symlinkSync(source, target); -fs.chmodSync(source, 0o755); -console.log("[prepare] Installed git pre-push hook → .git/hooks/pre-push"); diff --git a/scripts/pre-push b/scripts/pre-push deleted file mode 100755 index 6e53cb5f..00000000 --- a/scripts/pre-push +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env sh -# Git pre-push hook — automatically bumps the version before pushing. -# Installed by: npm run prepare (scripts/install-hooks.js) -# -# Prompts for patch / minor / major (default: patch), updates: -# - public/versioning.js -# - package.json -# - src/index.html (cache-busting ?v= hashes for changed modules) -# then commits those changes so they are included in the push. - -set -e - -REPO_ROOT="$(git rev-parse --show-toplevel)" - -echo "" -node "$REPO_ROOT/scripts/bump-version.js" - -# Stage files that may have been modified by the bump -git add \ - "$REPO_ROOT/public/versioning.js" \ - "$REPO_ROOT/package.json" \ - "$REPO_ROOT/src/index.html" 2>/dev/null || true - -# Only commit if there are staged changes from the bump -if ! git diff --cached --quiet; then - NEW_VERSION=$(node -e "const f=require('fs');const m=f.readFileSync('$REPO_ROOT/public/versioning.js','utf8').match(/const VERSION = \"([\d.]+)\"/);console.log(m[1])") - git commit -m "chore: bump version to $NEW_VERSION" - echo "[pre-push] Committed version bump → $NEW_VERSION" -fi