Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

Recover annotated web release tags after Actions checkout (#686)

Dee5b3e9b305e4f
diff --git a/.github/workflows/release-web.yml b/.github/workflows/release-web.yml
index 49fdf8350..9c95cc24e 100644
--- a/.github/workflows/release-web.yml
+++ b/.github/workflows/release-web.yml
@@ -62,8 +62,6 @@ jobs:
HAS_WIF: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER != '' }}
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- with:
- fetch-depth: 0
# Tag-only trigger, so GITHUB_REF_NAME is already the bare tag (e.g. v1.3.1_web) and that is
# the image tag ArgoCD deploys by. The X.Y.Z inside it is also the bundle's version.
@@ -76,10 +74,9 @@ jobs:
echo "::error::Tag $GITHUB_REF_NAME is not vX.Y.Z_web"
exit 1
}
- website_only=false
+ website_only="$(bash desktop/scripts/web-release-mode.sh "$GITHUB_REF" "$GITHUB_SHA")"
archive_path="$BUNDLE_IN_CONTEXT"
- if git for-each-ref --format='%(contents)' "$GITHUB_REF" | grep -qx 'Website-Only: true'; then
- website_only=true
+ if [ "$website_only" = true ]; then
archive_path=''
# Check again at publication time in case another app release landed.
python3 desktop/scripts/verify-website-only-release.py "$GITHUB_SHA" live
diff --git a/desktop/scripts/web-release-mode.sh b/desktop/scripts/web-release-mode.sh
new file mode 100644
index 000000000..2c46c0249
--- /dev/null
+++ b/desktop/scripts/web-release-mode.sh
@@ -0,0 +1,21 @@
+#!/usr/bin/env bash
+# Read the remote annotated tag, even when actions/checkout replaced its local
+# ref with the peeled commit. Never infer a full release from missing metadata.
+set -euo pipefail
+ref="${1:?release tag ref required}"
+expected_sha="${2:?expected source commit required}"
+[[ "$ref" =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+_web$ ]] || {
+ echo 'Expected refs/tags/vX.Y.Z_web' >&2; exit 1;
+}
+git fetch --no-tags --depth=1 --force origin "$ref:$ref"
+[ "$(git cat-file -t "$ref")" = tag ] || {
+ echo 'Release tag must be annotated; use make release-web' >&2; exit 1;
+}
+[ "$(git rev-parse "$ref^{commit}")" = "$expected_sha" ] || {
+ echo 'Release tag differs from the checked-out source' >&2; exit 1;
+}
+if git for-each-ref --format='%(contents)' "$ref" | grep -qx 'Website-Only: true'; then
+ echo true
+else
+ echo false
+fi
diff --git a/scripts/tests/test_web_release_mode.py b/scripts/tests/test_web_release_mode.py
new file mode 100644
index 000000000..94a94f827
--- /dev/null
+++ b/scripts/tests/test_web_release_mode.py
@@ -0,0 +1,71 @@
+from pathlib import Path
+import subprocess
+import tempfile
+import unittest
+
+
+SCRIPT = Path(__file__).resolve().parents[2] / 'desktop/scripts/web-release-mode.sh'
+
+
+class WebReleaseModeTests(unittest.TestCase):
+ def setUp(self):
+ self.temporary = tempfile.TemporaryDirectory()
+ self.addCleanup(self.temporary.cleanup)
+ root = Path(self.temporary.name)
+ self.repo = root / 'checkout'
+ self.repo.mkdir()
+ self.origin = root / 'origin.git'
+ subprocess.run(['git', 'init', '--bare', str(self.origin)], check=True, capture_output=True)
+ self.git('init')
+ self.git('config', 'user.name', 'Release test')
+ self.git('config', 'user.email', '[email protected]')
+ self.git('commit', '--allow-empty', '-m', 'Fixture')
+ self.sha = self.git('rev-parse', 'HEAD').stdout.strip()
+ self.ref = 'refs/tags/v1.3.27_web'
+ self.git('remote', 'add', 'origin', str(self.origin))
+
+ def git(self, *args):
+ return subprocess.run(['git', *args], cwd=self.repo, check=True,
+ text=True, capture_output=True, timeout=10)
+
+ def mode(self, expected=None):
+ return subprocess.run(['bash', str(SCRIPT), self.ref, expected or self.sha],
+ cwd=self.repo, text=True, capture_output=True, timeout=15)
+
+ def publish(self, message):
+ if message is None:
+ self.git('tag', 'v1.3.27_web')
+ else:
+ self.git('tag', '-a', 'v1.3.27_web', '-m', message)
+ self.git('push', 'origin', self.ref)
+
+ def test_recovers_website_mode_after_checkout_peels_tag(self):
+ self.publish('Harness website\n\nWebsite-Only: true')
+ self.git('update-ref', self.ref, self.sha)
+ self.assertEqual(self.git('cat-file', '-t', self.ref).stdout.strip(), 'commit')
+ result = self.mode()
+ self.assertEqual(result.returncode, 0, result.stderr)
+ self.assertEqual(result.stdout.strip(), 'true')
+ self.assertEqual(self.git('cat-file', '-t', self.ref).stdout.strip(), 'tag')
+
+ def test_normal_annotated_release_builds_flutter(self):
+ self.publish('Harness web 1.3.27')
+ result = self.mode()
+ self.assertEqual(result.returncode, 0, result.stderr)
+ self.assertEqual(result.stdout.strip(), 'false')
+
+ def test_missing_annotation_stops_instead_of_building_flutter(self):
+ self.publish(None)
+ result = self.mode()
+ self.assertNotEqual(result.returncode, 0)
+ self.assertIn('must be annotated', result.stderr)
+
+ def test_moved_tag_stops_before_publication(self):
+ self.publish('Harness website\n\nWebsite-Only: true')
+ result = self.mode('a' * 40)
+ self.assertNotEqual(result.returncode, 0)
+ self.assertIn('differs from', result.stderr)
+
+
+if __name__ == '__main__':
+ unittest.main()