mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-27 23:47:39 +01:00
ci: improve speed by caching brew install step and reading project settings from dumped xcodebuild -showProjectSettings instead of invoking each time.
This commit is contained in:
17
.github/workflows/alpha.yml
vendored
17
.github/workflows/alpha.yml
vendored
@@ -23,7 +23,17 @@ jobs:
|
||||
submodules: recursive
|
||||
fetch-depth: 0
|
||||
|
||||
- run: brew install ldid xcbeautify
|
||||
- uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
/opt/homebrew/Cellar
|
||||
/opt/homebrew/Homebrew
|
||||
/opt/homebrew/Library
|
||||
~/Library/Caches/Homebrew
|
||||
key: brew-${{ runner.os }}-ldid-xcbeautify-v1
|
||||
- run: |
|
||||
brew list ldid >/dev/null 2>&1 || brew install ldid
|
||||
brew list xcbeautify >/dev/null 2>&1 || brew install xcbeautify
|
||||
|
||||
# --------------------------------------------------
|
||||
# runtime env setup
|
||||
@@ -176,8 +186,9 @@ jobs:
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
PRODUCT_NAME=$(python3 scripts/ci/workflow.py get-product-name)
|
||||
BUNDLE_ID=$(python3 scripts/ci/workflow.py get-bundle-id)
|
||||
python3 scripts/ci/workflow.py dump-project-settings
|
||||
PRODUCT_NAME=$(python3 scripts/ci/workflow.py read-product-name)
|
||||
BUNDLE_ID=$(python3 scripts/ci/workflow.py read-bundle-id)
|
||||
SOURCE_JSON="_includes/source.json"
|
||||
IPA_NAME="$PRODUCT_NAME.ipa"
|
||||
|
||||
|
||||
18
.github/workflows/nightly.yml
vendored
18
.github/workflows/nightly.yml
vendored
@@ -25,7 +25,18 @@ jobs:
|
||||
submodules: recursive
|
||||
fetch-depth: 0
|
||||
|
||||
- run: brew install ldid xcbeautify
|
||||
- uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
/opt/homebrew/Cellar
|
||||
/opt/homebrew/Homebrew
|
||||
/opt/homebrew/Library
|
||||
~/Library/Caches/Homebrew
|
||||
key: brew-${{ runner.os }}-ldid-xcbeautify-v1
|
||||
|
||||
- run: |
|
||||
brew list ldid >/dev/null 2>&1 || brew install ldid
|
||||
brew list xcbeautify >/dev/null 2>&1 || brew install xcbeautify
|
||||
|
||||
# --------------------------------------------------
|
||||
# runtime env setup
|
||||
@@ -178,8 +189,9 @@ jobs:
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
PRODUCT_NAME=$(python3 scripts/ci/workflow.py get-product-name)
|
||||
BUNDLE_ID=$(python3 scripts/ci/workflow.py get-bundle-id)
|
||||
python3 scripts/ci/workflow.py dump-project-settings
|
||||
PRODUCT_NAME=$(python3 scripts/ci/workflow.py read-product-name)
|
||||
BUNDLE_ID=$(python3 scripts/ci/workflow.py read-bundle-id)
|
||||
SOURCE_JSON="_includes/source.json"
|
||||
IPA_NAME="$PRODUCT_NAME.ipa"
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import json
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
import argparse
|
||||
import textwrap
|
||||
import sys
|
||||
|
||||
SCRIPT_DIR = Path(__file__).resolve().parent
|
||||
|
||||
@@ -6,12 +6,12 @@ import datetime
|
||||
from pathlib import Path
|
||||
import time
|
||||
import json
|
||||
import inspect
|
||||
import re
|
||||
|
||||
# REPO ROOT relative to script dir
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
SCRIPTS = ROOT / 'scripts/ci'
|
||||
BUILD_SETTINGS_OUTFILE = "project-build-settings.txt"
|
||||
|
||||
# ----------------------------------------------------------
|
||||
# helpers
|
||||
@@ -127,23 +127,35 @@ def reserve_build_number(repo, max_attempts=5):
|
||||
# ----------------------------------------------------------
|
||||
# PROJECT INFO
|
||||
# ----------------------------------------------------------
|
||||
def dump_project_settings(outdir=None):
|
||||
outfile = Path(outdir).resolve() / BUILD_SETTINGS_OUTFILE if outdir else BUILD_SETTINGS_OUTFILE
|
||||
run(f"xcodebuild -showBuildSettings 2>&1 > '{outfile}'")
|
||||
|
||||
def get_product_name():
|
||||
return runAndGet(
|
||||
"xcodebuild -showBuildSettings "
|
||||
"| grep PRODUCT_NAME "
|
||||
def _extract_setting(cmd):
|
||||
out = runAndGet(cmd + " || true").strip() # prevent grep failure from aborting
|
||||
return out if out else None
|
||||
|
||||
def _read_dumped_build_setting(name):
|
||||
return _extract_setting(
|
||||
f"cat '{BUILD_SETTINGS_OUTFILE}' "
|
||||
f"| grep '{name} = ' "
|
||||
"| tail -1 "
|
||||
"| sed -e 's/.*= //g'"
|
||||
)
|
||||
|
||||
def get_bundle_id():
|
||||
return runAndGet(
|
||||
"xcodebuild -showBuildSettings 2>&1 "
|
||||
"| grep 'PRODUCT_BUNDLE_IDENTIFIER = ' "
|
||||
def query_build_setting(name):
|
||||
return _extract_setting(
|
||||
f"xcodebuild -showBuildSettings 2>&1 "
|
||||
f"| grep '{name} = ' "
|
||||
"| tail -1 "
|
||||
"| sed -e 's/.*= //g'"
|
||||
)
|
||||
|
||||
def get_product_name(): return query_build_setting("PRODUCT_NAME")
|
||||
def get_bundle_id(): return query_build_setting("PRODUCT_BUNDLE_IDENTIFIER")
|
||||
def read_product_name(): return _read_dumped_build_setting("PRODUCT_NAME")
|
||||
def read_bundle_id(): return _read_dumped_build_setting("PRODUCT_BUNDLE_IDENTIFIER")
|
||||
|
||||
def get_marketing_version():
|
||||
return runAndGet(f"grep MARKETING_VERSION {ROOT}/Build.xcconfig | sed -e 's/MARKETING_VERSION = //g'")
|
||||
|
||||
@@ -462,6 +474,9 @@ COMMANDS = {
|
||||
"reserve_build_number" : (reserve_build_number, 1, "<repo>"),
|
||||
"get-product-name" : (get_product_name, 0, ""),
|
||||
"get-bundle-id" : (get_bundle_id, 0, ""),
|
||||
"dump-project-settings" : (dump_project_settings, 0, ""),
|
||||
"read-product-name" : (read_product_name, 0, ""),
|
||||
"read-bundle-id" : (read_bundle_id, 0, ""),
|
||||
|
||||
# ----------------------------------------------------------
|
||||
# CLEAN
|
||||
|
||||
Reference in New Issue
Block a user