Add XZ cache #30
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
push: | |
branches: ['main'] | |
pull_request: | |
branches: ['main'] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
fetch: | |
name: Fetch | |
runs-on: ubuntu-latest | |
outputs: | |
xz: ${{ fromJson(steps.ver.outputs.result).xz }} | |
steps: | |
- name: Get version information | |
id: ver | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const { data: ffi } = await github.rest.repos.getLatestRelease({ | |
owner: "libffi", | |
repo: "libffi", | |
}) | |
const { data: xz } = await github.rest.repos.getLatestRelease({ | |
owner: "tukaani-project", | |
repo: "xz", | |
}) | |
return { ffi: ffi.tag_name.slice(1), xz: xz.tag_name.slice(1) } | |
build: | |
name: Build | |
needs: fetch | |
runs-on: macos-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ['3.13-dev'] | |
build: | |
- target: 'iphoneos.arm64' | |
sdk: 'iphoneos' | |
arch: 'arm64' | |
host: 'arm64-apple-ios' | |
- target: 'iphonesimulator.arm64' | |
sdk: 'iphonesimulator' | |
arch: 'arm64' | |
host: 'arm64-apple-ios-simulator' | |
- target: 'iphonesimulator.x86_64' | |
sdk: 'iphonesimulator' | |
arch: 'x86_64' | |
host: 'x86_64-apple-ios-simulator' | |
steps: | |
- name: Checkout ${{ github.repository }} | |
uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
id: py | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
check-latest: true | |
- name: Set version information | |
id: pyver | |
run: | | |
echo "py=$(python -V | cut -wf 2)" >> $GITHUB_OUTPUT | |
- name: Download bzip2 | |
run: | | |
curl -O https://www.sourceware.org/pub/bzip2/bzip2-latest.tar.gz | |
tar -xzf bzip2-latest.tar.gz | |
- name: Cache XZ Utils | |
id: cache-xz | |
uses: actions/cache@v4 | |
with: | |
path: ${{ github.workspace }}/install/xz | |
key: xz-${{ matrix.build.sdk }}-${{ matrix.build.arch }} | |
- name: Download XZ Utils | |
if: ${{ steps.cache-xz.outputs.cache-hit != 'true' }} | |
run: | | |
gh release download v${{ needs.fetch.outputs.xz }} -R tukaani-project/xz -p xz-${{ needs.fetch.outputs.xz }}.tar.gz | |
tar -xzf xz-${{ needs.fetch.outputs.xz }}.tar.gz | |
env: | |
GH_TOKEN: ${{ github.token }} | |
- name: Configure XZ Utils Build | |
if: ${{ steps.cache-xz.outputs.cache-hit != 'true' }} | |
working-directory: xz-${{ needs.fetch.outputs.xz }} | |
run: > | |
./configure | |
CC="xcrun --sdk ${{ matrix.build.sdk }} clang -target ${{ matrix.build.host }}" | |
CFLAGS="--sysroot=$(xcrun --sdk ${{ matrix.build.sdk }} --show-sdk-path) -mios-version-min=13.0" | |
--disable-shared | |
--enable-static | |
--host=${{ matrix.build.host }} | |
--build=arm64-apple-darwin | |
--prefix="${{ github.workspace }}/install/xz" | |
- name: Build XZ Utils | |
if: ${{ steps.cache-xz.outputs.cache-hit != 'true' }} | |
working-directory: xz-${{ needs.fetch.outputs.xz }} | |
run: | | |
make | |
make install | |
- name: Clone python/cpython ${{ matrix.python-version }} | |
run: > | |
gh repo clone python/cpython | |
-- -b v${{ steps.pyver.outputs.py }} --depth=1 | |
env: | |
GH_TOKEN: ${{ github.token }} | |
- name: Add iOS/Resources/bin to PATH | |
working-directory: cpython | |
run: echo "$(pwd)/iOS/Resources/bin" >> $GITHUB_PATH | |
- name: Configure | |
working-directory: cpython | |
run: > | |
./configure | |
LIBLZMA_CFLAGS="-I${{ github.workspace }}/install/xz/include" | |
LIBLZMA_LIBS="-L${{ github.workspace }}/install/xz/lib -llzma" | |
--enable-framework="./iOS/Frameworks/main/" | |
--host=${{ matrix.build.host }} | |
--build=arm64-apple-darwin | |
--with-build-python="${{ steps.py.outputs.python-path }}" | |
- name: Build Python.framework | |
working-directory: cpython | |
run: | | |
make | |
make install | |
- name: Create an archive | |
working-directory: cpython | |
run: > | |
tar -czf | |
./iOS/Frameworks/dist/Python.framework.tar.gz | |
./iOS/Frameworks/dist/Python.framework |