Add a script to bump the version across web, ios, android

This commit is contained in:
Jon Staab 2026-08-18 15:20:30 -07:00
parent d5dbb7fba1
commit e8455f2c8d
11 changed files with 60 additions and 7 deletions

View file

@ -206,7 +206,7 @@ pnpm run check # Type check
**Welshman Development:**
- Clone welshman to parent directory
- Use `./link_deps` script to link local welshman packages
- Use `./scripts/link-deps.mjs` to link local welshman packages
- Avoid committing `pnpm.overrides` changes
**Git Workflow:**

View file

@ -4,7 +4,7 @@
# docker run -p 3000:3000 flotilla
#
# Pass --build-arg VITE_BUILD_HASH=$(git rev-parse --short HEAD) to stamp the build.
# A .env in the build context is picked up by build.sh for branding config.
# A .env in the build context is picked up by scripts/build.sh for branding config.
# https://pnpm.io/docker#example-3-build-on-cicd
FROM node:24-slim AS builder

View file

@ -37,7 +37,7 @@ You can also optionally create an `.env.local` file and populate it with the fol
- `VITE_POMADE_SIGNERS` - A comma-separated list of Pomade signer server URLs (3+ required to enable email signup)
- `VITE_THUMBNAIL_URL` - URL of the image thumbnail service
These values **won't** be used for a built version. Instead, env variables should be provided to `build.sh` directly or to the built container.
These values **won't** be used for a built version. Instead, env variables should be provided to `scripts/build.sh` directly or to the built container.
If you're deploying a custom version of flotilla, be sure to remove the `plausible.coracle.social` script from `app.html`. This sends analytics to a server hosted by the developer.

View file

@ -4,10 +4,11 @@
"private": true,
"scripts": {
"dev": "vite dev",
"build": "./build.sh",
"build": "./scripts/build.sh",
"build:server": "vite build --config vite.config.server.ts",
"start": "node server.js",
"release:android": "./build.sh && cap build android --androidreleasetype APK --signing-type apksigner",
"release:android": "./scripts/build.sh && cap build android --androidreleasetype APK --signing-type apksigner",
"bump": "node scripts/bump-version.mjs",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --check src e2e playwright.config.ts && eslint src e2e",
@ -28,6 +29,7 @@
"@types/node": "^25.9.1",
"@types/ws": "^8.18.1",
"autoprefixer": "^10.4.23",
"capacitor-set-version": "^2.2.0",
"classnames": "^2.5.1",
"eslint": "^9.39.2",
"eslint-config-prettier": "^9.1.2",

Binary file not shown.

View file

@ -1,4 +1,4 @@
# Allow link_deps to change stuff in the working tree
# Allow link-deps.mjs to change stuff in the working tree
verifyDepsBeforeRun: warn
allowBuilds:
@ -7,6 +7,7 @@ allowBuilds:
esbuild: false
sharp: true
nostr-signer-capacitor-plugin@https://codeload.github.com/coracle-social/nostr-signer-capacitor-plugin/tar.gz/436adec9ed1e71569748cd56aa697f361e7a8d47: true
yarn: false
minimumReleaseAgeExclude:
- '@pomade/core'
- '@welshman/app'

50
scripts/bump-version.mjs Executable file
View file

@ -0,0 +1,50 @@
#!/usr/bin/env node
// Bumps the version in package.json and syncs it to android and ios via
// capacitor-set-version. Android and iOS build numbers have diverged
// historically, so each platform keeps its own counter, incremented only when
// its marketing version actually changes (re-running with the same version is
// a no-op).
import {readFileSync, writeFileSync} from "node:fs"
import {setAndroidVersionAndBuild} from "capacitor-set-version/dist/common/utils-android.js"
import {setIOSVersionAndBuild} from "capacitor-set-version/dist/common/utils-ios.js"
const arg = process.argv[2] || "patch"
const pkg = JSON.parse(readFileSync("package.json", "utf-8"))
let version
if (/^\d+\.\d+\.\d+$/.test(arg)) {
version = arg
} else {
const [major, minor, patch] = pkg.version.split(".").map(Number)
if (arg === "major") {
version = `${major + 1}.0.0`
} else if (arg === "minor") {
version = `${major}.${minor + 1}.0`
} else if (arg === "patch") {
version = `${major}.${minor}.${patch + 1}`
} else {
console.error(`Usage: pnpm bump [major|minor|patch|x.y.z] (got "${arg}")`)
process.exit(1)
}
}
const gradle = readFileSync("android/app/build.gradle", "utf-8")
const pbxproj = readFileSync("ios/App/App.xcodeproj/project.pbxproj", "utf-8")
const androidVersion = gradle.match(/versionName "(.+)"/)[1]
const androidBuild = Number(gradle.match(/versionCode (\d+)/)[1])
const iosVersion = pbxproj.match(/MARKETING_VERSION = (.+);/)[1]
const iosBuild = Number(pbxproj.match(/CURRENT_PROJECT_VERSION = (\d+);/)[1])
pkg.version = version
writeFileSync("package.json", JSON.stringify(pkg, null, 2) + "\n")
const nextAndroidBuild = version === androidVersion ? androidBuild : androidBuild + 1
const nextIosBuild = version === iosVersion ? iosBuild : iosBuild + 1
setAndroidVersionAndBuild(".", version, nextAndroidBuild)
setIOSVersionAndBuild(".", version, nextIosBuild)
console.log(`android: ${version} (${nextAndroidBuild})`)
console.log(`ios: ${version} (${nextIosBuild})`)

View file

@ -9,7 +9,7 @@ config({path: ".env"})
export default defineConfig({
// @welshman/editor takes tiptap as peer dependencies, so an installed copy resolves them from
// here and there is one prosemirror. link_deps symlinks its source instead, and that directory
// here and there is one prosemirror. link-deps.mjs symlinks its source instead, and that directory
// carries node_modules from welshman's own install — a second prosemirror, whose Plugin and
// PluginKey classes tiptap refuses to mix with ours ("Adding different instances of a keyed
// plugin"). Deduping resolves these to this project's copy wherever they are imported from, and