release-kit 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- release_kit/__init__.py +35 -0
- release_kit/config.py +81 -0
- release_kit/create_release.py +165 -0
- release_kit/ensure_release_pr.py +23 -0
- release_kit/feeds.py +126 -0
- release_kit/fetch_ci_artifacts.py +75 -0
- release_kit/ledger.py +33 -0
- release_kit/mirror_images.py +37 -0
- release_kit/plan.py +83 -0
- release_kit/publish_dev.py +104 -0
- release_kit/publish_packages.py +119 -0
- release_kit/py.typed +0 -0
- release_kit-0.1.0.dist-info/METADATA +13 -0
- release_kit-0.1.0.dist-info/RECORD +18 -0
- release_kit-0.1.0.dist-info/WHEEL +4 -0
- release_kit-0.1.0.dist-info/entry_points.txt +7 -0
- release_kit-0.1.0.dist-info/licenses/LICENSE +201 -0
- release_kit-0.1.0.dist-info/licenses/NOTICE +1 -0
release_kit/__init__.py
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
from .config import AppConfig, PackageConfig, PublishConfig, load_config, select_packages
|
|
2
|
+
from .feeds import Feed, NuGetFeed, NpmFeed, PublishRequest, build_feeds, pep440_dev_version, semver_dev_version
|
|
3
|
+
from .ledger import GitLedger
|
|
4
|
+
from .plan import (
|
|
5
|
+
PackagePlan,
|
|
6
|
+
TagLedger,
|
|
7
|
+
compute_plan,
|
|
8
|
+
next_version,
|
|
9
|
+
render_dev_summary,
|
|
10
|
+
render_summary,
|
|
11
|
+
resolved_dependency_versions,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
__all__ = [
|
|
15
|
+
"AppConfig",
|
|
16
|
+
"Feed",
|
|
17
|
+
"GitLedger",
|
|
18
|
+
"NpmFeed",
|
|
19
|
+
"NuGetFeed",
|
|
20
|
+
"PackageConfig",
|
|
21
|
+
"PackagePlan",
|
|
22
|
+
"PublishConfig",
|
|
23
|
+
"PublishRequest",
|
|
24
|
+
"TagLedger",
|
|
25
|
+
"build_feeds",
|
|
26
|
+
"compute_plan",
|
|
27
|
+
"load_config",
|
|
28
|
+
"next_version",
|
|
29
|
+
"pep440_dev_version",
|
|
30
|
+
"render_dev_summary",
|
|
31
|
+
"render_summary",
|
|
32
|
+
"resolved_dependency_versions",
|
|
33
|
+
"select_packages",
|
|
34
|
+
"semver_dev_version",
|
|
35
|
+
]
|
release_kit/config.py
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
from collections.abc import Sequence
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
from pydantic import BaseModel, Field, model_validator
|
|
5
|
+
|
|
6
|
+
from .feeds import KNOWN_FEEDS
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class PackageConfig(BaseModel):
|
|
10
|
+
name: str
|
|
11
|
+
path: Path
|
|
12
|
+
feeds: dict[str, str] = Field(default_factory=dict)
|
|
13
|
+
depends_on: list[str] = Field(default_factory=list)
|
|
14
|
+
dependency_pins: dict[str, str] = Field(default_factory=dict)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class AppConfig(BaseModel):
|
|
18
|
+
name: str
|
|
19
|
+
path: Path
|
|
20
|
+
tag_prefix: str
|
|
21
|
+
display_name: str
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class PublishConfig(BaseModel):
|
|
25
|
+
packages: list[PackageConfig]
|
|
26
|
+
apps: list[AppConfig] = Field(default_factory=list)
|
|
27
|
+
compose_files: list[str] = Field(default_factory=list)
|
|
28
|
+
ci_workflow: str
|
|
29
|
+
mirror_prefix: str
|
|
30
|
+
artifact_dir: Path = Path("/tmp/release-artifacts")
|
|
31
|
+
artifact_skip_prefixes: list[str] = Field(default_factory=lambda: ["env-lock-", "versions"])
|
|
32
|
+
artifact_skip_suffixes: list[str] = Field(default_factory=lambda: ["-build-report"])
|
|
33
|
+
|
|
34
|
+
@model_validator(mode="after")
|
|
35
|
+
def validate_dependency_graph(self) -> "PublishConfig":
|
|
36
|
+
seen: set[str] = set()
|
|
37
|
+
for package in self.packages:
|
|
38
|
+
for dependency in package.depends_on:
|
|
39
|
+
if dependency not in seen:
|
|
40
|
+
if dependency in {p.name for p in self.packages}:
|
|
41
|
+
message = f"package '{package.name}' depends on '{dependency}', which appears later in the list; packages must be ordered dependencies-first"
|
|
42
|
+
else:
|
|
43
|
+
message = f"package '{package.name}' depends on unknown package '{dependency}'"
|
|
44
|
+
raise ValueError(message)
|
|
45
|
+
seen.add(package.name)
|
|
46
|
+
|
|
47
|
+
names = {package.name for package in self.packages}
|
|
48
|
+
for package in self.packages:
|
|
49
|
+
for pinned in package.dependency_pins.values():
|
|
50
|
+
if pinned not in names:
|
|
51
|
+
raise ValueError(f"package '{package.name}' pins unknown package '{pinned}'")
|
|
52
|
+
|
|
53
|
+
return self
|
|
54
|
+
|
|
55
|
+
@model_validator(mode="after")
|
|
56
|
+
def validate_feed_names(self) -> "PublishConfig":
|
|
57
|
+
for package in self.packages:
|
|
58
|
+
unknown_feeds = set(package.feeds) - KNOWN_FEEDS
|
|
59
|
+
if unknown_feeds:
|
|
60
|
+
raise ValueError(f"package '{package.name}' declares unknown feeds: {sorted(unknown_feeds)}")
|
|
61
|
+
return self
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def load_config(path: Path) -> PublishConfig:
|
|
65
|
+
return PublishConfig.model_validate_json(path.read_text(encoding="utf-8"))
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def select_packages(packages: list[PackageConfig], only: Sequence[str], exclude: Sequence[str]) -> list[PackageConfig]:
|
|
69
|
+
if only and exclude:
|
|
70
|
+
raise SystemExit("--only and --exclude are mutually exclusive")
|
|
71
|
+
names = [package.name for package in packages]
|
|
72
|
+
for requested in [*only, *exclude]:
|
|
73
|
+
if requested not in names:
|
|
74
|
+
raise SystemExit(f"Unknown package '{requested}'. Valid: {', '.join(names)}")
|
|
75
|
+
if only:
|
|
76
|
+
selected = set(only)
|
|
77
|
+
return [package for package in packages if package.name in selected]
|
|
78
|
+
if exclude:
|
|
79
|
+
deselected = set(exclude)
|
|
80
|
+
return [package for package in packages if package.name not in deselected]
|
|
81
|
+
return packages
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import shutil
|
|
4
|
+
from datetime import UTC, datetime
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from tempfile import NamedTemporaryFile
|
|
7
|
+
from typing import Annotated
|
|
8
|
+
|
|
9
|
+
import typer
|
|
10
|
+
from bashrun import bash, bash_output
|
|
11
|
+
from pydantic_settings import BaseSettings
|
|
12
|
+
from stack_toolkit.context_sha import compute_service_shas
|
|
13
|
+
from unity_buildkit.ci_step import ci_step
|
|
14
|
+
|
|
15
|
+
from .config import PublishConfig, load_config
|
|
16
|
+
from .ledger import GitLedger
|
|
17
|
+
from .plan import UNCHANGED_FALLBACK_VERSION
|
|
18
|
+
|
|
19
|
+
app = typer.Typer(add_completion=False, pretty_exceptions_show_locals=False)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class Settings(BaseSettings):
|
|
23
|
+
github_repository: str
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def _package_artifacts(config: PublishConfig) -> list[Path]:
|
|
27
|
+
artifact_dir = config.artifact_dir
|
|
28
|
+
assets: list[Path] = []
|
|
29
|
+
if not artifact_dir.is_dir():
|
|
30
|
+
print("No release artifacts directory found")
|
|
31
|
+
return assets
|
|
32
|
+
|
|
33
|
+
for entry in sorted(artifact_dir.iterdir()):
|
|
34
|
+
if not entry.is_dir():
|
|
35
|
+
continue
|
|
36
|
+
if any(entry.name.startswith(p) for p in config.artifact_skip_prefixes):
|
|
37
|
+
print(f" Skipping: {entry.name} (not a release artifact)")
|
|
38
|
+
continue
|
|
39
|
+
if any(entry.name.endswith(s) for s in config.artifact_skip_suffixes):
|
|
40
|
+
print(f" Skipping: {entry.name} (not a release artifact)")
|
|
41
|
+
continue
|
|
42
|
+
|
|
43
|
+
files = [f for f in entry.rglob("*") if f.is_file()]
|
|
44
|
+
if not files:
|
|
45
|
+
print(f" Skipping: {entry.name} (empty)")
|
|
46
|
+
continue
|
|
47
|
+
|
|
48
|
+
if len(files) == 1:
|
|
49
|
+
asset = artifact_dir / f"{entry.name}{files[0].suffix}"
|
|
50
|
+
shutil.copy2(files[0], asset)
|
|
51
|
+
assets.append(asset)
|
|
52
|
+
print(f" Asset: {asset.name}")
|
|
53
|
+
else:
|
|
54
|
+
zip_path = artifact_dir / entry.name
|
|
55
|
+
shutil.make_archive(str(zip_path), "zip", entry)
|
|
56
|
+
asset = zip_path.parent / f"{zip_path.name}.zip"
|
|
57
|
+
assets.append(asset)
|
|
58
|
+
print(f" Asset: {asset.name} ({len(files)} files)")
|
|
59
|
+
|
|
60
|
+
return assets
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def _nuget_url(identity: str, version: str) -> str:
|
|
64
|
+
return f"https://www.nuget.org/packages/{identity}/{version}"
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def _npm_url(identity: str, version: str) -> str:
|
|
68
|
+
return f"https://www.npmjs.com/package/{identity}/v/{version}"
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def _pypi_url(identity: str, version: str) -> str:
|
|
72
|
+
return f"https://pypi.org/project/{identity}/{version}"
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
FEED_URLS = {"nuget": _nuget_url, "npm": _npm_url, "pypi": _pypi_url}
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def _build_release_notes(config: PublishConfig, service_shas: dict[str, str], ghcr_url: str) -> str:
|
|
79
|
+
ledger = GitLedger()
|
|
80
|
+
lines: list[str] = []
|
|
81
|
+
|
|
82
|
+
if service_shas:
|
|
83
|
+
lines.extend([
|
|
84
|
+
"## Docker images",
|
|
85
|
+
"",
|
|
86
|
+
f"Images on [GHCR]({ghcr_url}), per-service tags:",
|
|
87
|
+
"",
|
|
88
|
+
"| Env var | Tag |",
|
|
89
|
+
"|---|---|",
|
|
90
|
+
])
|
|
91
|
+
for var, sha in sorted(service_shas.items()):
|
|
92
|
+
lines.append(f"| `{var}` | `{sha}` |")
|
|
93
|
+
lines.append("")
|
|
94
|
+
|
|
95
|
+
lines.extend(["## Packages", "", "| Package | Version | Registry |", "|---|---|---|"])
|
|
96
|
+
for package in config.packages:
|
|
97
|
+
version = ledger.latest_version(f"{package.name}-v") or UNCHANGED_FALLBACK_VERSION
|
|
98
|
+
links: list[str] = []
|
|
99
|
+
for feed_name, identity in package.feeds.items():
|
|
100
|
+
url_builder = FEED_URLS.get(feed_name)
|
|
101
|
+
if url_builder is None:
|
|
102
|
+
links.append(feed_name)
|
|
103
|
+
elif version != UNCHANGED_FALLBACK_VERSION:
|
|
104
|
+
links.append(f"[{feed_name}]({url_builder(identity, version)})")
|
|
105
|
+
else:
|
|
106
|
+
links.append(feed_name)
|
|
107
|
+
display = package.name
|
|
108
|
+
lines.append(f"| {display} | {version} | {', '.join(links)} |")
|
|
109
|
+
|
|
110
|
+
for app_config in config.apps:
|
|
111
|
+
version = ledger.latest_version(f"{app_config.tag_prefix}-v")
|
|
112
|
+
if version:
|
|
113
|
+
lines.append(f"| {app_config.display_name} | {version} | — |")
|
|
114
|
+
|
|
115
|
+
lines.append("")
|
|
116
|
+
return "\n".join(lines)
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def _next_release_tag(repo: str) -> str:
|
|
120
|
+
today = datetime.now(UTC).strftime("%Y-%m-%d")
|
|
121
|
+
existing = bash_output(
|
|
122
|
+
f"gh release list --repo {repo} --json tagName --jq '[.[].tagName] | map(select(startswith(\"{today}\"))) | length'"
|
|
123
|
+
).strip()
|
|
124
|
+
count = int(existing) if existing else 0
|
|
125
|
+
return f"{today}.{count + 1}" if count > 0 else today
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
@app.command()
|
|
129
|
+
def main(config: Annotated[Path, typer.Option(help="Publish configuration JSON")]) -> None:
|
|
130
|
+
settings = Settings.model_validate({})
|
|
131
|
+
publish_config = load_config(config)
|
|
132
|
+
tag = _next_release_tag(settings.github_repository)
|
|
133
|
+
|
|
134
|
+
with ci_step("Compute service SHAs"):
|
|
135
|
+
service_shas: dict[str, str] = {}
|
|
136
|
+
for compose_file in publish_config.compose_files:
|
|
137
|
+
service_shas.update(compute_service_shas(Path.cwd(), Path(compose_file)))
|
|
138
|
+
for var, sha in sorted(service_shas.items()):
|
|
139
|
+
print(f" {var}={sha}")
|
|
140
|
+
|
|
141
|
+
with ci_step("Package artifacts"):
|
|
142
|
+
assets = _package_artifacts(publish_config)
|
|
143
|
+
if assets:
|
|
144
|
+
print(f" {len(assets)} asset(s) ready for upload")
|
|
145
|
+
else:
|
|
146
|
+
print(" No build artifacts to attach")
|
|
147
|
+
|
|
148
|
+
with ci_step("Create GitHub Release"):
|
|
149
|
+
owner, repository = settings.github_repository.split("/", maxsplit=1)
|
|
150
|
+
ghcr_url = f"https://github.com/orgs/{owner}/packages?repo_name={repository}"
|
|
151
|
+
notes = _build_release_notes(publish_config, service_shas, ghcr_url)
|
|
152
|
+
print(notes)
|
|
153
|
+
|
|
154
|
+
asset_args = " ".join(f'"{a}"' for a in assets)
|
|
155
|
+
with NamedTemporaryFile(mode="w", suffix=".md", delete=False, encoding="utf-8") as file:
|
|
156
|
+
file.write(notes)
|
|
157
|
+
notes_path = file.name
|
|
158
|
+
bash(
|
|
159
|
+
f"gh release create {tag} --title {tag}"
|
|
160
|
+
f" --notes-file {notes_path}"
|
|
161
|
+
f" --repo {settings.github_repository}"
|
|
162
|
+
f" {asset_args}"
|
|
163
|
+
)
|
|
164
|
+
Path(notes_path).unlink()
|
|
165
|
+
print(f" Release created: {tag}")
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import typer
|
|
4
|
+
from bashrun import bash_output
|
|
5
|
+
|
|
6
|
+
app = typer.Typer(add_completion=False, pretty_exceptions_show_locals=False)
|
|
7
|
+
|
|
8
|
+
BASE_BRANCH = "main"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@app.command()
|
|
12
|
+
def main() -> None:
|
|
13
|
+
existing = bash_output(
|
|
14
|
+
f'gh pr list --head dev --base {BASE_BRANCH} --state open --json number --jq ".[0].number"'
|
|
15
|
+
).strip()
|
|
16
|
+
if existing:
|
|
17
|
+
print(f"Release PR already exists: #{existing}")
|
|
18
|
+
else:
|
|
19
|
+
bash_output(
|
|
20
|
+
f'gh pr create --head dev --base {BASE_BRANCH} --title "Next release"'
|
|
21
|
+
' --body "Persistent release gate PR from `dev` → `main`. Merge when ready to cut a release."'
|
|
22
|
+
)
|
|
23
|
+
print("Created release PR")
|
release_kit/feeds.py
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import re
|
|
3
|
+
from collections.abc import Callable, Generator
|
|
4
|
+
from contextlib import contextmanager
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from subprocess import CalledProcessError
|
|
8
|
+
from typing import Protocol
|
|
9
|
+
|
|
10
|
+
from bashrun import bash, bash_output
|
|
11
|
+
|
|
12
|
+
NUGET_SOURCE = "https://api.nuget.org/v3/index.json"
|
|
13
|
+
PYPI_SIMPLE_INDEX = "https://pypi.org/simple/"
|
|
14
|
+
PYPROJECT_VERSION_PATTERN = re.compile(r'^version\s*=\s*"[^"]*"')
|
|
15
|
+
NPM_DEV_DIST_TAG = "dev"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@dataclass(frozen=True)
|
|
19
|
+
class PublishRequest:
|
|
20
|
+
path: Path
|
|
21
|
+
identity: str
|
|
22
|
+
version: str
|
|
23
|
+
dependency_versions: dict[str, str]
|
|
24
|
+
dist_tag: str | None = None
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class Feed(Protocol):
|
|
28
|
+
def publish(self, request: PublishRequest) -> None: ...
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class NuGetFeed:
|
|
32
|
+
def __init__(self, api_key: str) -> None:
|
|
33
|
+
self.api_key = api_key
|
|
34
|
+
|
|
35
|
+
def publish(self, request: PublishRequest) -> None:
|
|
36
|
+
bash(f"dotnet pack -c Release -p:Version={request.version} -o ./nupkg", cwd=request.path)
|
|
37
|
+
bash(
|
|
38
|
+
f"dotnet nuget push ./nupkg/*.nupkg --api-key {self.api_key} --source {NUGET_SOURCE} --skip-duplicate",
|
|
39
|
+
cwd=request.path,
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class NpmFeed:
|
|
44
|
+
def publish(self, request: PublishRequest) -> None:
|
|
45
|
+
command = "npm publish --access public --provenance"
|
|
46
|
+
if request.dist_tag:
|
|
47
|
+
command += f" --tag {request.dist_tag}"
|
|
48
|
+
with ephemeral_manifest_patch(request.path, request.version, request.dependency_versions):
|
|
49
|
+
try:
|
|
50
|
+
bash_output(command, cwd=request.path)
|
|
51
|
+
except CalledProcessError as e:
|
|
52
|
+
stderr = e.stderr or ""
|
|
53
|
+
if "EPUBLISHCONFLICT" in stderr or "cannot publish over existing version" in stderr:
|
|
54
|
+
print(" Version already published, skipping (idempotent)")
|
|
55
|
+
else:
|
|
56
|
+
raise
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class PyPIFeed:
|
|
60
|
+
def publish(self, request: PublishRequest) -> None:
|
|
61
|
+
if request.dependency_versions:
|
|
62
|
+
raise ValueError("pypi dependency pins are not supported")
|
|
63
|
+
with ephemeral_pyproject_patch(request.path, request.version):
|
|
64
|
+
bash("uv build --out-dir dist", cwd=request.path)
|
|
65
|
+
bash(f"uv publish --check-url {PYPI_SIMPLE_INDEX}", cwd=request.path)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
@contextmanager
|
|
69
|
+
def ephemeral_manifest_patch(package_path: Path, version: str, dependency_versions: dict[str, str]) -> Generator[None]:
|
|
70
|
+
manifest_path = package_path / "package.json"
|
|
71
|
+
original = manifest_path.read_text(encoding="utf-8")
|
|
72
|
+
try:
|
|
73
|
+
manifest = json.loads(original)
|
|
74
|
+
manifest["version"] = version
|
|
75
|
+
for dependency_name, dependency_version in dependency_versions.items():
|
|
76
|
+
manifest["dependencies"][dependency_name] = dependency_version
|
|
77
|
+
manifest_path.write_text(json.dumps(manifest, indent=2) + "\n", encoding="utf-8")
|
|
78
|
+
yield
|
|
79
|
+
finally:
|
|
80
|
+
manifest_path.write_text(original, encoding="utf-8")
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
@contextmanager
|
|
84
|
+
def ephemeral_pyproject_patch(package_path: Path, version: str) -> Generator[None]:
|
|
85
|
+
manifest_path = package_path / "pyproject.toml"
|
|
86
|
+
original = manifest_path.read_text(encoding="utf-8")
|
|
87
|
+
try:
|
|
88
|
+
manifest_path.write_text(patch_project_version(original, version), encoding="utf-8")
|
|
89
|
+
yield
|
|
90
|
+
finally:
|
|
91
|
+
manifest_path.write_text(original, encoding="utf-8")
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def patch_project_version(original: str, version: str) -> str:
|
|
95
|
+
lines = original.splitlines(keepends=True)
|
|
96
|
+
in_project_table = False
|
|
97
|
+
for index, line in enumerate(lines):
|
|
98
|
+
if line.startswith("["):
|
|
99
|
+
in_project_table = line.strip() == "[project]"
|
|
100
|
+
continue
|
|
101
|
+
if in_project_table and PYPROJECT_VERSION_PATTERN.match(line):
|
|
102
|
+
lines[index] = f'version = "{version}"\n'
|
|
103
|
+
return "".join(lines)
|
|
104
|
+
raise ValueError("pyproject.toml carries no [project] version to patch")
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
KNOWN_FEEDS = frozenset({"nuget", "npm", "pypi"})
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def semver_dev_version(base_version: str, run_id: str) -> str:
|
|
111
|
+
return f"{base_version}-dev.{run_id}"
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def pep440_dev_version(base_version: str, run_id: str) -> str:
|
|
115
|
+
return f"{base_version}.dev{run_id}"
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
DEV_VERSION_FORMATS: dict[str, Callable[[str, str], str]] = {
|
|
119
|
+
"nuget": semver_dev_version,
|
|
120
|
+
"npm": semver_dev_version,
|
|
121
|
+
"pypi": pep440_dev_version,
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def build_feeds(nuget_api_key: str) -> dict[str, Feed]:
|
|
126
|
+
return {"nuget": NuGetFeed(nuget_api_key), "npm": NpmFeed(), "pypi": PyPIFeed()}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from shutil import rmtree
|
|
5
|
+
from typing import Annotated
|
|
6
|
+
|
|
7
|
+
import typer
|
|
8
|
+
from bashrun import bash, bash_output
|
|
9
|
+
from pydantic_settings import BaseSettings
|
|
10
|
+
from unity_buildkit.ci_step import ci_step
|
|
11
|
+
|
|
12
|
+
from .config import load_config
|
|
13
|
+
|
|
14
|
+
app = typer.Typer(add_completion=False, pretty_exceptions_show_locals=False)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class Settings(BaseSettings):
|
|
18
|
+
github_sha: str
|
|
19
|
+
github_repository: str
|
|
20
|
+
github_output: str | None = None
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@app.command()
|
|
24
|
+
def main(
|
|
25
|
+
config: Annotated[Path, typer.Option(help="Publish configuration JSON")],
|
|
26
|
+
ci_run_id: Annotated[str | None, typer.Option(help="Override CI run lookup with a known run ID")] = None,
|
|
27
|
+
) -> None:
|
|
28
|
+
settings = Settings.model_validate({})
|
|
29
|
+
publish_config = load_config(config)
|
|
30
|
+
repo = settings.github_repository
|
|
31
|
+
|
|
32
|
+
if ci_run_id:
|
|
33
|
+
run_id = ci_run_id
|
|
34
|
+
print(f" Using override CI run: {run_id}")
|
|
35
|
+
else:
|
|
36
|
+
sha = bash_output(f'gh api "/repos/{repo}/git/commits/{settings.github_sha}" --jq ".parents[1].sha"').strip()
|
|
37
|
+
|
|
38
|
+
with ci_step("Find successful CI run"):
|
|
39
|
+
run_id = bash_output(
|
|
40
|
+
f'gh api "/repos/{repo}/actions/workflows/{publish_config.ci_workflow}/runs'
|
|
41
|
+
f'?head_sha={sha}&status=success" --jq ".workflow_runs[0].id // empty"'
|
|
42
|
+
).strip()
|
|
43
|
+
|
|
44
|
+
if not run_id:
|
|
45
|
+
print(f"::error::No successful CI run found for SHA {sha}. Cannot release untested code.")
|
|
46
|
+
raise typer.Exit(code=1)
|
|
47
|
+
|
|
48
|
+
print(f" CI run: {run_id}")
|
|
49
|
+
|
|
50
|
+
if settings.github_output:
|
|
51
|
+
with Path(settings.github_output).open("a", encoding="utf-8") as file:
|
|
52
|
+
file.write(f"run_id={run_id}\n")
|
|
53
|
+
|
|
54
|
+
artifact_dir = publish_config.artifact_dir
|
|
55
|
+
with ci_step("Download artifacts"):
|
|
56
|
+
bash(f"gh run download {run_id} --repo {repo} --dir {artifact_dir}")
|
|
57
|
+
|
|
58
|
+
if not artifact_dir.is_dir():
|
|
59
|
+
print(" No artifacts downloaded")
|
|
60
|
+
return
|
|
61
|
+
|
|
62
|
+
downloaded = 0
|
|
63
|
+
for entry in sorted(artifact_dir.iterdir()):
|
|
64
|
+
if not entry.is_dir():
|
|
65
|
+
continue
|
|
66
|
+
if any(entry.name.startswith(p) for p in publish_config.artifact_skip_prefixes) or any(
|
|
67
|
+
entry.name.endswith(s) for s in publish_config.artifact_skip_suffixes
|
|
68
|
+
):
|
|
69
|
+
print(f" Removed: {entry.name}")
|
|
70
|
+
rmtree(entry)
|
|
71
|
+
continue
|
|
72
|
+
downloaded += 1
|
|
73
|
+
print(f" Kept: {entry.name}")
|
|
74
|
+
|
|
75
|
+
print(f" {downloaded} artifact(s) ready in {artifact_dir}")
|
release_kit/ledger.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
from bashrun import bash, bash_check, bash_output
|
|
5
|
+
|
|
6
|
+
# Prerelease-suffixed tags (e.g. 1.0.6-preview) are not stable-ledger versions: the stable flow
|
|
7
|
+
# must never compute a next version from one. Dev-channel versions never enter the tag space.
|
|
8
|
+
STABLE_VERSION_PATTERN = re.compile(r"^\d+\.\d+\.\d+$")
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def is_stable_version(version: str) -> bool:
|
|
12
|
+
return STABLE_VERSION_PATTERN.fullmatch(version) is not None
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class GitLedger:
|
|
16
|
+
def latest_version(self, prefix: str) -> str | None:
|
|
17
|
+
output = bash_output(f'git tag --list "{prefix}*" --sort=-v:refname').strip()
|
|
18
|
+
if not output:
|
|
19
|
+
return None
|
|
20
|
+
for tag in output.splitlines():
|
|
21
|
+
version = tag[len(prefix) :]
|
|
22
|
+
if is_stable_version(version):
|
|
23
|
+
return version
|
|
24
|
+
return None
|
|
25
|
+
|
|
26
|
+
def has_changes_since(self, tag: str | None, path: Path) -> bool:
|
|
27
|
+
if tag is None:
|
|
28
|
+
return True
|
|
29
|
+
return not bash_check(f"git diff --quiet {tag} HEAD -- {path}")
|
|
30
|
+
|
|
31
|
+
def create_and_push_tag(self, tag: str) -> None:
|
|
32
|
+
bash(f"git tag {tag}")
|
|
33
|
+
bash(f"git push origin {tag}")
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from typing import Annotated
|
|
6
|
+
|
|
7
|
+
import typer
|
|
8
|
+
from bashrun import bash
|
|
9
|
+
from stack_toolkit.image_refs import collect_repo_references
|
|
10
|
+
from unity_buildkit.ci_step import ci_step
|
|
11
|
+
|
|
12
|
+
from .config import load_config
|
|
13
|
+
|
|
14
|
+
app = typer.Typer(add_completion=False, pretty_exceptions_show_locals=False)
|
|
15
|
+
|
|
16
|
+
CRANE_VERSION = "v0.22.1"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
@app.command()
|
|
20
|
+
def main(config: Annotated[Path, typer.Option(help="Publish configuration JSON")]) -> None:
|
|
21
|
+
publish_config = load_config(config)
|
|
22
|
+
mirror_prefix = publish_config.mirror_prefix
|
|
23
|
+
targets = {
|
|
24
|
+
occurrence.reference: occurrence.reference[len(mirror_prefix) + 1 :]
|
|
25
|
+
for occurrence in collect_repo_references(Path.cwd(), dockerfile_glob=None)
|
|
26
|
+
if occurrence.reference.startswith(f"{mirror_prefix}/")
|
|
27
|
+
}
|
|
28
|
+
with ci_step("Install crane"):
|
|
29
|
+
sudo = "sudo " if os.geteuid() != 0 else ""
|
|
30
|
+
archive = "go-containerregistry_Linux_x86_64.tar.gz"
|
|
31
|
+
bash(f"curl -fsSLO https://github.com/google/go-containerregistry/releases/download/{CRANE_VERSION}/{archive}")
|
|
32
|
+
bash(f"{sudo}tar -xzf {archive} -C /usr/local/bin crane")
|
|
33
|
+
Path(archive).unlink()
|
|
34
|
+
for mirrored, upstream in sorted(targets.items()):
|
|
35
|
+
with ci_step(f"Mirror {upstream} -> {mirrored}"):
|
|
36
|
+
bash(f"crane copy {upstream} {mirrored}")
|
|
37
|
+
print(f"Mirrored images: {len(targets)}")
|
release_kit/plan.py
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from typing import Protocol
|
|
4
|
+
|
|
5
|
+
from .config import PackageConfig
|
|
6
|
+
from .feeds import DEV_VERSION_FORMATS
|
|
7
|
+
|
|
8
|
+
FIRST_VERSION = "0.1.0"
|
|
9
|
+
UNCHANGED_FALLBACK_VERSION = "0.0.0"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class TagLedger(Protocol):
|
|
13
|
+
def latest_version(self, prefix: str) -> str | None: ...
|
|
14
|
+
|
|
15
|
+
def has_changes_since(self, tag: str | None, path: Path) -> bool: ...
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@dataclass(frozen=True)
|
|
19
|
+
class PackagePlan:
|
|
20
|
+
name: str
|
|
21
|
+
publish: bool
|
|
22
|
+
version: str
|
|
23
|
+
last_version: str | None
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def next_version(last_version: str | None) -> str:
|
|
27
|
+
if last_version is None:
|
|
28
|
+
return FIRST_VERSION
|
|
29
|
+
major, minor, patch = last_version.split(".")
|
|
30
|
+
return f"{major}.{minor}.{int(patch) + 1}"
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def compute_plan(packages: list[PackageConfig], ledger: TagLedger) -> dict[str, PackagePlan]:
|
|
34
|
+
plans: dict[str, PackagePlan] = {}
|
|
35
|
+
for package in packages:
|
|
36
|
+
last_version = ledger.latest_version(f"{package.name}-v")
|
|
37
|
+
changed = ledger.has_changes_since(f"{package.name}-v{last_version}" if last_version else None, package.path)
|
|
38
|
+
if any(plans[dependency].publish for dependency in package.depends_on):
|
|
39
|
+
changed = True
|
|
40
|
+
plans[package.name] = PackagePlan(
|
|
41
|
+
name=package.name,
|
|
42
|
+
publish=changed,
|
|
43
|
+
version=next_version(last_version) if changed else (last_version or UNCHANGED_FALLBACK_VERSION),
|
|
44
|
+
last_version=last_version,
|
|
45
|
+
)
|
|
46
|
+
return plans
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def resolved_dependency_versions(package: PackageConfig, plans: dict[str, PackagePlan]) -> dict[str, str]:
|
|
50
|
+
return {
|
|
51
|
+
dependency_name: plans[pinned_package].version
|
|
52
|
+
for dependency_name, pinned_package in package.dependency_pins.items()
|
|
53
|
+
if plans[pinned_package].publish
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def render_summary(plans: dict[str, PackagePlan]) -> str:
|
|
58
|
+
lines = [
|
|
59
|
+
"### Publish Plan",
|
|
60
|
+
"| Package | Publish | Version |",
|
|
61
|
+
"|---|---|---|",
|
|
62
|
+
]
|
|
63
|
+
lines.extend(f"| {plan.name} | {plan.publish} | {plan.version} |" for plan in plans.values())
|
|
64
|
+
return "\n".join(lines)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def render_dev_summary(packages: list[PackageConfig], plans: dict[str, PackagePlan], run_id: str) -> str:
|
|
68
|
+
lines = [
|
|
69
|
+
"### Dev Publish Plan",
|
|
70
|
+
"| Package | Publish | Versions |",
|
|
71
|
+
"|---|---|---|",
|
|
72
|
+
]
|
|
73
|
+
for package in packages:
|
|
74
|
+
plan = plans[package.name]
|
|
75
|
+
if not plan.publish:
|
|
76
|
+
lines.append(f"| {plan.name} | False | - |")
|
|
77
|
+
continue
|
|
78
|
+
versions = ", ".join(
|
|
79
|
+
f"{feed_name}: {identity} @ {DEV_VERSION_FORMATS[feed_name](plan.version, run_id)}"
|
|
80
|
+
for feed_name, identity in package.feeds.items()
|
|
81
|
+
)
|
|
82
|
+
lines.append(f"| {plan.name} | True | {versions} |")
|
|
83
|
+
return "\n".join(lines)
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from typing import Annotated
|
|
5
|
+
|
|
6
|
+
import typer
|
|
7
|
+
from pydantic_settings import BaseSettings
|
|
8
|
+
from unity_buildkit.ci_step import ci_step
|
|
9
|
+
from unity_buildkit.setup import configure_git, free_disk_space, install_dotnet, install_node
|
|
10
|
+
|
|
11
|
+
from .config import load_config, select_packages
|
|
12
|
+
from .feeds import DEV_VERSION_FORMATS, NPM_DEV_DIST_TAG, PublishRequest, build_feeds
|
|
13
|
+
from .ledger import GitLedger
|
|
14
|
+
from .plan import compute_plan, render_dev_summary, resolved_dependency_versions
|
|
15
|
+
|
|
16
|
+
app = typer.Typer(add_completion=False, pretty_exceptions_show_locals=False)
|
|
17
|
+
|
|
18
|
+
DEFAULT_CONFIG_PATH = Path("build/publish-config.json")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class Settings(BaseSettings):
|
|
22
|
+
github_workspace: str = ""
|
|
23
|
+
github_step_summary: str | None = None
|
|
24
|
+
github_run_id: str = ""
|
|
25
|
+
nuget_api_key: str = ""
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _write_summary(path: str | None, text: str) -> None:
|
|
29
|
+
if path:
|
|
30
|
+
with Path(path).open("a", encoding="utf-8") as file:
|
|
31
|
+
file.write(text + "\n")
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@app.command()
|
|
35
|
+
def main(
|
|
36
|
+
config: Annotated[Path, typer.Option(help="Publish configuration JSON")] = DEFAULT_CONFIG_PATH,
|
|
37
|
+
dry_run: Annotated[bool, typer.Option(help="Plan publishes without executing them")] = False,
|
|
38
|
+
run_id: Annotated[
|
|
39
|
+
str, typer.Option(help="CI run id baked into every dev version (defaults to GITHUB_RUN_ID)")
|
|
40
|
+
] = "",
|
|
41
|
+
only: Annotated[list[str] | None, typer.Option(help="Restrict to named packages (repeatable).")] = None,
|
|
42
|
+
exclude: Annotated[list[str] | None, typer.Option(help="Skip named packages (repeatable).")] = None,
|
|
43
|
+
) -> None:
|
|
44
|
+
settings = Settings.model_validate({})
|
|
45
|
+
resolved_run_id = run_id or settings.github_run_id
|
|
46
|
+
if not resolved_run_id.isdigit():
|
|
47
|
+
raise SystemExit("dev run id must be all digits: pass --run-id or set GITHUB_RUN_ID")
|
|
48
|
+
|
|
49
|
+
publish_config = load_config(config)
|
|
50
|
+
packages = select_packages(publish_config.packages, only or [], exclude or [])
|
|
51
|
+
ledger = GitLedger()
|
|
52
|
+
|
|
53
|
+
with ci_step("Compute dev publish plan"):
|
|
54
|
+
plans = compute_plan(publish_config.packages, ledger)
|
|
55
|
+
|
|
56
|
+
summary = render_dev_summary(packages, plans, resolved_run_id)
|
|
57
|
+
print(summary)
|
|
58
|
+
_write_summary(settings.github_step_summary, summary)
|
|
59
|
+
|
|
60
|
+
if not any(plan.publish for plan in plans.values()):
|
|
61
|
+
print("Nothing to publish")
|
|
62
|
+
return
|
|
63
|
+
|
|
64
|
+
if dry_run:
|
|
65
|
+
print("Dry run — skipping publish")
|
|
66
|
+
return
|
|
67
|
+
|
|
68
|
+
with ci_step("Setup"):
|
|
69
|
+
configure_git(settings.github_workspace)
|
|
70
|
+
free_disk_space()
|
|
71
|
+
install_dotnet("8.0")
|
|
72
|
+
install_node("24", "https://registry.npmjs.org")
|
|
73
|
+
|
|
74
|
+
feeds = build_feeds(settings.nuget_api_key)
|
|
75
|
+
published: list[tuple[str, str, str]] = []
|
|
76
|
+
for package in packages:
|
|
77
|
+
plan = plans[package.name]
|
|
78
|
+
if not plan.publish:
|
|
79
|
+
continue
|
|
80
|
+
dependency_versions = resolved_dependency_versions(package, plans)
|
|
81
|
+
for feed_name, identity in package.feeds.items():
|
|
82
|
+
dev_version = DEV_VERSION_FORMATS[feed_name](plan.version, resolved_run_id)
|
|
83
|
+
with ci_step(f"Publish {feed_name} ({package.name}) {dev_version}"):
|
|
84
|
+
feeds[feed_name].publish(
|
|
85
|
+
PublishRequest(
|
|
86
|
+
path=package.path,
|
|
87
|
+
identity=identity,
|
|
88
|
+
version=dev_version,
|
|
89
|
+
dependency_versions={
|
|
90
|
+
dependency_name: DEV_VERSION_FORMATS[feed_name](version, resolved_run_id)
|
|
91
|
+
for dependency_name, version in dependency_versions.items()
|
|
92
|
+
},
|
|
93
|
+
dist_tag=NPM_DEV_DIST_TAG if feed_name == "npm" else None,
|
|
94
|
+
)
|
|
95
|
+
)
|
|
96
|
+
published.append((feed_name, identity, dev_version))
|
|
97
|
+
|
|
98
|
+
recap = "\n".join([
|
|
99
|
+
"### Published dev versions",
|
|
100
|
+
*(f"{feed_name}: {identity} @ {version}" for feed_name, identity, version in published),
|
|
101
|
+
])
|
|
102
|
+
print(recap)
|
|
103
|
+
print("Consume these by exact version pin - there is no discovery tooling by design")
|
|
104
|
+
_write_summary(settings.github_step_summary, recap)
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from typing import Annotated
|
|
5
|
+
|
|
6
|
+
import typer
|
|
7
|
+
from pydantic_settings import BaseSettings
|
|
8
|
+
from unity_buildkit.ci_step import ci_step
|
|
9
|
+
from unity_buildkit.setup import configure_git, free_disk_space, install_dotnet, install_node
|
|
10
|
+
|
|
11
|
+
from .config import load_config, select_packages
|
|
12
|
+
from .feeds import PublishRequest, build_feeds
|
|
13
|
+
from .ledger import GitLedger
|
|
14
|
+
from .plan import compute_plan, next_version, render_summary, resolved_dependency_versions
|
|
15
|
+
|
|
16
|
+
app = typer.Typer(add_completion=False, pretty_exceptions_show_locals=False)
|
|
17
|
+
|
|
18
|
+
DEFAULT_CONFIG_PATH = Path("build/publish-config.json")
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class Settings(BaseSettings):
|
|
22
|
+
github_workspace: str = ""
|
|
23
|
+
github_step_summary: str | None = None
|
|
24
|
+
github_output: str | None = None
|
|
25
|
+
nuget_api_key: str = ""
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _append_output(path: str | None, line: str) -> None:
|
|
29
|
+
if path:
|
|
30
|
+
with Path(path).open("a", encoding="utf-8") as file:
|
|
31
|
+
file.write(line + "\n")
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
@app.command()
|
|
35
|
+
def main(
|
|
36
|
+
config: Annotated[Path, typer.Option(help="Publish configuration JSON")] = DEFAULT_CONFIG_PATH,
|
|
37
|
+
dry_run: Annotated[bool, typer.Option(help="Plan publishes without executing them")] = False,
|
|
38
|
+
only: Annotated[list[str] | None, typer.Option(help="Restrict to named packages (repeatable).")] = None,
|
|
39
|
+
exclude: Annotated[list[str] | None, typer.Option(help="Skip named packages (repeatable).")] = None,
|
|
40
|
+
with_apps: Annotated[bool, typer.Option(help="Handle app version bumps and tags in a filtered run.")] = False,
|
|
41
|
+
) -> None:
|
|
42
|
+
settings = Settings.model_validate({})
|
|
43
|
+
publish_config = load_config(config)
|
|
44
|
+
packages = select_packages(publish_config.packages, only or [], exclude or [])
|
|
45
|
+
ledger = GitLedger()
|
|
46
|
+
|
|
47
|
+
with ci_step("Compute publish plan"):
|
|
48
|
+
plans = compute_plan(publish_config.packages, ledger)
|
|
49
|
+
|
|
50
|
+
summary = render_summary(plans)
|
|
51
|
+
print(summary)
|
|
52
|
+
_append_output(settings.github_step_summary, summary)
|
|
53
|
+
|
|
54
|
+
if not any(plan.publish for plan in plans.values()):
|
|
55
|
+
print("Nothing to publish")
|
|
56
|
+
return
|
|
57
|
+
|
|
58
|
+
if dry_run:
|
|
59
|
+
print("Dry run — skipping publish")
|
|
60
|
+
return
|
|
61
|
+
|
|
62
|
+
with ci_step("Setup"):
|
|
63
|
+
configure_git(settings.github_workspace)
|
|
64
|
+
free_disk_space()
|
|
65
|
+
install_dotnet("8.0")
|
|
66
|
+
install_node("24", "https://registry.npmjs.org")
|
|
67
|
+
|
|
68
|
+
feeds = build_feeds(settings.nuget_api_key)
|
|
69
|
+
for package in packages:
|
|
70
|
+
plan = plans[package.name]
|
|
71
|
+
if not plan.publish:
|
|
72
|
+
continue
|
|
73
|
+
dependency_versions = resolved_dependency_versions(package, plans)
|
|
74
|
+
for feed_name, identity in package.feeds.items():
|
|
75
|
+
with ci_step(f"Publish {feed_name} ({package.name})"):
|
|
76
|
+
feeds[feed_name].publish(
|
|
77
|
+
PublishRequest(
|
|
78
|
+
path=package.path,
|
|
79
|
+
identity=identity,
|
|
80
|
+
version=plan.version,
|
|
81
|
+
dependency_versions=dependency_versions,
|
|
82
|
+
)
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
handle_apps = (not only and not exclude) or with_apps
|
|
86
|
+
any_package_published = any(plans[package.name].publish for package in packages)
|
|
87
|
+
app_versions: dict[str, str] = {}
|
|
88
|
+
with ci_step("Compute app versions"):
|
|
89
|
+
for app_config in publish_config.apps:
|
|
90
|
+
last_version = ledger.latest_version(f"{app_config.tag_prefix}-v")
|
|
91
|
+
changed = ledger.has_changes_since(
|
|
92
|
+
f"{app_config.tag_prefix}-v{last_version}" if last_version else None, app_config.path
|
|
93
|
+
)
|
|
94
|
+
# Apps depend on packages — bump if any package changed
|
|
95
|
+
if any_package_published:
|
|
96
|
+
changed = True
|
|
97
|
+
if changed:
|
|
98
|
+
new_version = next_version(last_version)
|
|
99
|
+
app_versions[app_config.name] = new_version
|
|
100
|
+
print(f" {app_config.name}: {last_version or '(none)'} -> {new_version}")
|
|
101
|
+
else:
|
|
102
|
+
print(f" {app_config.name}: {last_version or '0.0.0'} (unchanged)")
|
|
103
|
+
|
|
104
|
+
with ci_step("Create version tags"):
|
|
105
|
+
for package in packages:
|
|
106
|
+
plan = plans[package.name]
|
|
107
|
+
if plan.publish:
|
|
108
|
+
tag = f"{package.name}-v{plan.version}"
|
|
109
|
+
ledger.create_and_push_tag(tag)
|
|
110
|
+
print(f" Tagged: {tag}")
|
|
111
|
+
|
|
112
|
+
if handle_apps:
|
|
113
|
+
for app_config in publish_config.apps:
|
|
114
|
+
if app_config.name in app_versions:
|
|
115
|
+
tag = f"{app_config.tag_prefix}-v{app_versions[app_config.name]}"
|
|
116
|
+
ledger.create_and_push_tag(tag)
|
|
117
|
+
print(f" Tagged: {tag}")
|
|
118
|
+
|
|
119
|
+
_append_output(settings.github_output, "published=true")
|
release_kit/py.typed
ADDED
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: release-kit
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Publication machinery: per-package tag ledger, path-diff change detection, ephemeral version patching, and per-registry feed adapters (nuget, npm/UPM) driven by a declarative consumer-owned config
|
|
5
|
+
License-File: LICENSE
|
|
6
|
+
License-File: NOTICE
|
|
7
|
+
Requires-Python: >=3.13
|
|
8
|
+
Requires-Dist: bashrun>=0.1.0
|
|
9
|
+
Requires-Dist: pydantic-settings>=2.9.1
|
|
10
|
+
Requires-Dist: pydantic>=2.11.7
|
|
11
|
+
Requires-Dist: stack-toolkit>=0.1.0
|
|
12
|
+
Requires-Dist: typer>=0.17.4
|
|
13
|
+
Requires-Dist: unity-buildkit>=0.1.0
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
release_kit/__init__.py,sha256=CDbeGa-o3YqUEqygWePVp3WZYK53FmAsLshF6gs3PT4,831
|
|
2
|
+
release_kit/config.py,sha256=ZLP1A2iIrM6sfRpyIxst93LIJljL577fAiD-jjPRzK0,3167
|
|
3
|
+
release_kit/create_release.py,sha256=fAJyJGxz7zkaAejCOjWwZCfRtVPc9KkDl5aPdnzjd-E,5912
|
|
4
|
+
release_kit/ensure_release_pr.py,sha256=Pqs06fHsA26Rji-IZxfFA-2JqQrAetFRR2tgKkTvBxI,703
|
|
5
|
+
release_kit/feeds.py,sha256=O41agvb3M-19TfMvoGATJPQJ58S2Nd1jD6UTtWBZXCs,4405
|
|
6
|
+
release_kit/fetch_ci_artifacts.py,sha256=_5fkK1jEfhM1NWgt--0ZpcVAj0aQkmOUn2riAwxWAgg,2569
|
|
7
|
+
release_kit/ledger.py,sha256=wnmBgLOUVHN1T0kxAeCpCruJSr_Kr2QaqOOMtDcS8YU,1144
|
|
8
|
+
release_kit/mirror_images.py,sha256=NXNL9y9lgAIAD7X16WmQu0HuA65UtbAwCl7vCl851XA,1405
|
|
9
|
+
release_kit/plan.py,sha256=N6x3w2hnDJrNUoBiTIbVktpjXj9H2EenQVyxv5lepj4,2743
|
|
10
|
+
release_kit/publish_dev.py,sha256=5Ok1vRvzke2_Qpm9-2hFdTpDCz4Bj7UtVD2ZRNNU4vc,4132
|
|
11
|
+
release_kit/publish_packages.py,sha256=BRfqezhksaqNyEbgAm4PuYqb0yLXhoJBmim9TMc4YHo,4699
|
|
12
|
+
release_kit/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
|
+
release_kit-0.1.0.dist-info/METADATA,sha256=biZyPUbTqmHjwbe4Ys0wShHMC44yqzjHUdUqoJ8w6KY,532
|
|
14
|
+
release_kit-0.1.0.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
|
|
15
|
+
release_kit-0.1.0.dist-info/entry_points.txt,sha256=LSXNcSGT1G-q92fefhezjG3zSa0ufUOGQy4oRys5Ajk,316
|
|
16
|
+
release_kit-0.1.0.dist-info/licenses/LICENSE,sha256=RFhQPdSOiMTguUX7JSoIuTxA7HVzCbj_p8WU36HjUQQ,10947
|
|
17
|
+
release_kit-0.1.0.dist-info/licenses/NOTICE,sha256=jvglZza3GCdN7v4_TLuXUqX9C_uABlwAKUkcIeKwk_8,26
|
|
18
|
+
release_kit-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
[console_scripts]
|
|
2
|
+
create-release = release_kit.create_release:app
|
|
3
|
+
ensure-release-pr = release_kit.ensure_release_pr:app
|
|
4
|
+
fetch-ci-artifacts = release_kit.fetch_ci_artifacts:app
|
|
5
|
+
mirror-images = release_kit.mirror_images:app
|
|
6
|
+
publish-dev = release_kit.publish_dev:app
|
|
7
|
+
publish-packages = release_kit.publish_packages:app
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Copyright 2026 Tyler Hatch
|