Fixes the version mismatch of upload/download artifacts actions. #22
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: libclang-macosx-arm64 | |
on: [push, pull_request] | |
env: | |
LLVM_VER: 18.1.1 | |
BIN: /usr/local/opt/llvm/bin | |
concurrency: | |
group: ${{ github.repository }}-${{ github.head_ref || github.sha }}-${{ github.workflow }} | |
cancel-in-progress: true | |
jobs: | |
build-and-deploy: | |
if: "!contains(github.event.head_commit.message, 'skip ci')" | |
runs-on: macos-11 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: install wheel dependencies | |
run: | | |
pip3 install wheel | |
- name: install llvm | |
run: | | |
brew install llvm # assume install under /usr/local/opt/llvm | |
- name: get llvm-project | |
run: | | |
wget -q https://github.com/llvm/llvm-project/releases/download/llvmorg-$LLVM_VER/llvm-project-$LLVM_VER.src.tar.xz | |
tar xf llvm-project-$LLVM_VER.src.tar.xz | |
mv llvm-project-$LLVM_VER.src llvm-project-$LLVM_VER | |
- name: cmake | |
# see https://llvm.org/docs/HowToCrossCompileLLVM.html | |
run: | | |
echo "BIN=$BIN" >> "$GITHUB_ENV" | |
echo "$BIN" >> "$GITHUB_PATH" | |
set echo | |
uname -a | |
cd llvm-project-$LLVM_VER | |
# note: LIBCXX_ENABLE_ASSERTIONS=FALSE is for the "undefined symbol: std::__1::__libcpp_verbose_abort(char const*, ...)" failure | |
cmake -S llvm \ | |
-G "Unix Makefiles" -B build \ | |
-DBUILD_SHARED_LIBS=OFF \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-DCMAKE_CXX_COMPILER=$BIN/clang++ \ | |
-DCMAKE_C_COMPILER=$BIN/clang \ | |
-DCMAKE_INSTALL_PREFIX=$HOME/.local \ | |
-DCMAKE_OSX_ARCHITECTURES=arm64 \ | |
-DCMAKE_SYSTEM_NAME=Darwin \ | |
-DDEFAULT_SYSROOT="$(xcrun --show-sdk-path)" \ | |
-DLLVM_DEFAULT_TARGET_TRIPLE=18.1.1-arm64-apple-darwin21.6 \ | |
-DLLVM_ENABLE_PIC=False \ | |
-DLLVM_ENABLE_PROJECTS=clang \ | |
-DLLVM_ENABLE_TERMINFO=OFF \ | |
-DLLVM_ENABLE_WERROR=FALSE \ | |
-DLLVM_ENABLE_ZLIB=OFF \ | |
-DLLVM_ENABLE_ZSTD=OFF \ | |
-DLLVM_NATIVE_TOOL_DIR=$BIN \ | |
-DLLVM_USE_LINKER=lld \ | |
-DLIBCXX_ENABLE_ASSERTIONS=FALSE \ | |
-DLLVM_TARGETS_TO_BUILD=AArch64 | |
- name: build | |
run: | | |
cd llvm-project-$LLVM_VER | |
cmake --build build --config Release --target libclang --parallel $(sysctl -n hw.ncpu) | |
- name: combine .a archives into dylib | |
run: | | |
cd llvm-project-$LLVM_VER/build/lib | |
set echo | |
# convert .a -> dylib | |
$BIN/clang -arch arm64 -fpic -shared -lstdc++ -Wl,-force_load libclang.a *.a -o libclang.dylib | |
strip -u libclang.dylib | |
lipo -info libclang.dylib | |
du -csh libclang.dylib | |
file libclang.dylib | |
otool -L libclang.dylib | |
dyldinfo -platform -dependents libclang.dylib || true | |
- name: create and print sha512sum | |
run: | | |
cd llvm-project-$LLVM_VER/build/lib | |
shasum -a512 libclang.dylib > libclang.dylib.$LLVM_VER.macosx-arm64.sha512sum | |
echo "Checksum is: " | |
cat libclang.dylib.$LLVM_VER.macosx-arm64.sha512sum | |
gtar zcvf libclang.dylib.$LLVM_VER.macosx-arm64.tar.gz libclang.dylib libclang.dylib.$LLVM_VER.macosx-arm64.sha512sum | |
shasum -a512 libclang.dylib.$LLVM_VER.macosx-arm64.tar.gz | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: libclang.dylib.${{env.LLVM_VER}}.macosx-arm64.tar.gz | |
path: llvm-project-${{env.LLVM_VER}}/build/lib/libclang.dylib.${{env.LLVM_VER}}.macosx-arm64.tar.gz | |
- name: generate wheel package | |
run: | | |
cp llvm-project-$LLVM_VER/build/lib/libclang.dylib native/ | |
python3 setup_ext.py bdist_wheel --universal --plat-name=macosx_11_0_arm64 | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: wheel-${{env.LLVM_VER}}-macosx_11_0_arm64 | |
path: dist/*.whl | |
upload-to-pypi: | |
runs-on: ubuntu-latest | |
needs: [build-and-deploy] | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: wheel-${{env.LLVM_VER}}-macosx_11_0_arm64 | |
path: dist/ | |
- name: Publish to PyPI | |
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
packages_dir: dist/ | |
password: ${{ secrets.PYPI_TOKEN }} | |
verbose: true | |
print_hash: true |