Compare commits

..

3 Commits

Author SHA1 Message Date
mahee96
85ff9b09ca ci: more fixes 2026-02-24 10:23:31 +05:30
mahee96
4100e8b1b9 ci: more fixes 2026-02-24 10:10:22 +05:30
mahee96
42fae569ca ci: more fixes 2026-02-24 10:04:22 +05:30

View File

@@ -60,6 +60,7 @@ def short_commit():
# ---------------------------------------------------------- # ----------------------------------------------------------
# BUILD NUMBER RESERVATION # BUILD NUMBER RESERVATION
# ---------------------------------------------------------- # ----------------------------------------------------------
def reserve_build_number(repo, max_attempts=5): def reserve_build_number(repo, max_attempts=5):
repo = Path(repo).resolve() repo = Path(repo).resolve()
version_json = repo / "version.json" version_json = repo / "version.json"
@@ -67,14 +68,9 @@ def reserve_build_number(repo, max_attempts=5):
def utc_now(): def utc_now():
return datetime.datetime.now(datetime.UTC).strftime("%Y-%m-%dT%H:%M:%SZ") return datetime.datetime.now(datetime.UTC).strftime("%Y-%m-%dT%H:%M:%SZ")
def current_branch(): def read():
return runAndGet("git rev-parse --abbrev-ref HEAD", cwd=repo) branch = runAndGet("git rev-parse --abbrev-ref HEAD", cwd=repo)
def sync_with_remote(branch):
run(f"git fetch --depth=1 origin {branch}", check=False, cwd=repo)
run(f"git reset --hard origin/{branch}", check=False, cwd=repo)
def read(branch):
defaults = { defaults = {
"build": 0, "build": 0,
"issued_at": utc_now(), "issued_at": utc_now(),
@@ -86,10 +82,13 @@ def reserve_build_number(repo, max_attempts=5):
else: else:
data = {} data = {}
# fill missing fields
for k, v in defaults.items(): for k, v in defaults.items():
data.setdefault(k, v) data.setdefault(k, v)
# ensure tag always tracks current branch
data["tag"] = branch data["tag"] = branch
version_json.write_text(json.dumps(data, indent=2) + "\n") version_json.write_text(json.dumps(data, indent=2) + "\n")
return data return data
@@ -97,23 +96,19 @@ def reserve_build_number(repo, max_attempts=5):
version_json.write_text(json.dumps(data, indent=2) + "\n") version_json.write_text(json.dumps(data, indent=2) + "\n")
for attempt in range(max_attempts): for attempt in range(max_attempts):
branch = current_branch() run("git fetch --depth=1 origin HEAD", check=False, cwd=repo)
sync_with_remote(branch) run("git reset --hard FETCH_HEAD", check=False, cwd=repo)
data = read(branch) data = read()
data["build"] += 1 data["build"] += 1
data["issued_at"] = utc_now() data["issued_at"] = utc_now()
write(data) write(data)
run("git add version.json", check=False, cwd=repo) run("git add version.json", check=False, cwd=repo)
run( run(f"git commit -m '{data['tag']} - build no: {data['build']}' || true", check=False, cwd=repo)
f"git commit -m '{branch} - build no: {data['build']}' || true",
check=False,
cwd=repo,
)
rc = subprocess.call(f"git push origin {branch}", shell=True, cwd=repo) rc = subprocess.call("git push", shell=True, cwd=repo)
if rc == 0: if rc == 0:
print(f"Reserved build #{data['build']}", file=sys.stderr) print(f"Reserved build #{data['build']}", file=sys.stderr)
@@ -438,7 +433,7 @@ def upload_release(release_name, release_tag, commit_sha, repo, upstream_recomme
run( run(
f'gh release upload "{release_tag}" ' f'gh release upload "{release_tag}" '
f'SideStore.ipa SideStore.dSYMs.zip encrypted-build-logs.zip ' f'SideStore.ipa SideStore.dSYMs.zip encrypted-build-logs.zip'
f'--clobber' f'--clobber'
) )
@@ -533,5 +528,6 @@ def main():
sys.stdout.write(str(result)) sys.stdout.write(str(result))
sys.stdout.flush() sys.stdout.flush()
if __name__ == "__main__": if __name__ == "__main__":
main() main()