CI: multiple fixes

This commit is contained in:
mahee96
2026-02-25 07:33:55 +05:30
parent 555bb3d985
commit 118f64de8a
6 changed files with 59 additions and 39 deletions

View File

@@ -28,7 +28,7 @@ jobs:
- name: Find Last Successful commit
run: |
LAST_SUCCESSFUL_COMMIT=$(python3 scripts/ci/workflow.py last-successful-commit \
"${{ github.workflow }}" "${{ env.CHANNEL }}" || echo "")
"false" "${{ env.CHANNEL }}" || echo "")
echo "LAST_SUCCESSFUL_COMMIT=$LAST_SUCCESSFUL_COMMIT" | tee -a $GITHUB_ENV
- run: brew install ldid xcbeautify

View File

@@ -30,7 +30,7 @@ jobs:
- name: Find Last Successful commit
run: |
LAST_SUCCESSFUL_COMMIT=$(python3 scripts/ci/workflow.py last-successful-commit \
"${{ github.workflow }}" "${{ env.CHANNEL }}" || echo "")
"false" "${{ env.CHANNEL }}" || echo "")
echo "LAST_SUCCESSFUL_COMMIT=$LAST_SUCCESSFUL_COMMIT" | tee -a $GITHUB_ENV
- name: Check for new changes (on schedule)

View File

@@ -17,7 +17,6 @@ jobs:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_NAME: Stable
CHANNEL: stable
UPSTREAM_CHANNEL: ""
@@ -27,6 +26,12 @@ jobs:
submodules: recursive
fetch-depth: 0
- name: Find Last Successful commit
run: |
LAST_SUCCESSFUL_COMMIT=$(python3 scripts/ci/workflow.py last-successful-commit \
"true" || echo "")
echo "LAST_SUCCESSFUL_COMMIT=$LAST_SUCCESSFUL_COMMIT" | tee -a $GITHUB_ENV
- run: brew install ldid xcbeautify
- name: Setup Env
@@ -68,9 +73,6 @@ jobs:
~/Library/Caches/org.swift.swiftpm
key: xcode-build-cache-stable-
- name: Clean
run: python3 scripts/ci/workflow.py clean
- name: Build
id: build
env:
@@ -112,7 +114,7 @@ jobs:
IPA_NAME="$PRODUCT_NAME.ipa"
python3 scripts/ci/workflow.py generate-metadata \
"$CHANNEL" \
"${{ github.ref_name }}" \
"$SHORT_COMMIT" \
"$MARKETING_VERSION" \
"$CHANNEL" \
@@ -125,7 +127,7 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
python3 scripts/ci/workflow.py upload-release \
"$RELEASE_NAME" \
"${{ github.ref_name }}" \
"${{ github.ref_name }}" \
"$GITHUB_SHA" \
"$GITHUB_REPOSITORY" \

View File

@@ -137,12 +137,20 @@ def generate_release_notes(last_successful, tag, branch):
url = repo_url()
section += (
f"\n{HEADER_MARKER} Full Changelog: "
f"[{last_successful[:8]}...{current[:8]}]"
f"[{ref_display(last_successful)}...{ref_display(current)}]"
f"({url}/compare/{last_successful}...{current})\n"
)
return section
def ref_display(ref):
try:
tag = run(f'git describe --tags --exact-match "{ref}" 2>/dev/null || true')
if tag:
return tag
except Exception:
pass
return ref[:8]
# ----------------------------------------------------------
# markdown update

View File

@@ -107,13 +107,13 @@ def main():
gen_cmd = (
f"python3 {script} "
f"{args.last_successful_commit} {args.release_tag} "
f"--output-dir \"{notes_dir}\""
f'--output-dir "{notes_dir}"'
)
else:
gen_cmd = (
f"python3 {script} "
f"{args.short_commit} {args.release_tag} "
f"--output-dir \"{notes_dir}\""
f'--output-dir "{notes_dir}"'
)
sh(gen_cmd, cwd=repo_root)

