diff --git a/.github/workflows/alpha.yml b/.github/workflows/alpha.yml index 76cc8fe5..f034fe14 100644 --- a/.github/workflows/alpha.yml +++ b/.github/workflows/alpha.yml @@ -36,17 +36,9 @@ jobs: # -------------------------------------------------- # runtime env setup # -------------------------------------------------- - - uses: actions/checkout@v4 - with: - repository: "SideStore/beta-build-num" - ref: ${{ env.CHANNEL }} - token: ${{ secrets.CROSS_REPO_PUSH_KEY }} - path: "Dependencies/beta-build-num" - fetch-depth: 1 - - name: Setup Env run: | - BUILD_NUM=$(python3 scripts/ci/workflow.py reserve_build_number 'Dependencies/beta-build-num') + BUILD_NUM="${{ github.run_number }}" MARKETING_VERSION=$(python3 scripts/ci/workflow.py get-marketing-version) SHORT_COMMIT=$(python3 scripts/ci/workflow.py commit-id) @@ -180,6 +172,9 @@ jobs: path: SideStore.dSYMs.zip - uses: actions/checkout@v4 + if: > + steps.build_gate.outputs.should_skip != 'true' && + secrets.CROSS_REPO_PUSH_KEY != '' with: repository: "SideStore/apps-v2.json" ref: "main" @@ -190,6 +185,9 @@ jobs: # deploy # -------------------------------------------------- - name: Deploy + if: > + steps.build_gate.outputs.should_skip != 'true' && + secrets.CROSS_REPO_PUSH_KEY != '' env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | @@ -198,7 +196,7 @@ jobs: BUNDLE_ID=$(python3 scripts/ci/workflow.py read-bundle-id) SOURCE_JSON="_includes/source.json" IPA_NAME="$PRODUCT_NAME.ipa" - + python3 scripts/ci/workflow.py deploy \ SideStore/apps-v2.json \ "$SOURCE_JSON" \ @@ -210,8 +208,13 @@ jobs: "$IPA_NAME" \ "$LAST_SUCCESSFUL_COMMIT" - RELEASE_NOTES=$(python3 scripts/ci/workflow.py retrieve-release-notes "$CHANNEL") - + # -------------------------------------------------- + # upload release + # -------------------------------------------------- + - name: Upload Release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | python3 scripts/ci/workflow.py upload-release \ "$RELEASE_NAME" \ "$CHANNEL" \ diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 89dc7263..ad39d225 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -58,19 +58,10 @@ jobs: # -------------------------------------------------- # runtime env setup # -------------------------------------------------- - - uses: actions/checkout@v4 - if: steps.build_gate.outputs.should_skip != 'true' - with: - repository: "SideStore/beta-build-num" - ref: ${{ env.CHANNEL }} - token: ${{ secrets.CROSS_REPO_PUSH_KEY }} - path: "Dependencies/beta-build-num" - fetch-depth: 1 - - name: Setup Env if: steps.build_gate.outputs.should_skip != 'true' run: | - BUILD_NUM=$(python3 scripts/ci/workflow.py reserve_build_number 'Dependencies/beta-build-num') + BUILD_NUM="${{ github.run_number }}" MARKETING_VERSION=$(python3 scripts/ci/workflow.py get-marketing-version) SHORT_COMMIT=$(python3 scripts/ci/workflow.py commit-id) @@ -219,7 +210,9 @@ jobs: path: SideStore.dSYMs.zip - uses: actions/checkout@v4 - if: steps.build_gate.outputs.should_skip != 'true' + if: > + steps.build_gate.outputs.should_skip != 'true' && + secrets.CROSS_REPO_PUSH_KEY != '' with: repository: "SideStore/apps-v2.json" ref: "main" @@ -230,7 +223,7 @@ jobs: # deploy # -------------------------------------------------- - name: Deploy - if: steps.build_gate.outputs.should_skip != 'true' + if: steps.build_gate.outputs.should_skip != 'true' && secrets.CROSS_REPO_PUSH_KEY != '' env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | @@ -239,7 +232,7 @@ jobs: BUNDLE_ID=$(python3 scripts/ci/workflow.py read-bundle-id) SOURCE_JSON="_includes/source.json" IPA_NAME="$PRODUCT_NAME.ipa" - + python3 scripts/ci/workflow.py deploy \ SideStore/apps-v2.json \ "$SOURCE_JSON" \ @@ -251,8 +244,14 @@ jobs: "$IPA_NAME" \ "$LAST_SUCCESSFUL_COMMIT" - RELEASE_NOTES=$(python3 scripts/ci/workflow.py retrieve-release-notes "$CHANNEL") - + # -------------------------------------------------- + # upload release + # -------------------------------------------------- + - name: Upload Release + if: steps.build_gate.outputs.should_skip != 'true' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | python3 scripts/ci/workflow.py upload-release \ "$RELEASE_NAME" \ "$CHANNEL" \ diff --git a/scripts/ci/workflow.py b/scripts/ci/workflow.py index f7bfaf2a..43191f14 100644 --- a/scripts/ci/workflow.py +++ b/scripts/ci/workflow.py @@ -72,73 +72,6 @@ def count_new_commits(last_commit): except Exception: return 0 -# ---------------------------------------------------------- -# BUILD NUMBER RESERVATION -# ---------------------------------------------------------- -def reserve_build_number(repo, max_attempts=5): - repo = Path(repo).resolve() - version_json = repo / "version.json" - - def utc_now(): - return datetime.datetime.now(datetime.UTC).strftime("%Y-%m-%dT%H:%M:%SZ") - - def current_branch(): - return 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 = { - "build": 0, - "issued_at": utc_now(), - "tag": branch, - } - - if version_json.exists(): - data = json.loads(version_json.read_text()) - else: - data = {} - - for k, v in defaults.items(): - data.setdefault(k, v) - - data["tag"] = branch - version_json.write_text(json.dumps(data, indent=2) + "\n") - return data - - def write(data): - version_json.write_text(json.dumps(data, indent=2) + "\n") - - for attempt in range(max_attempts): - branch = current_branch() - sync_with_remote(branch) - - data = read(branch) - data["build"] += 1 - data["issued_at"] = utc_now() - - write(data) - - run("git add version.json", check=False, cwd=repo) - run( - 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) - - if rc == 0: - print(f"Reserved build #{data['build']}", file=sys.stderr) - return data["build"] - - print("Push rejected, retrying...", file=sys.stderr) - time.sleep(2) - - raise SystemExit("Failed reserving build number") - # ---------------------------------------------------------- # PROJECT INFO # ---------------------------------------------------------- @@ -520,8 +453,7 @@ COMMANDS = { # ---------------------------------------------------------- "get-marketing-version" : (get_marketing_version, 0, ""), "set-marketing-version" : (set_marketing_version, 1, ""), - "compute-normalized" : (compute_normalized_version, 3, " "), - "reserve_build_number" : (reserve_build_number, 1, ""), + "compute-normalized" : (compute_normalized_version,3, " "), "get-product-name" : (get_product_name, 0, ""), "get-bundle-id" : (get_bundle_id, 0, ""), "dump-project-settings" : (dump_project_settings, 0, ""),