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
|
submodules: recursive
|
||||||
fetch-depth: 0
|
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
|
# runtime env setup
|
||||||
@@ -176,8 +186,9 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
PRODUCT_NAME=$(python3 scripts/ci/workflow.py get-product-name)
|
python3 scripts/ci/workflow.py dump-project-settings
|
||||||
BUNDLE_ID=$(python3 scripts/ci/workflow.py get-bundle-id)
|
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"
|
SOURCE_JSON="_includes/source.json"
|
||||||
IPA_NAME="$PRODUCT_NAME.ipa"
|
IPA_NAME="$PRODUCT_NAME.ipa"
|
||||||
|
|
||||||
|
|||||||
18
.github/workflows/nightly.yml
vendored
18
.github/workflows/nightly.yml
vendored
@@ -25,7 +25,18 @@ jobs:
|
|||||||
submodules: recursive
|
submodules: recursive
|
||||||
fetch-depth: 0
|
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
|
# runtime env setup
|
||||||
@@ -178,8 +189,9 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
PRODUCT_NAME=$(python3 scripts/ci/workflow.py get-product-name)
|
python3 scripts/ci/workflow.py dump-project-settings
|
||||||
BUNDLE_ID=$(python3 scripts/ci/workflow.py get-bundle-id)
|
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"
|
SOURCE_JSON="_includes/source.json"
|
||||||
IPA_NAME="$PRODUCT_NAME.ipa"
|
IPA_NAME="$PRODUCT_NAME.ipa"
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import json
|
|||||||
import subprocess
|
import subprocess
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import argparse
|
import argparse
|
||||||
import textwrap
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
SCRIPT_DIR = Path(__file__).resolve().parent
|
SCRIPT_DIR = Path(__file__).resolve().parent
|
||||||
|
|||||||
@@ -6,12 +6,12 @@ import datetime
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import time
|
import time
|
||||||
import json
|
import json
|
||||||
import inspect
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
# REPO ROOT relative to script dir
|
# REPO ROOT relative to script dir
|
||||||
ROOT = Path(__file__).resolve().parents[2]
|
ROOT = Path(__file__).resolve().parents[2]
|
||||||
SCRIPTS = ROOT / 'scripts/ci'
|
SCRIPTS = ROOT / 'scripts/ci'
|
||||||
|
BUILD_SETTINGS_OUTFILE = "project-build-settings.txt"
|
||||||
|
|
||||||
# ----------------------------------------------------------
|
# ----------------------------------------------------------
|
||||||
# helpers
|
# helpers
|
||||||
@@ -127,23 +127,35 @@ def reserve_build_number(repo, max_attempts=5):
|
|||||||
# ----------------------------------------------------------
|
# ----------------------------------------------------------
|
||||||
# PROJECT INFO
|
# 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():
|
def _extract_setting(cmd):
|
||||||
return runAndGet(
|
out = runAndGet(cmd + " || true").strip() # prevent grep failure from aborting
|
||||||
"xcodebuild -showBuildSettings "
|
return out if out else None
|
||||||
"| grep PRODUCT_NAME "
|
|
||||||
|
def _read_dumped_build_setting(name):
|
||||||
|
return _extract_setting(
|
||||||
|
f"cat '{BUILD_SETTINGS_OUTFILE}' "
|
||||||
|
f"| grep '{name} = ' "
|
||||||
"| tail -1 "
|
"| tail -1 "
|
||||||
"| sed -e 's/.*= //g'"
|
"| sed -e 's/.*= //g'"
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_bundle_id():
|
def query_build_setting(name):
|
||||||
return runAndGet(
|
return _extract_setting(
|
||||||
"xcodebuild -showBuildSettings 2>&1 "
|
f"xcodebuild -showBuildSettings 2>&1 "
|
||||||
"| grep 'PRODUCT_BUNDLE_IDENTIFIER = ' "
|
f"| grep '{name} = ' "
|
||||||
"| tail -1 "
|
"| tail -1 "
|
||||||
"| sed -e 's/.*= //g'"
|
"| 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():
|
def get_marketing_version():
|
||||||
return runAndGet(f"grep MARKETING_VERSION {ROOT}/Build.xcconfig | sed -e 's/MARKETING_VERSION = //g'")
|
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>"),
|
"reserve_build_number" : (reserve_build_number, 1, "<repo>"),
|
||||||
"get-product-name" : (get_product_name, 0, ""),
|
"get-product-name" : (get_product_name, 0, ""),
|
||||||
"get-bundle-id" : (get_bundle_id, 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
|
# CLEAN
|
||||||
|
|||||||
Reference in New Issue
Block a user