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: 3 additions & 0 deletions .github/sdk-release.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"engine_commit": "8fd3e8780c985721730855396de987e59e268fcf"
}
43 changes: 37 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# SPDX-License-Identifier: AGPL-3.0-only
name: Build and publish binary SDKs
on:
push:
branches: [main]
paths: ['.github/sdk-release.json']
workflow_dispatch:
inputs:
engine_commit:
Expand All @@ -9,11 +12,39 @@ on:
permissions:
contents: read
concurrency:
group: sdk-${{ inputs.engine_commit }}
group: sdk-${{ inputs.engine_commit || github.sha }}
cancel-in-progress: false
jobs:
build:
request:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-22.04
outputs:
commit: ${{ steps.revision.outputs.commit }}
steps:
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
with:
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
with:
python-version: '3.12'
- name: Audit the reviewed release request
run: python release.py check-repository
- name: Resolve the requested engine revision
id: revision
env:
REQUESTED_ENGINE_COMMIT: ${{ inputs.engine_commit }}
REQUEST_EVENT: ${{ github.event_name }}
shell: python
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')
build:
needs: request
strategy:
fail-fast: false
matrix:
Expand All @@ -26,7 +57,7 @@ jobs:
target: macos-universal
runs-on: ${{ matrix.os }}
env:
ENGINE_COMMIT: ${{ inputs.engine_commit }}
ENGINE_COMMIT: ${{ needs.request.outputs.commit }}
SDK_TARGET: ${{ matrix.target }}
steps:
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
Expand All @@ -46,7 +77,7 @@ jobs:
uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
with:
repository: RakuenSoftware/wol-engine
ref: runtime-${{ inputs.engine_commit }}
ref: runtime-${{ needs.request.outputs.commit }}
token: ${{ secrets.ENGINE_SOURCE_TOKEN }}
path: private-engine
submodules: recursive
Expand Down Expand Up @@ -105,12 +136,12 @@ jobs:
if-no-files-found: error
retention-days: 7
publish:
needs: build
needs: [request, build]
runs-on: ubuntu-22.04
permissions:
contents: write
env:
ENGINE_COMMIT: ${{ inputs.engine_commit }}
ENGINE_COMMIT: ${{ needs.request.outputs.commit }}
steps:
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
with:
Expand Down
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ repository's Releases page.
- Public Git history contains only the explicitly allowed automation, tests,
documentation and licence files. The audit checks all reachable history, so
deleting a forbidden file in a later commit does not make it acceptable.
- Only a manual run of the workflow on `main` can access the source credential.
Pull request checks never receive it. Maintainers who can change `main` or
- Merging a reviewed change to `.github/sdk-release.json` into `main` starts
the native release builds. Manual runs on `main` are also available.
Pull request checks never receive the source credential. Maintainers who can change `main` or
workflows are trusted with this credential; review those changes accordingly.
- Each fresh GitHub-hosted Linux, Windows and Mac runner temporarily checks out
an exact private `runtime-<40-character SHA>` tag into a separate sibling
Expand Down Expand Up @@ -47,7 +48,13 @@ for software that users execute.
workflow inputs, commits or logs. Keep automatic pull request reviews enabled.
3. Merge this repository's reviewed automation to `main`. Create a private
engine tag `runtime-<full commit SHA>` for the reviewed source to build.
4. Run **Build and publish binary SDKs** on `main` with that exact commit SHA.
4. Open a PR updating `.github/sdk-release.json` to that exact commit SHA.
The PR validates the request and publication policy without private source
access. Merging it into `main` automatically starts all three native builds.
This repository's initial request selects the already-tagged engine revision
`8fd3e8780c985721730855396de987e59e268fcf`.
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
archives and their checksum records; GitHub's automatic source archives
contain only this public automation repository.
Expand Down
15 changes: 14 additions & 1 deletion release.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,28 @@ class SDKRelease:
"windows-x64": ("windows", "x86_64", "dll"),
"macos-universal": ("macos", "universal", "dylib")}
PUBLIC_FILES = {"LICENSE", "README.md", "SECURITY.md", "AGENTS.md", ".gitignore", "release.py",
"test_release.py", ".github/workflows/build.yml", ".github/workflows/audit.yml"}
"test_release.py", ".github/sdk-release.json", ".github/workflows/build.yml", ".github/workflows/audit.yml"}
FORBIDDEN = {".c", ".cpp", ".cc", ".cxx", ".h", ".hpp", ".hxx", ".gd", ".gdshader", ".gdshaderinc",
".glsl", ".hlsl", ".shader", ".pdb", ".snupkg", ".csproj", ".sln", ".map", ".py", ".sh", ".ps1", ".js", ".ts", ".rs", ".log"}
SOURCE_TEXT = re.compile(rb'(?m)^\s*(?:namespace\s+Wol\.Engine\b|(?:public|internal)\s+(?:(?:partial|sealed|static|abstract)\s+)*(?:class|struct|interface|record)\s+\w+|shader_type\s+\w+\s*;|void\s+(?:vertex|fragment)\s*\(|#include\s*[<"])')
SECRET_TEXT = re.compile(rb'(?:-----BEGIN (?:OPENSSH |RSA |EC )?PRIVATE KEY-----|github_pat_[A-Za-z0-9_]{20,}|gh[pousr]_[A-Za-z0-9_]{20,})')

@classmethod
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"}:
raise ValueError("Unexpected release request fields")
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")
return override

@classmethod
def check_repository(cls, root):
root = Path(root)
if (root / ".github/sdk-release.json").exists():
cls.requested_commit(root)
paths = set(subprocess.check_output(["git", "ls-files", "-z"], cwd=root).decode().split("\0")) - {""}
revisions = subprocess.check_output(["git", "rev-list", "--all"], cwd=root).decode().splitlines()
for revision in revisions:
Expand Down
16 changes: 16 additions & 0 deletions test_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,22 @@ def test_checksum_sidecars_cannot_carry_extra_content(self):
with archive.with_suffix('.zip.sha256').open('a') as stream: stream.write('private diagnostic text')
with self.assertRaises(ValueError): SDKRelease.check_sdk(archive, self.commit, 'linux-x64')

def test_release_requests_and_manual_overrides_require_exact_commits(self):
directory = self.root / '.github'; directory.mkdir()
request = directory / 'sdk-release.json'
request.write_text(json.dumps({'engine_commit': self.commit}))
self.assertEqual(SDKRelease.requested_commit(self.root), self.commit)
self.assertEqual(SDKRelease.requested_commit(self.root, 'b' * 40), 'b' * 40)
for data in ({'engine_commit': 'main'}, {'engine_commit': self.commit + '/extra'},
{'engine_commit': self.commit.upper()}, {'engine_commit': self.commit, 'command': 'extra'},
{'engine_commit': None}, ['unexpected']):
request.write_text(json.dumps(data))
with self.subTest(data=data), self.assertRaises(ValueError):
SDKRelease.requested_commit(self.root)
for value in ('', 'main', 'a' * 39, 'a' * 40 + '\n'):
with self.subTest(override=value), self.assertRaises(ValueError):
SDKRelease.requested_commit(self.root, value)

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