Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.
Rust agentai-agentapplecomputer-usecomputer-use-agentcontainerizationcuadesktop-automationhacktoberfestlumemacosmanusoperatorswiftvirtualizationvirtualization-frameworkwindowswindows-sandbox
fix(release): restrict package bumps to owner (#2330)
Francesco Bonacci537e1a0f6da6
diff --git a/.github/scripts/tests/test_release_bump_authorization.py b/.github/scripts/tests/test_release_bump_authorization.pynew file mode 100644index 0000000000..8b0fdfc732--- /dev/null+++ b/.github/scripts/tests/test_release_bump_authorization.py@@ -0,0 +1,58 @@+"""Regression tests for package version-bump authorization."""++from pathlib import Path+import unittest+++REPO_ROOT = Path(__file__).resolve().parents[3]+++class TestReleaseBumpAuthorization(unittest.TestCase):+ """Verify that humans other than the release owner cannot bump packages."""++ def test_bump_workflow_is_gated_before_write_access(self) -> None:+ workflow = (+ REPO_ROOT / ".github/workflows/release-bump-version.yml"+ ).read_text()++ self.assertIn("permissions: {}", workflow)+ self.assertIn(" authorize:\n", workflow)+ self.assertIn('ACTOR: ${{ github.actor }}', workflow)+ self.assertIn('TRIGGERING_ACTOR: ${{ github.triggering_actor }}', workflow)+ self.assertIn(+ '"f-trycua:f-trycua"|'+ '"cua-release-bot[bot]:cua-release-bot[bot]")',+ workflow,+ )+ self.assertIn(" bump-version:\n needs: authorize\n", workflow)+ self.assertIn(+ " permissions:\n contents: write\n steps:\n",+ workflow,+ )++ def test_auto_release_requires_owner_applied_labels(self) -> None:+ workflow = (+ REPO_ROOT / ".github/workflows/release-on-merge.yml"+ ).read_text()++ self.assertIn(+ 'LABEL_EVENTS=$(gh api --paginate --slurp \\\n'+ ' "repos/$REPO/issues/$PR_NUMBER/events?per_page=100")',+ workflow,+ )+ self.assertIn("label_was_applied_by_release_owner()", workflow)+ self.assertIn('.actor.login == "f-trycua"', workflow)+ self.assertIn(+ 'label_was_applied_by_release_owner "bump:major"', workflow+ )+ self.assertIn(+ 'label_was_applied_by_release_owner "bump:minor"', workflow+ )+ self.assertIn(+ 'label_was_applied_by_release_owner "$release_label"', workflow+ )+ self.assertIn("No owner-authorized release labels found", workflow)+++if __name__ == "__main__":+ unittest.main()diff --git a/.github/workflows/ci-test-scripts.yml b/.github/workflows/ci-test-scripts.ymlindex 5778bad070..5e57b9567a 100644--- a/.github/workflows/ci-test-scripts.yml+++ b/.github/workflows/ci-test-scripts.yml@@ -10,6 +10,8 @@ on:- ".github/workflows/cd-rust-cua-driver.yml"- ".github/workflows/cd-swift-lume.yml"- ".github/workflows/release-please.yml"+ - ".github/workflows/release-bump-version.yml"+ - ".github/workflows/release-on-merge.yml"- ".release-please-manifest.json"- "release-please-config.json"- ".github/workflows/ci-test-scripts.yml"diff --git a/.github/workflows/release-bump-version.yml b/.github/workflows/release-bump-version.ymlindex 669320135f..c5428de0ec 100644--- a/.github/workflows/release-bump-version.yml+++ b/.github/workflows/release-bump-version.yml@@ -51,12 +51,33 @@ on:type: stringdefault: "main"-permissions:- contents: write+permissions: {}jobs:+ authorize:+ name: Authorize version bump+ runs-on: ubuntu-latest+ steps:+ - name: Allow only the release owner or trusted automation+ env:+ ACTOR: ${{ github.actor }}+ TRIGGERING_ACTOR: ${{ github.triggering_actor }}+ run: |+ case "$ACTOR:$TRIGGERING_ACTOR" in+ "f-trycua:f-trycua"|"cua-release-bot[bot]:cua-release-bot[bot]")+ echo "Version bump authorized for $ACTOR."+ ;;+ *)+ echo "::error::Only f-trycua may manually bump package versions."+ exit 1+ ;;+ esac+bump-version:+ needs: authorizeruns-on: ubuntu-latest+ permissions:+ contents: writesteps:- name: Set package directory and typeid: packagediff --git a/.github/workflows/release-on-merge.yml b/.github/workflows/release-on-merge.ymlindex 38497d14e6..f14d6879a1 100644--- a/.github/workflows/release-on-merge.yml+++ b/.github/workflows/release-on-merge.yml@@ -36,11 +36,39 @@ jobs:exit 0fi+ # A label only authorizes a release when its latest add/remove event+ # shows that the release owner applied it and it remains present.+ LABEL_EVENTS=$(gh api --paginate --slurp \+ "repos/$REPO/issues/$PR_NUMBER/events?per_page=100")++ label_was_applied_by_release_owner() {+ local label=$1+ jq -e --arg label "$label" '+ [+ .[][]+ | select(+ (.event == "labeled" or .event == "unlabeled")+ and .label.name == $label+ )+ ]+ | last+ | .event == "labeled" and .actor.login == "f-trycua"+ ' <<< "$LABEL_EVENTS" > /dev/null+ }+# Determine bump type from labels (default: patch)BUMP_TYPE="patch"if echo "$LABELS" | grep -q '"bump:major"'; then+ if ! label_was_applied_by_release_owner "bump:major"; then+ echo "::warning::bump:major was not applied by f-trycua; skipping auto-release."+ exit 0+ fiBUMP_TYPE="major"elif echo "$LABELS" | grep -q '"bump:minor"'; then+ if ! label_was_applied_by_release_owner "bump:minor"; then+ echo "::warning::bump:minor was not applied by f-trycua; skipping auto-release."+ exit 0+ fiBUMP_TYPE="minor"fiecho "Bump type: $BUMP_TYPE"@@ -102,13 +130,18 @@ jobs:# Collect labeled packages for auto-releaseLABELED=()for svc in "${!AFFECTED_MAP[@]}"; do- if echo "$LABELS" | grep -q "\"release:${svc}\""; then- LABELED+=("$svc")+ release_label="release:${svc}"+ if echo "$LABELS" | grep -q "\"${release_label}\""; then+ if label_was_applied_by_release_owner "$release_label"; then+ LABELED+=("$svc")+ else+ echo "::warning::$release_label was not applied by f-trycua; ignoring it."+ fifidoneif [ ${#LABELED[@]} -eq 0 ]; then- echo "No release labels found. Daily digest will catch unreleased packages."+ echo "No owner-authorized release labels found. Daily digest will catch unreleased packages."exit 0fi