View File

@@ -318,21 +318,32 @@ def deploy(repo, source_json, release_tag, marketing_version):
raise SystemExit("Deploy push failed after retries")
def last_successful_commit(workflow, branch):
import json
def last_successful_commit(is_stable, tag=None):
is_stable = str(is_stable).lower() in ("1", "true", "yes")
try:
out = runAndGet(
f'gh run list '
f'--workflow "{workflow}" '
f'--json headSha,conclusion,headBranch'
)
if is_stable:
prev_tag = runAndGet(
r'git tag --sort=-v:refname '
r'| grep -E "^[0-9]+\.[0-9]+\.[0-9]+$" '
r'| sed -n "2p" || true'
).strip()
runs = json.loads(out)
if prev_tag:
return runAndGet(f'git rev-parse "{prev_tag}^{{commit}}"')
for r in runs:
if r.get("conclusion") == "success" and r.get("headBranch") == branch:
return r["headSha"]
return None # ← changed
if tag:
exists = subprocess.call(
f'git rev-parse -q --verify "refs/tags/{tag}"',
shell=True,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
) == 0
if exists:
return runAndGet(f'git rev-parse "{tag}^{{commit}}"')
except Exception:
pass
@@ -341,15 +352,13 @@ def last_successful_commit(workflow, branch):
def upload_release(release_name, release_tag, commit_sha, repo, upstream_tag_recommended, is_stable=False):
is_stable = str(is_stable).lower() in ("1", "true", "yes")
draft = False
prerelease = True
latest = False
if is_stable:
draft = True # always create a draft for stable and let user publish release
update_tag = False
prerelease = False
else:
draft = False
update_tag = True # update existing
prerelease = True
latest = True
token = getenv("GH_TOKEN")
if token:
@@ -377,12 +386,13 @@ def upload_release(release_name, release_tag, commit_sha, repo, upstream_tag_rec
f"--output-dir {ROOT}"
)
release_notes = re.sub(
r'^\s*#{1,6}\s*what(?:\'?s|\s+is)?\s+(?:new|changed).*',
"## What's Changed",
release_notes,
flags=re.IGNORECASE | re.MULTILINE,
)
if is_stable:
release_notes = re.sub(
r'(?im)^[ \t]*#{1,6}[ \t]*what[\']?s[ \t]+changed[ \t]*$',
"## What's Changed",
release_notes,
flags=re.IGNORECASE | re.MULTILINE,
)
upstream_block = ""
if upstream_tag_recommended and upstream_tag_recommended.strip():
@@ -405,7 +415,7 @@ def upload_release(release_name, release_tag, commit_sha, repo, upstream_tag_rec
draft_flag = "--draft" if draft else ""
prerelease_flag = "--prerelease" if prerelease else ""
latest_flag = "" if update_tag else "--latest=false"
latest_flag = "--latest=true" if latest else ""
# create release if it doesn't exist
exists = subprocess.call(
@@ -514,7 +524,7 @@ COMMANDS = {
# ----------------------------------------------------------
# RELEASE / DEPLOY
# ----------------------------------------------------------
"last-successful-commit" : (last_successful_commit, 2, "<workflow_name> <branch>"),
"last-successful-commit" : (last_successful_commit, 1, "<is_stable> [tag]"),
"release-notes" : (release_notes, 1, "<tag>"),
"retrieve-release-notes" : (retrieve_release_notes, 1, "<tag>"),
"generate-metadata" : (generate_metadata, 7,
@@ -548,9 +558,9 @@ def main():
suffix = f" {arg_usage}" if arg_usage else ""
raise SystemExit(f"Usage: workflow.py {cmd}{suffix}")
args = sys.argv[2:2 + argc]
args = sys.argv[2:]
result = func(*args) if argc else func()
result = func(*args) if args else func()
# ONLY real outputs go to stdout
if result is not None: