Update download-artifact action to version 4 #408
This file contains hidden or 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: CI | |
| on: | |
| push: | |
| branches: | |
| - master | |
| tags: | |
| - v* | |
| pull_request: | |
| branches: | |
| - master | |
| jobs: | |
| build-and-test-cpp: | |
| name: Build and test C++ library on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest] | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| submodules: recursive | |
| - name: Install ICU libraries on macOS | |
| if: startsWith(matrix.os, 'macos') | |
| run: brew install icu4c | |
| - name: Build and install | |
| if: startsWith(matrix.os, 'ubuntu') | |
| run: | | |
| cmake -DBUILD_TESTS=ON -DCMAKE_INSTALL_PREFIX=$PWD/install . | |
| make install | |
| - name: Build and install (macOS) | |
| if: startsWith(matrix.os, 'macos') | |
| run: | | |
| ICU_PREFIX=$(brew --prefix icu4c) | |
| cmake \ | |
| -DBUILD_TESTS=ON \ | |
| -DCMAKE_INSTALL_PREFIX=$PWD/install \ | |
| -DICU_ROOT=$ICU_PREFIX \ | |
| . | |
| make install | |
| - name: Test | |
| run: | | |
| test/onmt_tokenizer_test test/data | |
| check-python-style: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.11" | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install black==22.* flake8==3.9.* isort==5.* | |
| - name: Check code format with Black | |
| working-directory: bindings/python | |
| run: | | |
| black --check . | |
| - name: Check imports order with isort | |
| working-directory: bindings/python | |
| run: | | |
| isort --check-only . | |
| - name: Check code style with Flake8 | |
| working-directory: bindings/python | |
| if: ${{ always() }} | |
| run: | | |
| flake8 . | |
| build-and-test-python-wheels: | |
| name: Build and test wheels on ${{ matrix.os }} for ${{ matrix.arch }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-2019] | |
| arch: [auto64] | |
| include: | |
| - os: ubuntu-latest | |
| arch: aarch64 | |
| - os: macos-latest | |
| arch: arm64 | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| submodules: recursive | |
| - uses: docker/setup-qemu-action@v2 | |
| if: ${{ matrix.arch == 'aarch64' }} | |
| name: Set up QEMU | |
| - name: Build wheels | |
| uses: pypa/cibuildwheel@v2.11.2 | |
| with: | |
| package-dir: bindings/python | |
| output-dir: wheelhouse | |
| env: | |
| CIBW_ENVIRONMENT_LINUX: TOKENIZER_ROOT=/project/build/install ICU_ROOT=/project/icu | |
| CIBW_ENVIRONMENT_MACOS: TOKENIZER_ROOT=${GITHUB_WORKSPACE}/build/install | |
| CIBW_ENVIRONMENT_WINDOWS: TOKENIZER_ROOT=${GITHUB_WORKSPACE}/build/install | |
| CIBW_BEFORE_ALL_LINUX: bindings/python/tools/prepare_build_environment_linux.sh | |
| CIBW_BEFORE_ALL_MACOS: bindings/python/tools/prepare_build_environment_macos.sh | |
| CIBW_BEFORE_ALL_WINDOWS: bash bindings/python/tools/prepare_build_environment_windows.sh | |
| CIBW_BEFORE_BUILD: pip install pybind11==2.10.1 | |
| CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 | |
| CIBW_MANYLINUX_AARCH64_IMAGE: manylinux2014 | |
| CIBW_BUILD: "cp310-* cp311-* cp312-*" | |
| CIBW_TEST_COMMAND: pytest {project}/bindings/python/test/test.py | |
| CIBW_TEST_REQUIRES: pytest | |
| CIBW_ARCHS: ${{ matrix.arch }} | |
| CIBW_SKIP: pp* *-musllinux_* | |
| CIBW_TEST_SKIP: "*-macosx_arm64" | |
| CIBW_REPAIR_WHEEL_COMMAND_MACOS: "" | |
| - name: Upload Python wheels | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: python-wheels-${{ matrix.os }}-${{ matrix.arch }} | |
| path: wheelhouse | |
| publish-python-wheels-on-pypi: | |
| if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') | |
| needs: [build-and-test-cpp, build-and-test-python-wheels] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download Python wheels | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: dist | |
| - name: Publish Python wheels to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| user: __token__ | |
| password: ${{ secrets.PYPI_API_TOKEN }} | |
| packages_dir: . |