From bce38c874324ef3d46827f81f804afd69a8ff4ed Mon Sep 17 00:00:00 2001 From: mahee96 <47920326+mahee96@users.noreply.github.com> Date: Tue, 24 Feb 2026 07:41:06 +0530 Subject: [PATCH] CI: improve more ci worflow --- .github/workflows/alpha.yml | 10 ++++++-- .github/workflows/nightly.yml | 10 ++++++-- scripts/ci/workflow.py | 47 +++++++++-------------------------- 3 files changed, 28 insertions(+), 39 deletions(-) diff --git a/.github/workflows/alpha.yml b/.github/workflows/alpha.yml index c7fbaa0e..f72d2ac3 100644 --- a/.github/workflows/alpha.yml +++ b/.github/workflows/alpha.yml @@ -161,13 +161,19 @@ jobs: name: SideStore-${{ env.VERSION }}-dSYMs.zip path: SideStore.dSYMs.zip + - uses: actions/checkout@v4 + with: + repository: 'SideStore/apps-v2.json' + ref: 'main' + token: ${{ secrets.CROSS_REPO_PUSH_KEY }} + path: 'SideStore/apps-v2.json' + # -------------------------------------------------- # deploy # -------------------------------------------------- - name: Deploy env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - CROSS_REPO_PUSH_KEY: ${{ secrets.CROSS_REPO_PUSH_KEY }} run: | PRODUCT_NAME=$(python3 scripts/ci/workflow.py get-product-name) BUNDLE_ID=$(python3 scripts/ci/workflow.py get-bundle-id) @@ -178,7 +184,7 @@ jobs: "${{ github.workflow }}" "$CHANNEL") python3 scripts/ci/workflow.py deploy \ - Dependencies/apps-v2.json \ + SideStore/apps-v2.json \ "$SOURCE_JSON" \ "$REF_NAME" \ "$SHORT_COMMIT" \ diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index b12763b5..fc237fa6 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -163,13 +163,19 @@ jobs: name: SideStore-${{ env.VERSION }}-dSYMs.zip path: SideStore.dSYMs.zip + - uses: actions/checkout@v4 + with: + repository: 'SideStore/apps-v2.json' + ref: 'main' + token: ${{ secrets.CROSS_REPO_PUSH_KEY }} + path: 'SideStore/apps-v2.json' + # -------------------------------------------------- # deploy # -------------------------------------------------- - name: Deploy env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - CROSS_REPO_PUSH_KEY: ${{ secrets.CROSS_REPO_PUSH_KEY }} run: | PRODUCT_NAME=$(python3 scripts/ci/workflow.py get-product-name) BUNDLE_ID=$(python3 scripts/ci/workflow.py get-bundle-id) @@ -180,7 +186,7 @@ jobs: "${{ github.workflow }}" "$CHANNEL") python3 scripts/ci/workflow.py deploy \ - Dependencies/apps-v2.json \ + SideStore/apps-v2.json \ "$SOURCE_JSON" \ "$REF_NAME" \ "$SHORT_COMMIT" \ diff --git a/scripts/ci/workflow.py b/scripts/ci/workflow.py index 9ebebe5e..f1203eb3 100644 --- a/scripts/ci/workflow.py +++ b/scripts/ci/workflow.py @@ -276,6 +276,7 @@ def retrieve_release_notes(tag): # ---------------------------------------------------------- # DEPLOY SOURCE.JSON # ---------------------------------------------------------- + def deploy(repo, source_json, release_tag, short_commit, marketing_version, version, channel, bundle_id, ipa_name, last_successful_commit=None): repo = (ROOT / repo).resolve() ipa_path = ROOT / ipa_name @@ -306,54 +307,33 @@ def deploy(repo, source_json, release_tag, short_commit, marketing_version, vers f"--bundle-id {bundle_id}" ) + # pass only if provided if last_successful_commit: cmd += f" --last-successful-commit {last_successful_commit}" run(cmd) - run("git config user.name 'GitHub Actions'", check=False, cwd=repo) - run("git config user.email 'github-actions@github.com'", check=False, cwd=repo) + run("git config user.name 'GitHub Actions'", check=False) + run("git config user.email 'github-actions@github.com'", check=False) # ------------------------------------------------------ - # attach to real branch (avoid detached HEAD) - # ------------------------------------------------------ - run("git fetch origin", check=False, cwd=repo) - run("git checkout -B main origin/main", cwd=repo) - - # ------------------------------------------------------ - # attach push credentials (equivalent to checkout@v4 token) - # ------------------------------------------------------ - token = getenv("CROSS_REPO_PUSH_KEY") or getenv("GH_TOKEN") - - if not token: - raise SystemExit("Missing push token for apps-v2.json push") - - run( - f'git remote set-url origin ' - f'https://x-access-token:{token}@github.com/SideStore/apps-v2.json.git', - cwd=repo - ) - - # ------------------------------------------------------ - # push loop + run("git fetch origin main", check=False, cwd=repo) + run("git switch main || git switch -c main origin/main", cwd=repo) + run("git reset --hard origin/main", cwd=repo) # ------------------------------------------------------ + max_attempts = 5 for attempt in range(1, max_attempts + 1): if attempt > 1: - run("git fetch origin main", check=False, cwd=repo) - run("git reset --hard origin/main", check=False, cwd=repo) + run("git fetch --depth=1 origin HEAD", check=False, cwd=repo) + run("git reset --hard FETCH_HEAD", check=False, cwd=repo) # regenerate after reset so we don't lose changes - run( - f"python3 {SCRIPTS}/update_source_metadata.py " - f"'{ROOT}/{metadata}' '{source_json_path}'", - cwd=repo - ) - + run(f"python3 {SCRIPTS}/update_source_metadata.py '{ROOT}/{metadata}' '{source_json_path}'", cwd=repo) run(f"git add --verbose {source_json}", cwd=repo) run(f"git commit -m '{release_tag} - deployed {version}' || true", cwd=repo) - rc = subprocess.call("git push origin main", shell=True, cwd=repo) + rc = subprocess.call("git push", shell=True, cwd=repo) if rc == 0: print("Deploy push succeeded", file=sys.stderr) @@ -364,9 +344,6 @@ def deploy(repo, source_json, release_tag, short_commit, marketing_version, vers else: raise SystemExit("Deploy push failed after retries") - - - def last_successful_commit(workflow, branch): import json