Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/sdk-release.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"engine_commit": "8fd3e8780c985721730855396de987e59e268fcf"
"engine_commit": "8fd3e8780c985721730855396de987e59e268fcf",
"attempt": 2
}
13 changes: 6 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,13 @@ jobs:
env:
REQUESTED_ENGINE_COMMIT: ${{ inputs.engine_commit }}
REQUEST_EVENT: ${{ github.event_name }}
shell: python
shell: bash
run: |
import os
from release import SDKRelease
override = os.environ['REQUESTED_ENGINE_COMMIT'] if os.environ['REQUEST_EVENT'] == 'workflow_dispatch' else None
commit = SDKRelease.requested_commit('.', override)
with open(os.environ['GITHUB_OUTPUT'], 'a') as output:
output.write('commit=' + commit + '\n')
if [ "$REQUEST_EVENT" = workflow_dispatch ]; then
python release.py resolve-request --commit "$REQUESTED_ENGINE_COMMIT" >> "$GITHUB_OUTPUT"
else
python release.py resolve-request >> "$GITHUB_OUTPUT"
fi
build:
needs: request
strategy:
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ for software that users execute.
access. Merging it into `main` automatically starts all three native builds.
This repository's initial request selects the already-tagged engine revision
`8fd3e8780c985721730855396de987e59e268fcf`.
To retry an unpublished revision through a PR, increment the request's
optional positive integer `attempt` field (default: 1). Merging that request
starts a fresh run without moving the source tag.
Manual **Build and publish binary SDKs** runs on `main` remain available for
retries, using the same exact commit SHA.
All three native-host SDK jobs must pass. The release contains three ZIP
Expand Down
12 changes: 9 additions & 3 deletions release.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ class SDKRelease:
def requested_commit(cls, root, override=None):
if override is None:
request = json.loads((Path(root) / ".github/sdk-release.json").read_text())
if not isinstance(request, dict) or set(request) != {"engine_commit"}:
if not isinstance(request, dict) or set(request) not in ({"engine_commit"}, {"engine_commit", "attempt"}):
raise ValueError("Unexpected release request fields")
attempt = request.get("attempt", 1)
if type(attempt) is not int or not 1 <= attempt <= 100000:
raise ValueError("Release attempt must be a positive integer")
override = request["engine_commit"]
if not isinstance(override, str) or not re.fullmatch(r"[0-9a-f]{40}", override):
raise ValueError("Release requests require a full engine commit")
Expand Down Expand Up @@ -198,7 +201,7 @@ def stage(cls, source, destination, commit, targets):

if __name__ == "__main__":
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("command", choices=("check-repository", "stage"))
parser.add_argument("command", choices=("check-repository", "resolve-request", "stage"))
parser.add_argument("--root", default=".")
parser.add_argument("--input", type=Path)
parser.add_argument("--output", type=Path)
Expand All @@ -208,9 +211,12 @@ def stage(cls, source, destination, commit, targets):
try:
if args.command == "check-repository":
SDKRelease.check_repository(args.root)
elif args.command == "resolve-request":
print("commit=" + SDKRelease.requested_commit(args.root, args.commit))
else:
SDKRelease.stage(args.input, args.output, args.commit, (args.target,) if args.target else tuple(SDKRelease.TARGETS))
except Exception:
print("PUBLICATION_POLICY_FAILED: output withheld; inspect privately.", file=sys.stderr)
sys.exit(1)
print("PUBLICATION_POLICY_OK")
if args.command != "resolve-request":
print("PUBLICATION_POLICY_OK")
17 changes: 17 additions & 0 deletions test_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from pathlib import Path
import struct
import subprocess
import sys
import tempfile
import unittest
import zipfile
Expand Down Expand Up @@ -107,6 +108,22 @@ def test_release_requests_and_manual_overrides_require_exact_commits(self):
with self.subTest(override=value), self.assertRaises(ValueError):
SDKRelease.requested_commit(self.root, value)

def test_release_request_cli_emits_only_github_job_output(self):
directory = self.root / '.github'; directory.mkdir()
request = directory / 'sdk-release.json'
request.write_text(json.dumps({'engine_commit': self.commit, 'attempt': 2}))
command = [sys.executable, str(Path(__file__).with_name('release.py').resolve()), 'resolve-request', '--root', str(self.root)]
result = subprocess.run(command, cwd=self.root, capture_output=True, text=True, check=True)
self.assertEqual(result.stdout, 'commit=' + self.commit + '\n')
result = subprocess.run(command + ['--commit', 'b' * 40], cwd=self.root, capture_output=True, text=True, check=True)
self.assertEqual(result.stdout, 'commit=' + 'b' * 40 + '\n')
for attempt in (0, -1, True, '2', 100001):
request.write_text(json.dumps({'engine_commit': self.commit, 'attempt': attempt}))
result = subprocess.run(command, cwd=self.root, capture_output=True, text=True)
self.assertNotEqual(result.returncode, 0)
self.assertEqual(result.stdout, '')
self.assertNotIn('Traceback', result.stderr)

def test_repository_history_keeps_deleted_source_visible_to_the_audit(self):
repo = self.root / 'repo'; repo.mkdir()
subprocess.run(['git', 'init', '-q', str(repo)], check=True)
Expand Down