Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix(desktop): publish update feed from release commit (#8184)
Eric Hayesedb7f91b9f10
diff --git a/.github/workflows/build_desktop_on_tag.yml b/.github/workflows/build_desktop_on_tag.ymlindex 4ab0d6f8f8..9b3a81240d 100644--- a/.github/workflows/build_desktop_on_tag.yml+++ b/.github/workflows/build_desktop_on_tag.yml@@ -979,7 +979,20 @@ jobs:nix develop --command bun apps/web/scripts/desktop-release.mjs newer \release-artifacts/latest.json "$work_dir/latest.json" || result=$?if [ "$result" -eq 2 ]; then- echo "A matching or newer desktop release is already promoted."+ candidate_version=$(jq -er '.version' release-artifacts/latest.json)+ current_version=$(jq -er '.version' "$work_dir/latest.json")+ if [ "$candidate_version" = "$current_version" ]; then+ if ! cmp -s release-artifacts/latest.json "$work_dir/latest.json"; then+ echo "Desktop update feed already has version $candidate_version with different content" >&2+ exit 1+ fi+ # A previous attempt may have uploaded the feed but failed before+ # marking the versioned release as the latest download.+ gh release edit "$RELEASE_TAG" --repo "$RELEASE_REPOSITORY" --latest+ echo "Desktop release already promoted."+ else+ echo "A newer desktop release is already promoted."+ fiexit 0fi[ "$result" -eq 0 ] || exit "$result"@@ -991,7 +1004,9 @@ jobs:echo "Could not read the existing desktop update channel" >&2exit 1fi- gh release create desktop-stable --repo "$RELEASE_REPOSITORY" --target "$RELEASE_TAG" \+ # --target accepts a branch or full commit SHA, not the versioned release tag.+ release_commit=$(git rev-parse --verify 'HEAD^{commit}')+ gh release create desktop-stable --repo "$RELEASE_REPOSITORY" --target "$release_commit" \--prerelease --latest=false --title "Desktop stable update feed" \--notes "Update metadata only. Download installers from a versioned desktop release."fidiff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/build_desktop_on_tag/test.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/build_desktop_on_tag/test.rsindex 7e2ec1831e..db99c09f03 100644--- a/tooling/xtask/crates/xtask_workflows/src/workflows/build_desktop_on_tag/test.rs+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/build_desktop_on_tag/test.rs@@ -1,4 +1,167 @@use super::*;+use std::fs;+use std::os::unix::fs::PermissionsExt;+use std::path::Path;+use std::process::{Command, Output};++const RELEASE_TAG: &str = "v2026.10.16.0";+const RELEASE_VERSION: &str = "2026.1016.0";+const RELEASE_SHA: &str = "0123456789abcdef0123456789abcdef01234567";++struct PublishFixture {+ temp: tempfile::TempDir,+ channel_version: &'static str,+}++impl PublishFixture {+ fn new(channel_version: &'static str) -> Self {+ let temp = tempfile::tempdir().expect("publish fixture directory");+ let bin = temp.path().join("bin");+ fs::create_dir(&bin).expect("mock command directory");+ let artifacts = temp.path().join("release-artifacts");+ fs::create_dir(&artifacts).expect("release artifacts directory");+ fs::write(artifacts.join("installer.bin"), "installer").expect("installer artifact");++ write_command(+ &bin,+ "git",+ r#"#!/usr/bin/env bash+set -euo pipefail+[[ "$1" == rev-parse ]]+printf '%s\n' "$STUB_RELEASE_SHA"+"#,+ );+ write_command(+ &bin,+ "nix",+ r#"#!/usr/bin/env bash+set -euo pipefail+[[ "$1" == develop && "$2" == --command && "$3" == bun && "$4" == apps/web/scripts/desktop-release.mjs ]]+command=$5+shift 5+case "$command" in+ manifest)+ printf '{"version":"%s"}\n' "$STUB_RELEASE_VERSION" > "$1/latest.json"+ ;;+ newer)+ IFS=. read -r candidate_major candidate_minor candidate_patch <<< "$(jq -r .version "$1")"+ IFS=. read -r current_major current_minor current_patch <<< "$(jq -r .version "$2")"+ if (( candidate_major > current_major ||+ (candidate_major == current_major && candidate_minor > current_minor) ||+ (candidate_major == current_major && candidate_minor == current_minor && candidate_patch > current_patch) )); then+ exit 0+ fi+ exit 2+ ;;+ *) exit 2 ;;+esac+"#,+ );+ write_command(+ &bin,+ "gh",+ r#"#!/usr/bin/env bash+set -euo pipefail+printf '%s\n' "$*" >> "$STUB_GH_LOG"+case "$1 $2" in+ 'release view')+ if [[ "$3" == desktop-stable ]]; then+ [[ -n "$STUB_CHANNEL_VERSION" ]] || exit 1+ printf '{"assets":[{"name":"latest.json"}]}\n'+ elif [[ "$3" == "$STUB_RELEASE_TAG" ]]; then+ printf '{"assets":[]}\n'+ else+ exit 2+ fi+ ;;+ 'release download')+ [[ "$3" == desktop-stable && -n "$STUB_CHANNEL_VERSION" ]]+ while (( $# > 0 )); do+ if [[ "$1" == --dir ]]; then+ printf '{"version":"%s"}\n' "$STUB_CHANNEL_VERSION" > "$2/latest.json"+ exit 0+ fi+ shift+ done+ exit 2+ ;;+ 'release create')+ [[ "$3" == desktop-stable ]] || exit 2+ target=''+ while (( $# > 0 )); do+ if [[ "$1" == --target ]]; then+ target=$2+ break+ fi+ shift+ done+ [[ "$target" == "$STUB_RELEASE_SHA" ]] || {+ printf 'desktop-stable target must be the release commit SHA, got %s\n' "$target" >&2+ exit 2+ }+ ;;+ 'release upload'|'release edit') ;;+ 'api --paginate') printf '[]\n' ;;+ *) exit 2 ;;+esac+"#,+ );++ Self {+ temp,+ channel_version,+ }+ }++ fn run(&self) -> Output {+ let root = self.temp.path();+ Command::new("bash")+ .args([+ "-c",+ "export PATH=\"$STUB_BIN:$PATH\"\nexec bash \"$STUB_SCRIPT\"",+ ])+ .current_dir(root)+ .env("STUB_BIN", root.join("bin"))+ .env(+ "STUB_SCRIPT",+ Path::new(env!("CARGO_MANIFEST_DIR"))+ .join("src/workflows/scripts/publish_desktop_updates.sh"),+ )+ .env("STUB_GH_LOG", root.join("gh.log"))+ .env("STUB_RELEASE_TAG", RELEASE_TAG)+ .env("STUB_RELEASE_VERSION", RELEASE_VERSION)+ .env("STUB_RELEASE_SHA", RELEASE_SHA)+ .env("STUB_CHANNEL_VERSION", self.channel_version)+ .env("RELEASE_TAG", RELEASE_TAG)+ .env("RELEASE_REPOSITORY", "macro-inc/macro")+ .output()+ .expect("run desktop update publication script")+ }++ fn gh_calls(&self) -> String {+ fs::read_to_string(self.temp.path().join("gh.log")).expect("GitHub command log")+ }+}++fn write_command(bin: &Path, name: &str, contents: &str) {+ let path = bin.join(name);+ fs::write(&path, contents).expect("mock command");+ fs::set_permissions(path, fs::Permissions::from_mode(0o755)).expect("executable mock");+}++fn assert_publish_success(output: &Output) {+ assert!(+ output.status.success(),+ "publish failed: {:?}\nstdout: {}\nstderr: {}",+ output.status,+ String::from_utf8_lossy(&output.stdout),+ String::from_utf8_lossy(&output.stderr),+ );+}++fn called(calls: &str, prefix: &str) -> bool {+ calls.lines().any(|line| line.starts_with(prefix))+}fn rendered_yaml() -> String {build_desktop_on_tag()@@ -74,3 +237,52 @@ fn hosted_publish_runner_skips_the_nix_cache_teardown() {);assert!(yaml[updates..].contains("timeout-minutes: 20"));}++#[test]+fn first_update_creates_channel_at_release_commit_and_promotes_release() {+ let fixture = PublishFixture::new("");+ assert_publish_success(&fixture.run());+ let calls = fixture.gh_calls();+ assert!(+ calls.lines().any(|line| {+ line.starts_with("release create desktop-stable ")+ && line.contains(&format!("--target {RELEASE_SHA}"))+ }),+ "channel must point at the release commit: {calls}"+ );+ assert!(called(&calls, "release upload desktop-stable "), "{calls}");+ assert!(+ calls.lines().any(|line| {+ line.starts_with(&format!("release edit {RELEASE_TAG} ")) && line.contains("--latest")+ }),+ "new releases must become the latest download: {calls}"+ );+}++#[test]+fn equal_version_rerun_finishes_marking_release_latest() {+ let fixture = PublishFixture::new(RELEASE_VERSION);+ assert_publish_success(&fixture.run());+ let calls = fixture.gh_calls();+ assert!(!called(&calls, "release create desktop-stable "), "{calls}");+ assert!(!called(&calls, "release upload desktop-stable "), "{calls}");+ assert!(+ calls.lines().any(|line| {+ line.starts_with(&format!("release edit {RELEASE_TAG} ")) && line.contains("--latest")+ }),+ "equal-version reruns must finish release promotion: {calls}"+ );+}++#[test]+fn older_release_cannot_replace_update_feed_or_latest_release() {+ let fixture = PublishFixture::new("2026.1017.0");+ assert_publish_success(&fixture.run());+ let calls = fixture.gh_calls();+ assert!(!called(&calls, "release create desktop-stable "), "{calls}");+ assert!(!called(&calls, "release upload desktop-stable "), "{calls}");+ assert!(+ !called(&calls, &format!("release edit {RELEASE_TAG} ")),+ "{calls}"+ );+}diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/publish_desktop_updates.sh b/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/publish_desktop_updates.shindex 9f01b375de..e23a2eec48 100644--- a/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/publish_desktop_updates.sh+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/scripts/publish_desktop_updates.sh@@ -33,7 +33,20 @@ if gh release view desktop-stable --repo "$RELEASE_REPOSITORY" --json assets > "nix develop --command bun apps/web/scripts/desktop-release.mjs newer \release-artifacts/latest.json "$work_dir/latest.json" || result=$?if [ "$result" -eq 2 ]; then- echo "A matching or newer desktop release is already promoted."+ candidate_version=$(jq -er '.version' release-artifacts/latest.json)+ current_version=$(jq -er '.version' "$work_dir/latest.json")+ if [ "$candidate_version" = "$current_version" ]; then+ if ! cmp -s release-artifacts/latest.json "$work_dir/latest.json"; then+ echo "Desktop update feed already has version $candidate_version with different content" >&2+ exit 1+ fi+ # A previous attempt may have uploaded the feed but failed before+ # marking the versioned release as the latest download.+ gh release edit "$RELEASE_TAG" --repo "$RELEASE_REPOSITORY" --latest+ echo "Desktop release already promoted."+ else+ echo "A newer desktop release is already promoted."+ fiexit 0fi[ "$result" -eq 0 ] || exit "$result"@@ -45,7 +58,9 @@ elseecho "Could not read the existing desktop update channel" >&2exit 1fi- gh release create desktop-stable --repo "$RELEASE_REPOSITORY" --target "$RELEASE_TAG" \+ # --target accepts a branch or full commit SHA, not the versioned release tag.+ release_commit=$(git rev-parse --verify 'HEAD^{commit}')+ gh release create desktop-stable --repo "$RELEASE_REPOSITORY" --target "$release_commit" \--prerelease --latest=false --title "Desktop stable update feed" \--notes "Update metadata only. Download installers from a versioned desktop release."fi