π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Automate CLI release follow-up
Manav Rathia51c1a620aea
diff --git a/.github/docs/cli-release.md b/.github/docs/cli-release.mdnew file mode 100644index 0000000000..e831d7d97c--- /dev/null+++ b/.github/docs/cli-release.md@@ -0,0 +1,9 @@+# CLI releases++To publish the version on main:++```sh+gh workflow run ente-cli-release.yml --ref main+```++This publishes the CLI binaries and release notes, then opens a PR to bump the patch version, add the changelog entry and remove the shipped change notes.diff --git a/.github/scripts/cli-version.mjs b/.github/scripts/cli-version.mjsnew file mode 100644index 0000000000..5056e61c08--- /dev/null+++ b/.github/scripts/cli-version.mjs@@ -0,0 +1,35 @@+#!/usr/bin/env node++import fs from "node:fs";+import path from "node:path";+import { fileURLToPath } from "node:url";++const root = path.resolve(+ path.dirname(fileURLToPath(import.meta.url)),+ "../..",+);+const manifest = path.join(root, "rust/apps/cli/Cargo.toml");+const lockfile = path.join(root, "rust/Cargo.lock");+const source = fs.readFileSync(manifest, "utf8");+const [command = "get", version] = process.argv.slice(2);++if (command === "get") {+ console.log(source.match(/^version = "([^"]+)"$/m)[1]);+} else if (command === "set" && /^\d+\.\d+\.\d+$/.test(version)) {+ for (const [file, pattern] of [+ [manifest, /(^version = ")[^"]+(")/m],+ [lockfile, /(name = "ente-cli"\nversion = ")[^"]+(")/],+ ]) {+ const text = fs.readFileSync(file, "utf8");+ if (!pattern.test(text)) throw new Error(`No CLI version in ${file}`);+ fs.writeFileSync(+ file,+ text.replace(pattern, (_, a, b) => `${a}${version}${b}`),+ );+ }+} else {+ console.error(+ "Usage: node .github/scripts/cli-version.mjs get|set <x.y.z>",+ );+ process.exit(2);+}diff --git a/.github/scripts/sync-help-changelog.mjs b/.github/scripts/sync-help-changelog.mjsindex b8a02a7691..7f4e7262b9 100644--- a/.github/scripts/sync-help-changelog.mjs+++ b/.github/scripts/sync-help-changelog.mjs@@ -18,6 +18,7 @@ const apps = {auth: { changelog: "docs/docs/auth/changelog.md", label: undefined },locker: { changelog: "docs/docs/locker/changelog.md", label: "mobile" },ensu: { changelog: "docs/docs/ensu/changelog.md", label: undefined },+ cli: { changelog: "docs/docs/cli/changelog.md", label: undefined },};const normalizeReleaseBodyIndent = (body) => {@@ -63,10 +64,10 @@ const body = normalizeReleaseBodyIndent(process.env.RELEASE_BODY ?? "")const section = `${heading} - ${date}\n\n${body}\n`;const at = content.search(/^## v/m);-if (at < 0)- throw new Error(`No "## v" entry to insert before in ${config.changelog}`);fs.writeFileSync(file,- `${content.slice(0, at)}${section}\n${content.slice(at)}`,+ at < 0+ ? `${content.trimEnd()}\n\n${section}`+ : `${content.slice(0, at)}${section}\n${content.slice(at)}`,);diff --git a/.github/workflows/ente-cli-release.yml b/.github/workflows/ente-cli-release.ymlindex 70a213e5da..3e1e62d08b 100644--- a/.github/workflows/ente-cli-release.yml+++ b/.github/workflows/ente-cli-release.yml@@ -55,7 +55,7 @@ jobs:binary=ente.exefiif [[ "$RUNNER_OS" = Linux ]]; then features=(--features rusqlite/bundled-sqlcipher-vendored-openssl,keyring/vendored); fi- version=$(cargo metadata --locked --no-deps --format-version 1 | jq -rj '.packages[] | select(.name == "ente-cli") | .version')+ version=$(node ../.github/scripts/cli-version.mjs get)cargo build --locked --release -p ente-cli --bin ente --target "$TARGET" "${features[@]}"cd "target/$TARGET/release"[[ "$(./"$binary" --version)" = "ente $version" ]]@@ -103,6 +103,7 @@ jobs:private-key: ${{ secrets.ENTE_CI_GH_APP_PRIVATE_KEY }}repositories: entepermission-contents: write+ permission-pull-requests: write- name: Publish releaseenv:GH_TOKEN: ${{ steps.app-token.outputs.token }}@@ -117,3 +118,22 @@ jobs:cd assetssha256sum *.tar.gz *.zip > SHA256SUMSgh release create "$tag" --target "$GITHUB_SHA" --title "Ente CLI $VERSION" --notes-file "$RUNNER_TEMP/release-notes.md" --latest=false *+ - name: Open release follow-up PR+ env:+ GH_TOKEN: ${{ steps.app-token.outputs.token }}+ APP_SLUG: ${{ steps.app-token.outputs.app-slug }}+ RELEASE_BODY: ${{ steps.notes.outputs.release_body }}+ run: |+ IFS=. read -r major minor patch <<< "$VERSION"+ next_version="$major.$minor.$((patch + 1))"+ branch="ente-cli-v$next_version"+ git switch -c "$branch"+ node .github/scripts/cli-version.mjs set "$next_version"+ node .github/scripts/sync-help-changelog.mjs cli "$VERSION"+ find rust/apps/cli/changes -maxdepth 1 -type f -name '*.md' ! -name README.md -delete+ bot_id="$(gh api "/users/${APP_SLUG}[bot]" --jq .id)"+ git config user.name "${APP_SLUG}[bot]"+ git config user.email "${bot_id}+${APP_SLUG}[bot]@users.noreply.github.com"+ git commit -am "Start Ente CLI $next_version"+ git -c http.https://github.com/.extraheader= push "https://x-access-token:${GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" "$branch"+ gh pr create --base main --head "$branch" --title "[rust] Start Ente CLI $next_version" --body ""diff --git a/docs/docs/cli/changelog.md b/docs/docs/cli/changelog.mdnew file mode 100644index 0000000000..825c32f0d0--- /dev/null+++ b/docs/docs/cli/changelog.md@@ -0,0 +1 @@+# Changelogdiff --git a/rust/apps/cli/changes/README.md b/rust/apps/cli/changes/README.mdnew file mode 100644index 0000000000..2c5e49ebf3--- /dev/null+++ b/rust/apps/cli/changes/README.md@@ -0,0 +1,7 @@+For each user facing change, create a new `arbitrary-slug.md`, e.g.:++```md+- Added support for exporting Auth codes.+```++All these files are concatenated in alphabetical order for the release notes.