Add artifact upload #46
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: | |
ios: '13.0' | |
ffi: ${{ fromJson(steps.ver.outputs.result).ffi }} | |
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-bz2: | |
name: Build bzip2 | |
needs: fetch | |
runs-on: macos-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
build: | |
- target: 'iphoneos.arm64' | |
sdk: 'iphoneos' | |
arch: 'arm64' | |
host: 'arm64-apple-ios${{ needs.fetch.outputs.ios }}' | |
- target: 'iphonesimulator.arm64' | |
sdk: 'iphonesimulator' | |
arch: 'arm64' | |
host: 'arm64-apple-ios${{ needs.fetch.outputs.ios }}-simulator' | |
- target: 'iphonesimulator.x86_64' | |
sdk: 'iphonesimulator' | |
arch: 'x86_64' | |
host: 'x86_64-apple-ios${{ needs.fetch.outputs.ios }}-simulator' | |
steps: | |
- name: Checkout ${{ github.repository }} | |
uses: actions/checkout@v4 | |
- name: Cache bzip2 | |
id: cache | |
uses: actions/cache@v4 | |
with: | |
path: ${{ github.workspace }}/install/bz2 | |
key: bz2-${{ matrix.build.sdk }}-${{ matrix.build.arch }} | |
- name: Download bzip2 source | |
if: ${{ steps.cache.outputs.cache-hit != 'true' }} | |
run: | | |
curl -O https://www.sourceware.org/pub/bzip2/bzip2-latest.tar.gz | |
mkdir -p ./bzip2 | |
tar -xzf bzip2-latest.tar.gz -C ./bzip2 --strip-components 1 | |
- name: Build bzip2 | |
if: ${{ steps.cache.outputs.cache-hit != 'true' }} | |
working-directory: bzip2 | |
run: > | |
make install | |
PREFIX="${{ github.workspace }}/install/bz2" | |
CC="xcrun --sdk ${{ matrix.build.sdk }} clang -target ${{ matrix.build.host }}" | |
CFLAGS="--sysroot=$(xcrun --sdk ${{ matrix.build.sdk }} --show-sdk-path) -mios-version-min=${{ needs.fetch.outputs.ios }}" | |
LDFLAGS="-isysroot $(xcrun --sdk ${{ matrix.build.sdk }} --show-sdk-path) -mios-version-min=${{ needs.fetch.outputs.ios }}" | |
- name: Upload the bzip2 artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: bz2-${{ matrix.build.sdk }}-${{ matrix.build.arch }} | |
path: ${{ github.workspace }}/install/bz2 | |
if-no-files-found: error | |
retention-days: 1 | |
build-ffi: | |
name: Build libffi | |
needs: fetch | |
runs-on: macos-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
build: | |
- target: 'iphoneos.arm64' | |
sdk: 'iphoneos' | |
arch: 'arm64' | |
host: 'arm64-apple-ios${{ needs.fetch.outputs.ios }}' | |
- target: 'iphonesimulator.arm64' | |
sdk: 'iphonesimulator' | |
arch: 'arm64' | |
host: 'arm64-apple-ios${{ needs.fetch.outputs.ios }}-simulator' | |
- target: 'iphonesimulator.x86_64' | |
sdk: 'iphonesimulator' | |
arch: 'x86_64' | |
host: 'x86_64-apple-ios${{ needs.fetch.outputs.ios }}-simulator' | |
steps: | |
- name: Checkout ${{ github.repository }} | |
uses: actions/checkout@v4 | |
- name: Cache bzip2 | |
id: cache | |
uses: actions/cache@v4 | |
with: | |
path: ${{ github.workspace }}/install/ffi | |
key: ffi-${{ matrix.build.sdk }}-${{ matrix.build.arch }} | |
- name: Download libffi source | |
if: ${{ steps.cache.outputs.cache-hit != 'true' }} | |
run: > | |
gh release | |
-R libffi/libffi | |
download v${{ needs.fetch.outputs.ffi }} | |
-p libffi-${{ needs.fetch.outputs.ffi }}.tar.gz | |
env: | |
GH_TOKEN: ${{ github.token }} | |
- name: Extract libffi tarball | |
if: ${{ steps.cache.outputs.cache-hit != 'true' }} | |
run: tar -xzf libffi-${{ needs.fetch.outputs.ffi }}.tar.gz | |
- name: Configure libffi build | |
if: ${{ steps.cache.outputs.cache-hit != 'true' }} | |
working-directory: libffi-${{ needs.fetch.outputs.ffi }} | |
run: > | |
./configure | |
--prefix="${{ github.workspace }}/install/ffi" | |
--host=${{ matrix.build.host }} | |
CC="xcrun --sdk ${{ matrix.build.sdk }} clang -target ${{ matrix.build.host }}" | |
CFLAGS="--sysroot=$(xcrun --sdk ${{ matrix.build.sdk }} --show-sdk-path) -mios-version-min=${{ needs.fetch.outputs.ios }}" | |
LDFLAGS="-isysroot $(xcrun --sdk ${{ matrix.build.sdk }} --show-sdk-path) -mios-version-min=${{ needs.fetch.outputs.ios }}" | |
- name: Build libffi | |
if: ${{ steps.cache.outputs.cache-hit != 'true' }} | |
working-directory: libffi-${{ needs.fetch.outputs.ffi }} | |
run: | | |
make | |
make install | |
- name: Upload the libffi artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ffi-${{ matrix.build.sdk }}-${{ matrix.build.arch }} | |
path: ${{ github.workspace }}/install/ffi | |
if-no-files-found: error | |
retention-days: 1 | |
build-xz: | |
name: Build XZ Utils | |
needs: fetch | |
runs-on: macos-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
build: | |
- target: 'iphoneos.arm64' | |
sdk: 'iphoneos' | |
arch: 'arm64' | |
host: 'arm64-apple-ios${{ needs.fetch.outputs.ios }}' | |
- target: 'iphonesimulator.arm64' | |
sdk: 'iphonesimulator' | |
arch: 'arm64' | |
host: 'arm64-apple-ios${{ needs.fetch.outputs.ios }}-simulator' | |
- target: 'iphonesimulator.x86_64' | |
sdk: 'iphonesimulator' | |
arch: 'x86_64' | |
host: 'x86_64-apple-ios${{ needs.fetch.outputs.ios }}-simulator' | |
steps: | |
- name: Checkout ${{ github.repository }} | |
uses: actions/checkout@v4 | |
- name: Cache XZ Utils | |
id: cache | |
uses: actions/cache@v4 | |
with: | |
path: ${{ github.workspace }}/install/xz | |
key: xz-${{ matrix.build.sdk }}-${{ matrix.build.arch }} | |
- name: Download XZ Utils source | |
if: ${{ steps.cache.outputs.cache-hit != 'true' }} | |
run: > | |
gh release | |
-R tukaani-project/xz | |
download v${{ needs.fetch.outputs.xz }} | |
-p xz-${{ needs.fetch.outputs.xz }}.tar.gz | |
env: | |
GH_TOKEN: ${{ github.token }} | |
- name: Extract XZ Utils tarball | |
if: ${{ steps.cache.outputs.cache-hit != 'true' }} | |
run: tar -xzf xz-${{ needs.fetch.outputs.xz }}.tar.gz | |
- name: Apply patch | |
if: ${{ steps.cache.outputs.cache-hit != 'true' }} | |
working-directory: xz-${{ needs.fetch.outputs.xz }} | |
run: | | |
patch -u ./build-aux/config.sub ${{ github.workspace }}/patch/xz.patch | |
- name: Configure XZ Utils build | |
if: ${{ steps.cache.outputs.cache-hit != 'true' }} | |
working-directory: xz-${{ needs.fetch.outputs.xz }} | |
run: > | |
./configure | |
--prefix="${{ github.workspace }}/install/xz" | |
--host=${{ matrix.build.host }} | |
--disable-shared | |
--enable-static | |
CC="xcrun --sdk ${{ matrix.build.sdk }} clang -target ${{ matrix.build.host }}" | |
CFLAGS="--sysroot=$(xcrun --sdk ${{ matrix.build.sdk }} --show-sdk-path) -mios-version-min=${{ needs.fetch.outputs.ios }}" | |
LDFLAGS="-isysroot $(xcrun --sdk ${{ matrix.build.sdk }} --show-sdk-path) -mios-version-min=${{ needs.fetch.outputs.ios }}" | |
- name: Build XZ Utils | |
if: ${{ steps.cache.outputs.cache-hit != 'true' }} | |
working-directory: xz-${{ needs.fetch.outputs.xz }} | |
run: | | |
make | |
make install | |
- name: Upload the XZ Utils artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: xz-${{ matrix.build.sdk }}-${{ matrix.build.arch }} | |
path: ${{ github.workspace }}/install/xz | |
if-no-files-found: error | |
retention-days: 1 | |
build-python: | |
name: Build Python | |
needs: [build-bz2, build-ffi, build-xz] | |
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: 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: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: ${{ github.workspace }}/install | |
pattern: '*-${{ matrix.build.sdk }}-${{ matrix.build.arch }}' | |
- 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 | |
BZIP2_CFLAGS="-I${{ github.workspace }}/install/bz2-${{ matrix.build.sdk }}-${{ matrix.build.arch }}/include" | |
BZIP2_LIBS="-L${{ github.workspace }}/install/bz2-${{ matrix.build.sdk }}-${{ matrix.build.arch }}/lib -lbz2" | |
LIBFFI_CFLAGS="-I${{ github.workspace }}/install/ffi-${{ matrix.build.sdk }}-${{ matrix.build.arch }}/include" | |
LIBFFI_LIBS="-L${{ github.workspace }}/install/ffi-${{ matrix.build.sdk }}-${{ matrix.build.arch }}/lib -lffi" | |
LIBLZMA_CFLAGS="-I${{ github.workspace }}/install/xz-${{ matrix.build.sdk }}-${{ matrix.build.arch }}/include" | |
LIBLZMA_LIBS="-L${{ github.workspace }}/install/xz-${{ matrix.build.sdk }}-${{ matrix.build.arch }}/lib -llzma" | |
--enable-framework="${{ github.workspace }}/framework" | |
--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: framework | |
run: tar -czf Python.framework.tar.gz Python.framework | |
- name: Upload Python.framewrok.tar.gz | |
uses: actions/upload-artifact@v4 | |
with: | |
name: cp${{ steps.py.outputs.python-version }}-${{ matrix.build.sdk }}-${{ matrix.build.arch }} | |
path: ${{ github.workspace }}/framework/Python.framework.tar.gz | |
if-no-files-found: error | |
retention-days: 1 |