mirror of
https://github.com/Shu-Ying/main_plugin_farm.git
synced 2026-10-30 14:20:01 +08:00
fixed # 修复工作流BUG
This commit is contained in:
@@ -24,10 +24,16 @@ def source_identity(root):
|
||||
}
|
||||
|
||||
|
||||
def build(root, output, version):
|
||||
def read_version(root):
|
||||
version = (Path(root) / "version.txt").read_text(encoding="utf-8").strip()
|
||||
if not re.fullmatch(r"[0-9]+\.[0-9]+\.[0-9]+(?:-[a-z0-9.-]+)?", version):
|
||||
raise ValueError("Invalid preview version")
|
||||
raise ValueError("Invalid version in root version.txt file")
|
||||
return version
|
||||
|
||||
|
||||
def build(root, output):
|
||||
root, output = Path(root).resolve(), Path(output).resolve()
|
||||
version = read_version(root)
|
||||
if output.exists():
|
||||
raise FileExistsError("Use a new output directory")
|
||||
if not output.is_relative_to(root / "dist") and output.is_relative_to(root):
|
||||
@@ -63,6 +69,7 @@ def build(root, output, version):
|
||||
for name, source in {
|
||||
"LICENSE": root / "LICENSE",
|
||||
"README.md": root / "docs/11-zhenxun-preview.md",
|
||||
"version.txt": root / "version.txt",
|
||||
"images/farm-preview.png": root / "images/farm-preview.png",
|
||||
"verify_package.py": root / "scripts/verify_zhenxun.py",
|
||||
".github/workflows/verify.yml": root / "release/zhenxun/verify.yml",
|
||||
@@ -107,10 +114,9 @@ def build(root, output, version):
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--output", type=Path, required=True)
|
||||
parser.add_argument("--version", default="0.1.0-preview.1")
|
||||
args = parser.parse_args()
|
||||
root = Path(__file__).resolve().parents[1]
|
||||
print(build(root, args.output, args.version))
|
||||
print(build(root, args.output))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -25,6 +25,8 @@ def main():
|
||||
if set(trigger) != {"push", "pull_request", "workflow_dispatch"}:
|
||||
raise ValueError("Unsafe or missing workflow trigger")
|
||||
inputs = trigger["workflow_dispatch"]["inputs"]
|
||||
if set(inputs) != {"publish"}:
|
||||
raise ValueError("Version must come from the root version.txt file")
|
||||
if inputs["publish"]["default"] != "false":
|
||||
raise ValueError("Publish must be opt-in")
|
||||
sync = source["jobs"]["sync-preview"]
|
||||
@@ -35,7 +37,7 @@ def main():
|
||||
raise ValueError("Publish boundary differs")
|
||||
if generated["permissions"] != {"contents":"read"}:
|
||||
raise ValueError("Generated workflow permissions differ")
|
||||
if generated["on"]["push"]["branches"] != ["farm-preview"]:
|
||||
if generated["on"]["push"]["branches"] != ["main"]:
|
||||
raise ValueError("Generated branch differs")
|
||||
print("Workflow YAML and publication guards checked")
|
||||
|
||||
|
||||
@@ -55,8 +55,6 @@ def publish(package, confirmed=False, request=None):
|
||||
repository = call("GET", "", None)
|
||||
if not repository:
|
||||
raise ValueError(f"Target repository is not accessible: {REPOSITORY}")
|
||||
if repository.get("default_branch") == BRANCH:
|
||||
raise ValueError("Preview must not be the repository default branch")
|
||||
ref = call("GET", f"git/ref/heads/{BRANCH}", None)
|
||||
parent = ref["object"]["sha"] if ref else None
|
||||
if parent:
|
||||
|
||||
Reference in New Issue
Block a user