π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Refine Ensu release promotion flow
Manav Rathi29eb8a254e4b
diff --git a/.github/docs/ensu-release.md b/.github/docs/ensu-release.mdindex afec6a55c9..75fc0e5eb5 100644--- a/.github/docs/ensu-release.md+++ b/.github/docs/ensu-release.md@@ -25,7 +25,7 @@ Scheduled nightly builds are skipped while a release branch exists.git switch maingit pullgit switch -c ensu-v0.1.17-beta-node .github/scripts/ensu-version.mjs set --version 0.1.17 --channel beta+node .github/scripts/ensu-version.mjs set 0.1.17-betagit commit -am "Start Ensu 0.1.17 beta"git push -u origin ensu-v0.1.17-beta```@@ -44,25 +44,18 @@ git pushThe push updates the `ensu-v0.1.16-beta` prerelease.-## Promote release+## Draft release-First change the local release branch to stable:+Tag the release branch commit you want to ship:```bashgit switch release/ensu-v0.1.16-node .github/scripts/ensu-version.mjs set --version 0.1.16 --channel stable-git commit -am "Mark Ensu 0.1.16 stable"-```--Then tag that commit and push the tag:--```bash+git pullgit tag ensu-v0.1.16git push origin ensu-v0.1.16```-The workflow creates draft release `ensu-v0.1.16` and removes-`ensu-v0.1.16-beta`.+The workflow creates draft release `ensu-v0.1.16` and removes `ensu-v0.1.16-beta`.## Cleanupdiff --git a/.github/scripts/ensu-version.mjs b/.github/scripts/ensu-version.mjsindex d6b02d17a4..9f79535848 100644--- a/.github/scripts/ensu-version.mjs+++ b/.github/scripts/ensu-version.mjs@@ -23,18 +23,17 @@ function write(file, text) {fs.writeFileSync(file, text);}-function sourceVersion() {- const version = JSON.parse(read(files.packageJson)).version;+function parseVersion(version) {const match = /^(\d+\.\d+\.\d+)(-beta)?$/.exec(version);- if (!match) throw new Error(`Invalid Ensu desktop version: ${version}`);+ if (!match) throw new Error(`Invalid Ensu version: ${version}`);return {- version: match[1],- channel: match[2] ? "beta" : "stable",+ source: version,+ marketing: match[1],};}-function desktopVersion(version, channel) {- return channel === "beta" ? `${version}-beta` : version;+function sourceVersion() {+ return parseVersion(JSON.parse(read(files.packageJson)).version);}function value(file, regex) {@@ -57,58 +56,52 @@ function expect(label, actual, wanted) {}function check() {- const { version, channel } = sourceVersion();- const desktop = desktopVersion(version, channel);+ const version = sourceVersion();- expect("tauri.conf.json", JSON.parse(read(files.tauri)).package?.version, desktop);- expect("Cargo.toml", value(files.cargoToml, /\[package\][\s\S]*?^version = "([^"]+)"/m), desktop);- expect("Cargo.lock", value(files.cargoLock, /\[\[package\]\]\nname = "ensu-tauri"\nversion = "([^"]+)"/), desktop);- expect("Android versionName", value(files.android, /versionName = "([^"]+)"/), version);- expect("Info.plist", value(files.plist, /<key>CFBundleShortVersionString<\/key>\s*<string>([^<]+)<\/string>/), version);+ expect("tauri.conf.json", JSON.parse(read(files.tauri)).package?.version, version.source);+ expect("Cargo.toml", value(files.cargoToml, /\[package\][\s\S]*?^version = "([^"]+)"/m), version.source);+ expect("Cargo.lock", value(files.cargoLock, /\[\[package\]\]\nname = "ensu-tauri"\nversion = "([^"]+)"/), version.source);+ expect("Android versionName", value(files.android, /versionName = "([^"]+)"/), version.marketing);+ expect("Info.plist", value(files.plist, /<key>CFBundleShortVersionString<\/key>\s*<string>([^<]+)<\/string>/), version.marketing);const xcodeMarketingVersions = [...read(files.xcode).matchAll(/MARKETING_VERSION = ([^;]+);/g)];if (!xcodeMarketingVersions.length) throw new Error("Xcode MARKETING_VERSION: no entries found");for (const match of xcodeMarketingVersions) {- expect("Xcode MARKETING_VERSION", match[1], version);+ expect("Xcode MARKETING_VERSION", match[1], version.marketing);}}-function setVersion(version, channel) {- if (!/^\d+\.\d+\.\d+$/.test(version)) throw new Error(`Invalid version: ${version}`);- if (!["beta", "stable"].includes(channel)) throw new Error(`Invalid channel: ${channel}`);+function setVersion(source) {+ const version = parseVersion(source);- const desktop = desktopVersion(version, channel);const packageJson = JSON.parse(read(files.packageJson));- packageJson.version = desktop;+ packageJson.version = version.source;write(files.packageJson, `${JSON.stringify(packageJson, null, 2)}\n`);- replace(files.tauri, /("package"\s*:\s*\{[\s\S]*?"version"\s*:\s*")[^"]+(")/, (_m, a, b) => `${a}${desktop}${b}`);- replace(files.cargoToml, /(\[package\][\s\S]*?^version = ")[^"]+(")/m, (_m, a, b) => `${a}${desktop}${b}`);- replace(files.cargoLock, /(\[\[package\]\]\nname = "ensu-tauri"\nversion = ")[^"]+(")/, (_m, a, b) => `${a}${desktop}${b}`);- replace(files.android, /versionName = "[^"]+"/, `versionName = "${version}"`);- replace(files.xcode, /MARKETING_VERSION = [^;]+;/g, `MARKETING_VERSION = ${version};`);- replace(files.plist, /(<key>CFBundleShortVersionString<\/key>\s*<string>)[^<]+(<\/string>)/, (_m, a, b) => `${a}${version}${b}`);+ replace(files.tauri, /("package"\s*:\s*\{[\s\S]*?"version"\s*:\s*")[^"]+(")/, (_m, a, b) => `${a}${version.source}${b}`);+ replace(files.cargoToml, /(\[package\][\s\S]*?^version = ")[^"]+(")/m, (_m, a, b) => `${a}${version.source}${b}`);+ replace(files.cargoLock, /(\[\[package\]\]\nname = "ensu-tauri"\nversion = ")[^"]+(")/, (_m, a, b) => `${a}${version.source}${b}`);+ replace(files.android, /versionName = "[^"]+"/, `versionName = "${version.marketing}"`);+ replace(files.xcode, /MARKETING_VERSION = [^;]+;/g, `MARKETING_VERSION = ${version.marketing};`);+ replace(files.plist, /(<key>CFBundleShortVersionString<\/key>\s*<string>)[^<]+(<\/string>)/, (_m, a, b) => `${a}${version.marketing}${b}`);}function usage() {console.error(`Usage:- node .github/scripts/ensu-version.mjs check- node .github/scripts/ensu-version.mjs github-output- node .github/scripts/ensu-version.mjs set --version 0.1.16 --channel beta- node .github/scripts/ensu-version.mjs set --version 0.1.16 --channel stable`);+ node .github/scripts/ensu-version.mjs get+ node .github/scripts/ensu-version.mjs set 0.1.16-beta+ node .github/scripts/ensu-version.mjs set 0.1.16`);}-const [command = "check", ...args] = process.argv.slice(2);+const [command = "get", ...args] = process.argv.slice(2);try {- if (command === "check") {+ if (command === "get") {check();- } else if (command === "github-output") {- const version = sourceVersion();- console.log(`version=${version.version}`);- console.log(`channel=${version.channel}`);+ console.log(sourceVersion().marketing);} else if (command === "set") {- setVersion(args[args.indexOf("--version") + 1], args[args.indexOf("--channel") + 1]);+ setVersion(args[0]);+ check();} else {usage();process.exit(2);diff --git a/.github/workflows/ensu-release.yml b/.github/workflows/ensu-release.ymlindex 45e028c5bf..91bbebea39 100644--- a/.github/workflows/ensu-release.yml+++ b/.github/workflows/ensu-release.yml@@ -35,6 +35,8 @@ jobs:release_body: ${{ steps.prepare.outputs.release_body }}release_draft: ${{ steps.prepare.outputs.release_draft }}release_prerelease: ${{ steps.prepare.outputs.release_prerelease }}+ release_version: ${{ steps.prepare.outputs.release_version }}+ is_release_tag: ${{ steps.prepare.outputs.is_release_tag }}short_sha: ${{ steps.prepare.outputs.short_sha }}steps:@@ -57,24 +59,12 @@ jobs:commit_sha="$(git rev-parse HEAD)"- node .github/scripts/ensu-version.mjs check- source_version=""- source_channel=""- while IFS='=' read -r key value; do- case "${key}" in- version) source_version="${value}" ;;- channel) source_channel="${value}" ;;- esac- done < <(node .github/scripts/ensu-version.mjs github-output)+ version="$(node .github/scripts/ensu-version.mjs get)"if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then- expected_tag="ensu-v${source_version}"+ expected_tag="ensu-v${version}"if [[ "${GITHUB_REF_NAME}" != "${expected_tag}" ]]; then- echo "::error::Tag ${GITHUB_REF_NAME} does not match source version ${source_version}"- exit 1- fi- if [[ "${source_channel}" != "stable" ]]; then- echo "::error::Stable releases require the Ensu source channel to be stable"+ echo "::error::Tag ${GITHUB_REF_NAME} does not match Ensu version ${version}"exit 1fi@@ -83,17 +73,14 @@ jobs:RELEASE_BODY=""RELEASE_DRAFT=trueRELEASE_PRERELEASE=false+ IS_RELEASE_TAG=trueelse- if [[ "${source_channel}" != "beta" ]]; then- echo "::error::Nightly releases require the Ensu source channel to be beta"- exit 1- fi-- RELEASE_TAG="ensu-v${source_version}-beta"+ RELEASE_TAG="ensu-v${version}-beta"RELEASE_NAME="${RELEASE_TAG}"RELEASE_BODY="Nightly builds"RELEASE_DRAFT=falseRELEASE_PRERELEASE=true+ IS_RELEASE_TAG=falsefiecho "should_build=true" >> "${GITHUB_OUTPUT}"@@ -104,6 +91,8 @@ jobs:echo "release_body=${RELEASE_BODY}" >> "${GITHUB_OUTPUT}"echo "release_draft=${RELEASE_DRAFT}" >> "${GITHUB_OUTPUT}"echo "release_prerelease=${RELEASE_PRERELEASE}" >> "${GITHUB_OUTPUT}"+ echo "release_version=${version}" >> "${GITHUB_OUTPUT}"+ echo "is_release_tag=${IS_RELEASE_TAG}" >> "${GITHUB_OUTPUT}"release-desktop:needs: release-metadata@@ -134,6 +123,8 @@ jobs:RELEASE_BODY: ${{ needs.release-metadata.outputs.release_body }}RELEASE_DRAFT: ${{ needs.release-metadata.outputs.release_draft }}RELEASE_PRERELEASE: ${{ needs.release-metadata.outputs.release_prerelease }}+ RELEASE_VERSION: ${{ needs.release-metadata.outputs.release_version }}+ IS_RELEASE_TAG: ${{ needs.release-metadata.outputs.is_release_tag }}HAS_WINDOWS_SIGNING: ${{ secrets.AZURE_TENANT_ID != '' && secrets.AZURE_CLIENT_ID != '' && secrets.AZURE_CLIENT_SECRET != '' && secrets.AZURE_ENDPOINT != '' && secrets.AZURE_CODE_SIGNING_NAME != '' && secrets.AZURE_CERT_PROFILE_NAME != '' }}steps:@@ -149,6 +140,10 @@ jobs:cache: "yarn"cache-dependency-path: "web/yarn.lock"+ - name: Set release version+ if: env.IS_RELEASE_TAG == 'true'+ run: node .github/scripts/ensu-version.mjs set "${RELEASE_VERSION}"+- name: Activate Yarn 1.22.22run: |corepack enable@@ -319,6 +314,8 @@ jobs:RELEASE_BODY: ${{ needs.release-metadata.outputs.release_body }}RELEASE_DRAFT: ${{ needs.release-metadata.outputs.release_draft }}RELEASE_PRERELEASE: ${{ needs.release-metadata.outputs.release_prerelease }}+ RELEASE_VERSION: ${{ needs.release-metadata.outputs.release_version }}+ IS_RELEASE_TAG: ${{ needs.release-metadata.outputs.is_release_tag }}SHORT_SHA: ${{ needs.release-metadata.outputs.short_sha }}HAS_ANDROID_SIGNING: ${{ secrets.SIGNING_KEY_ENSU != '' && secrets.SIGNING_STORE_PASSWORD_ENSU != '' && secrets.SIGNING_KEY_ALIAS_ENSU != '' && secrets.SIGNING_KEY_PASSWORD_ENSU != '' }}HAS_PLAYSTORE_SERVICE_ACCOUNT: ${{ secrets.SERVICE_ACCOUNT_JSON != '' }}@@ -352,6 +349,12 @@ jobs:- name: Setup Rustuses: dtolnay/rust-toolchain@stable+ - name: Set release version+ if: env.IS_RELEASE_TAG == 'true'+ run: |+ cd ../../../../..+ node .github/scripts/ensu-version.mjs set "${RELEASE_VERSION}"+- name: Generate Android bindingsrun: |cd ../../../../../rust@@ -391,7 +394,7 @@ jobs:mkdir -p artifactscp app-ui/build/outputs/apk/release/app-ui-release.apk artifacts/${{ env.RELEASE_TAG }}.apk- - name: Upload Android APK to draft GitHub release+ - name: Upload Android APK to GitHub releaseif: env.HAS_ANDROID_SIGNING == 'true'uses: ncipollo/release-action@v1with:@@ -427,8 +430,8 @@ jobs:color: 0xFDCE13cleanup-beta-release:- needs: [release-desktop, build-android]- if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')+ needs: [release-metadata, release-desktop, build-android]+ if: needs.release-metadata.outputs.is_release_tag == 'true'runs-on: ubuntu-22.04steps: