Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Freeze RC build numbers in the sources

Manav Rathiebfb38031ebc
diff --git a/.github/docs/app-release.md b/.github/docs/app-release.md
index a048c9a807..f56b70a62e 100644
--- a/.github/docs/app-release.md
+++ b/.github/docs/app-release.md
@@ -45,11 +45,12 @@ The workflow also opens a PR to move `main` to `0.1.17-beta`. Merge that PR afte
## Update the RC if needed
-Cherry pick fixes to the release branch and push to replace the current RC.
+Cherry pick fixes to the release branch and push to replace the current RC. For release branches the build number does not auto increment and needs to be manually incremented.
```sh
git switch release/ensu-v0.1.16
git cherry-pick <fix-sha>
+node .github/scripts/app-version.mjs ensu bump-build-and-commit
git push
```
@@ -80,6 +81,6 @@ It also opens a PR for updating the changelog in the docs.
> [!NOTE]
>
-> If a build has already reached Play Store or TestFlight, trigger a new workflow run instead of re-running failed jobs so that it gets a new build number.
+> Individual failed jobs can be re-run idempotently (e.g. if only the Android job failed, it can be re-run in place). Retrying the build as a whole is also fine, except when it has already reached Play Store or TestFlight, in which case it needs a fresh build number: for nightlies trigger a new workflow run, for RCs push a `bump-build-and-commit`.
`app-release.yml` changes release state. If it fails, inspect the failed step before re-running. After it has pushed a branch, created a tag, or moved a draft release, either finish the remaining step manually or undo the partial state first. Cleanup is intentionally late: `action=start` pushes the release branch before deleting the beta pre-release from `ente/nightly`, and `action=promote` deletes the release branch last.
diff --git a/.github/scripts/app-version.mjs b/.github/scripts/app-version.mjs
new file mode 100644
index 0000000000..65889547f8
--- /dev/null
+++ b/.github/scripts/app-version.mjs
@@ -0,0 +1,85 @@
+#!/usr/bin/env node
+
+import { execFileSync } from "node:child_process";
+import path from "node:path";
+import { fileURLToPath } from "node:url";
+
+const dir = path.dirname(fileURLToPath(import.meta.url));
+const root = path.resolve(dir, "../..");
+const [app, command, ...args] = process.argv.slice(2);
+
+const scripts = {
+ photos: ["flutter-version.mjs", "photos"],
+ auth: ["flutter-version.mjs", "auth"],
+ locker: ["flutter-version.mjs", "locker"],
+ ensu: ["ensu-version.mjs"],
+ "photos-desktop": ["photos-desktop-version.mjs"],
+};
+
+const versionFiles = {
+ photos: ["mobile/apps/photos/pubspec.yaml"],
+ auth: ["mobile/apps/auth/pubspec.yaml"],
+ locker: ["mobile/apps/locker/pubspec.yaml"],
+ ensu: [
+ "rust/apps/ensu/package.json",
+ "rust/apps/ensu/package-lock.json",
+ "rust/apps/ensu/src-tauri/tauri.conf.json",
+ "rust/apps/ensu/src-tauri/Cargo.toml",
+ "rust/Cargo.lock",
+ "mobile/native/android/apps/ensu/app/build.gradle.kts",
+ "mobile/native/apple/apps/ensu/Ensu.xcodeproj/project.pbxproj",
+ "mobile/native/apple/apps/ensu/Ensu/Info.plist",
+ ],
+};
+
+function usage() {
+ console.error(`Usage: node .github/scripts/app-version.mjs <app> <command> [args]
+
+Commands are forwarded to the app's version script, plus:
+ set-build-and-commit 0.1.16 34 set version and build number, then commit
+ bump-build-and-commit bump the build number, then commit (no-op for photos-desktop)
+
+Valid apps: ${Object.keys(scripts).join(", ")}`);
+}
+
+if (!scripts[app] || !command) {
+ usage();
+ process.exit(2);
+}
+
+function run(cmd, cmdArgs = [], opts = {}) {
+ const [script, ...prefix] = scripts[app];
+ return execFileSync("node", [path.join(dir, script), ...prefix, cmd, ...cmdArgs], {
+ encoding: "utf8",
+ ...opts,
+ });
+}
+
+function commitVersion() {
+ const capture = { stdio: ["ignore", "pipe", "inherit"] };
+ const version = run("get", [], capture).trim();
+ const build = run("get-build-base", [], capture).trim();
+ const title = app[0].toUpperCase() + app.slice(1);
+ execFileSync("git", ["commit", "-m", `${title} ${version}+${build}`, "--", ...versionFiles[app]], {
+ cwd: root,
+ stdio: "inherit",
+ });
+}
+
+try {
+ if (command === "bump-build-and-commit") {
+ if (app === "photos-desktop") {
+ console.error(`${app} has no build number; nothing to do`);
+ process.exit(0);
+ }
+ run("bump-build");
+ commitVersion();
+ } else if (command === "set-build-and-commit") {
+ run("set-build", args);
+ commitVersion();
+ } else {
+ run(command, args, { stdio: "inherit" });
+ }
+} catch (error) {
+ process.exit(error.status ?? 1);
+}
diff --git a/.github/scripts/ensu-version.mjs b/.github/scripts/ensu-version.mjs
index ac0bba25dd..596dce8045 100644
--- a/.github/scripts/ensu-version.mjs
+++ b/.github/scripts/ensu-version.mjs
@@ -53,9 +53,27 @@ function expect(label, actual, wanted) {
if (actual !== wanted) throw new Error(`${label}: expected ${wanted}, found ${actual}`);
}
+function sourceBuildNumber() {
+ const buildNumber = value(files.android, /versionCode = .*\?: (\d+)/);
+ if (!buildNumber) throw new Error("Android versionCode: no default found");
+ return buildNumber;
+}
+
+function setBuildNumber(buildNumber) {
+ replace(files.android, /(versionCode = .*\?: )\d+/, (_m, prefix) => `${prefix}${buildNumber}`);
+ replace(files.xcode, /CURRENT_PROJECT_VERSION = [^;]+;/g, `CURRENT_PROJECT_VERSION = ${buildNumber};`);
+}
+
function check() {
const version = sourceVersion();
const releaseVersion = trimVersion(version);
+ const buildNumber = sourceBuildNumber();
+
+ const xcodeBuildNumbers = [...read(files.xcode).matchAll(/CURRENT_PROJECT_VERSION = ([^;]+);/g)];
+ if (!xcodeBuildNumbers.length) throw new Error("Xcode CURRENT_PROJECT_VERSION: no entries found");
+ for (const match of xcodeBuildNumbers) {
+ expect("Xcode CURRENT_PROJECT_VERSION", match[1], buildNumber);
+ }
expect("tauri.conf.json", value(files.tauri, /^\s*"version"\s*:\s*"([^"]+)"/m), version);
expect("package-lock.json", value(files.packageLock, /"name": "ensu-desktop",\n\s+"version": "([^"]+)"/), version);
@@ -89,8 +107,11 @@ function setVersion(version) {
function usage() {
console.error(`Usage:
node .github/scripts/ensu-version.mjs get
+ node .github/scripts/ensu-version.mjs get-build-base
node .github/scripts/ensu-version.mjs set 0.1.16-beta
- node .github/scripts/ensu-version.mjs set 0.1.16`);
+ node .github/scripts/ensu-version.mjs set 0.1.16
+ node .github/scripts/ensu-version.mjs set-build 0.1.16 34
+ node .github/scripts/ensu-version.mjs bump-build`);
}
const [command = "get", ...args] = process.argv.slice(2);
@@ -99,9 +120,20 @@ try {
if (command === "get") {
check();
console.log(sourceVersion());
+ } else if (command === "get-build-base") {
+ check();
+ console.log(sourceBuildNumber());
} else if (command === "set") {
setVersion(args[0]);
check();
+ } else if (command === "set-build") {
+ if (!/^\d+$/.test(args[1])) throw new Error(`Invalid Ensu build number: ${args[1]}`);
+ setVersion(args[0]);
+ setBuildNumber(args[1]);
+ check();
+ } else if (command === "bump-build") {
+ setBuildNumber(Number(sourceBuildNumber()) + 1);
+ check();
} else {
usage();
process.exit(2);
diff --git a/.github/scripts/flutter-version.mjs b/.github/scripts/flutter-version.mjs
index eff14e2e11..5847e2d30b 100644
--- a/.github/scripts/flutter-version.mjs
+++ b/.github/scripts/flutter-version.mjs
@@ -13,6 +13,7 @@ function usage() {
node .github/scripts/flutter-version.mjs auth get-build-base
node .github/scripts/flutter-version.mjs auth set 4.4.23
node .github/scripts/flutter-version.mjs auth set-build 4.4.23 1007
+ node .github/scripts/flutter-version.mjs auth bump-build
Valid apps: photos, auth, locker`);
}
@@ -61,6 +62,9 @@ try {
if (!/^\d+\.\d+\.\d+$/.test(args[0])) throw new Error(`Invalid ${app} release version: ${args[0]}`);
if (!/^\d+$/.test(args[1])) throw new Error(`Invalid ${app} build number: ${args[1]}`);
setPubspecVersion(`${args[0]}+${args[1]}`);
+ } else if (command === "bump-build") {
+ const { source, buildBase } = pubspecVersion();
+ setPubspecVersion(`${source}+${Number(buildBase) + 1}`);
} else {
usage();
process.exit(2);
diff --git a/.github/workflows/app-release.yml b/.github/workflows/app-release.yml
index af785c13f1..0b32d6e293 100644
--- a/.github/workflows/app-release.yml
+++ b/.github/workflows/app-release.yml
@@ -28,6 +28,7 @@ on:
type: string
permissions:
+ actions: read
contents: write
pull-requests: write
@@ -79,18 +80,13 @@ jobs:
if: inputs.action == 'start'
env:
GH_TOKEN: ${{ steps.app_token.outputs.token }}
+ RUNS_TOKEN: ${{ github.token }}
APP_SLUG: ${{ steps.app_token.outputs.app-slug }}
run: |
set -euo pipefail
app_version() {
- if [ "${APP}" = "ensu" ]; then
- node .github/scripts/ensu-version.mjs "$@"
- elif [ "${APP}" = "photos-desktop" ]; then
- node .github/scripts/photos-desktop-version.mjs "$@"
- else
- node .github/scripts/flutter-version.mjs "${APP}" "$@"
- fi
+ node .github/scripts/app-version.mjs "${APP}" "$@"
}
git_push_release_branch() {
@@ -120,9 +116,13 @@ jobs:
fi
git switch -c "${release_branch}"
- if [ "${APP}" = "ensu" ] || [ "${APP}" = "photos-desktop" ]; then
+ if [ "${APP}" = "photos-desktop" ]; then
app_version set "${VERSION}"
git commit -am "${APP^} v${VERSION}"
+ else
+ build_base="$(app_version get-build-base)"
+ last_run="$(GH_TOKEN="${RUNS_TOKEN}" gh api "/repos/${GITHUB_REPOSITORY}/actions/workflows/${APP}-build.yml/runs?per_page=1" --jq '.workflow_runs[0].run_number // 0')"
+ app_version set-build-and-commit "${VERSION}" "$((build_base + last_run + 1))"
fi
git_push_release_branch "${release_branch}"
@@ -151,13 +151,7 @@ jobs:
set -euo pipefail
app_version() {
- if [ "${APP}" = "ensu" ]; then
- node .github/scripts/ensu-version.mjs "$@"
- elif [ "${APP}" = "photos-desktop" ]; then
- node .github/scripts/photos-desktop-version.mjs "$@"
- else
- node .github/scripts/flutter-version.mjs "${APP}" "$@"
- fi
+ node .github/scripts/app-version.mjs "${APP}" "$@"
}
git_push_release_branch() {
diff --git a/.github/workflows/auth-build.yml b/.github/workflows/auth-build.yml
index 3b511b08dc..1cea4a9146 100644
--- a/.github/workflows/auth-build.yml
+++ b/.github/workflows/auth-build.yml
@@ -54,17 +54,18 @@ jobs:
fi
release_version="$(node .github/scripts/flutter-version.mjs auth get)"
- build_number_base="$(node .github/scripts/flutter-version.mjs auth get-build-base)"
- build_number=$((build_number_base + GITHUB_RUN_NUMBER))
if [[ "${GITHUB_REF_NAME}" == release/auth-v* ]]; then
if [[ "${GITHUB_REF_NAME}" != "release/auth-v${release_version}" ]]; then
echo "::error::Branch ${GITHUB_REF_NAME} does not match Auth version ${release_version}"
exit 1
fi
+ build_number="$(node .github/scripts/flutter-version.mjs auth get-build-base)"
release_tag="auth-v${release_version}-rc"
release_title="πŸ”’ Auth release candidate - ${release_version} (build ${build_number})"
else
+ build_number_base="$(node .github/scripts/flutter-version.mjs auth get-build-base)"
+ build_number=$((build_number_base + GITHUB_RUN_NUMBER))
release_tag="auth-v${release_version}-beta"
release_title="πŸ”’ Auth nightly - ${release_version} (build ${build_number})"
fi
diff --git a/.github/workflows/ensu-build.yml b/.github/workflows/ensu-build.yml
index a223bf279a..f2a4d19224 100644
--- a/.github/workflows/ensu-build.yml
+++ b/.github/workflows/ensu-build.yml
@@ -13,7 +13,6 @@ on:
env:
NDK_VERSION: "27.3.13750724"
- BUILD_NUMBER_BASE: "33"
permissions:
contents: write
@@ -58,7 +57,6 @@ jobs:
version="$(node .github/scripts/ensu-version.mjs get)"
release_version="${version%-beta}"
- build_number=$((BUILD_NUMBER_BASE + GITHUB_RUN_NUMBER))
if [[ "${GITHUB_REF_NAME}" == release/ensu-v* ]]; then
if [[ "${version}" != "${release_version}" ]]; then
@@ -69,6 +67,7 @@ jobs:
echo "::error::Branch ${GITHUB_REF_NAME} does not match Ensu version ${release_version}"
exit 1
fi
+ build_number="$(node .github/scripts/ensu-version.mjs get-build-base)"
release_tag="ensu-v${release_version}-rc"
release_title="πŸ€– Ensu release candidate Β· ${release_version} (build ${build_number})"
else
@@ -76,6 +75,8 @@ jobs:
echo "::error::${GITHUB_REF_NAME} is ${version}, expected ${release_version}-beta"
exit 1
fi
+ build_number_base="$(node .github/scripts/ensu-version.mjs get-build-base)"
+ build_number=$((build_number_base + GITHUB_RUN_NUMBER))
release_tag="ensu-v${release_version}-beta"
release_title="πŸ€– Ensu nightly Β· ${version} (build ${build_number})"
fi
diff --git a/.github/workflows/locker-build.yml b/.github/workflows/locker-build.yml
index b0535dbbb7..741b273f09 100644
--- a/.github/workflows/locker-build.yml
+++ b/.github/workflows/locker-build.yml
@@ -54,17 +54,18 @@ jobs:
fi
release_version="$(node .github/scripts/flutter-version.mjs locker get)"
- build_number_base="$(node .github/scripts/flutter-version.mjs locker get-build-base)"
- build_number=$((build_number_base + GITHUB_RUN_NUMBER))
if [[ "${GITHUB_REF_NAME}" == release/locker-v* ]]; then
if [[ "${GITHUB_REF_NAME}" != "release/locker-v${release_version}" ]]; then
echo "::error::Branch ${GITHUB_REF_NAME} does not match Locker version ${release_version}"
exit 1
fi
+ build_number="$(node .github/scripts/flutter-version.mjs locker get-build-base)"
release_tag="locker-v${release_version}-rc"
release_title="πŸ—„οΈ Locker release candidate - ${release_version} (build ${build_number})"
else
+ build_number_base="$(node .github/scripts/flutter-version.mjs locker get-build-base)"
+ build_number=$((build_number_base + GITHUB_RUN_NUMBER))
release_tag="locker-v${release_version}-beta"
release_title="πŸ—„οΈ Locker nightly - ${release_version} (build ${build_number})"
fi
diff --git a/.github/workflows/photos-build.yml b/.github/workflows/photos-build.yml
index 57f978dc29..a3a589f4d7 100644
--- a/.github/workflows/photos-build.yml
+++ b/.github/workflows/photos-build.yml
@@ -54,17 +54,18 @@ jobs:
fi
release_version="$(node .github/scripts/flutter-version.mjs photos get)"
- build_number_base="$(node .github/scripts/flutter-version.mjs photos get-build-base)"
- build_number=$((build_number_base + GITHUB_RUN_NUMBER))
if [[ "${GITHUB_REF_NAME}" == release/photos-v* ]]; then
if [[ "${GITHUB_REF_NAME}" != "release/photos-v${release_version}" ]]; then
echo "::error::Branch ${GITHUB_REF_NAME} does not match Photos version ${release_version}"
exit 1
fi
+ build_number="$(node .github/scripts/flutter-version.mjs photos get-build-base)"
release_tag="photos-v${release_version}-rc"
release_title="🌻 Photos release candidate - ${release_version} (build ${build_number})"
else
+ build_number_base="$(node .github/scripts/flutter-version.mjs photos get-build-base)"
+ build_number=$((build_number_base + GITHUB_RUN_NUMBER))
release_tag="photos-v${release_version}-beta"
release_title="🌻 Photos nightly - ${release_version} (build ${build_number})"
fi