From d6e5ea0f3643fb371574e973e7cb25c593713739 Mon Sep 17 00:00:00 2001 From: Arnis Voitkans Date: Tue, 22 Sep 2026 06:58:01 +0300 Subject: [PATCH] Use the release creation response to publish draft reports --- ci/release/README.md | 10 ++++++---- ci/release/publish_report.py | 9 +++++---- ci/release/test_release.py | 25 +++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/ci/release/README.md b/ci/release/README.md index 1f12f6849cc..36f6ed4169c 100644 --- a/ci/release/README.md +++ b/ci/release/README.md @@ -12,8 +12,8 @@ publisher versions. Source revision and package/lock hashes are derived from the checked-out commit; `image/inputs.json` is generated. The source context is a Git archive without submodule contents. Frozen dependency installation and persistent BuildKit `gha` cache retain dependency layers; PRs only read the trusted cache. -A PR build and a mainline build validate different commits. Warm-cache speed is -not established until real runs measure it. +A PR build and a mainline build validate different commits. The first mainline run +populates the cache; measure later runs before claiming a warm-cache speedup. ## Activation and retries @@ -23,8 +23,10 @@ access and Actions access for `LUMII-AILab/dspace-angular`. Grant the app reposi write access through the package's **Manage Actions access**, preserving the existing package/reader. Do not delete/recreate the package or change visibility. Then set repository variable `CLARIN_RELEASE_PUBLISH_ENABLED=true`. The one-time -switch is separate from the automatic per-merge flow. The current CLI cannot inspect -package permissions (missing `read:packages`); this review/activation remains pending. +switch is separate from the automatic per-merge flow. Activation was completed on +2026-09-21 after owner confirmation and independent private-package/reader checks. +The ordinary CLI token lacks `read:packages`; do not interpret that token's 403 as +a package visibility or deployment-reader failure. See [GitHub package access](https://docs.github.com/en/packages/learn-github-packages/configuring-a-packages-access-control-and-visibility). Merge/push and workflow execution require their own requested publication scope. diff --git a/ci/release/publish_report.py b/ci/release/publish_report.py index c83fe6bda6d..72d30c0e803 100644 --- a/ci/release/publish_report.py +++ b/ci/release/publish_report.py @@ -26,10 +26,11 @@ def find_release(): release = find_release() if release is None: - command('release', 'create', version, '-R', repo, '--draft', '--target', record['source'], - '--title', version, '--notes', - 'Exact-image checks passed. Synthetic rehearsal only; scan findings remain report-only.') - release = find_release() + # Use the creation response: listing immediately afterward can be stale. + release = json.loads(command('api', '--method', 'POST', f'repos/{repo}/releases', + '-f', f'tag_name={version}', '-f', f'target_commitish={record["source"]}', + '-f', f'name={version}', '-F', 'draft=true', '-f', + 'body=Exact-image checks passed. Synthetic rehearsal only; scan findings remain report-only.')) assert release and release['tag_name'] == version assert release['target_commitish'] == record['source'], 'Release target changed' names = {asset['name'] for asset in release['assets']} diff --git a/ci/release/test_release.py b/ci/release/test_release.py index 276f596e686..f6964e38735 100644 --- a/ci/release/test_release.py +++ b/ci/release/test_release.py @@ -163,6 +163,31 @@ def gh(*args): state['assets']['release.json']=b'changed' with self.assertRaises(AssertionError): publish_report.publish(record,root) + def test_new_draft_uses_creation_response_when_release_list_is_stale(self): + import publish_report + with tempfile.TemporaryDirectory() as d: + root=Path(d) + (root/'release.json').write_text('{"verified":true}') + record=dict(repository='owner/app',version='sha-'+'a'*40,source='a'*40) + calls=[] + def gh(*args): + calls.append(args) + if args[:2]==('api','--paginate'): return '' # Listing remains stale. + if args[:3]==('api','--method','POST'): + self.assertIn('draft=true',args) + return json.dumps(dict(id=1,tag_name=record['version'], + target_commitish=record['source'],draft=True,assets=[])) + if args[:2]==('release','download'): + (Path(args[-1])/'release.json').write_bytes((root/'release.json').read_bytes()) + if args[0]=='api' and '/commits/' in args[1]: + return json.dumps({'sha':record['source']}) + return '' + with patch.object(publish_report,'command',side_effect=gh): + publish_report.publish(record,root) + self.assertEqual(sum(c[:2]==('api','--paginate') for c in calls),1) + self.assertTrue(any(c[:2]==('release','upload') for c in calls)) + self.assertTrue(any(c[:2]==('release','edit') for c in calls)) + def test_workflow_qualifies_before_publishing_without_private_checkout(self): workflow=(ROOT/'.github/workflows/clarin-release.yml').read_text() build,publish=workflow.split('\n publish:\n')