From 7742438719e717eac4e8f588bec71a3fc2049185 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Sat, 2 Dec 2023 15:00:22 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=9A=20use=20maturin=20in=20CI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main.yaml | 108 ++++++++++++++++++++++++++++++--- .github/workflows/preview.yaml | 9 +++ 2 files changed, 107 insertions(+), 10 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 658297312..daae7ca53 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -39,11 +39,108 @@ jobs: ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} run: cd server && poetry run pytest - pypi-deployment: + linux: runs-on: ubuntu-latest + strategy: + matrix: + target: [x86_64, x86, aarch64, armv7, s390x, ppc64le] + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: "3.10.8" + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.target }} + args: --release --out dist --find-interpreter + sccache: "true" + manylinux: auto + - name: Upload wheels + uses: actions/upload-artifact@v3 + with: + name: wheels + path: dist + + windows: + runs-on: windows-latest + strategy: + matrix: + target: [x64, x86] + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: "3.10.8" + architecture: ${{ matrix.target }} + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.target }} + args: --release --out dist --find-interpreter + sccache: "true" + - name: Upload wheels + uses: actions/upload-artifact@v3 + with: + name: wheels + path: dist + + macos: + runs-on: macos-latest + strategy: + matrix: + target: [x86_64, aarch64] + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: "3.10.8" + - name: Build wheels + uses: PyO3/maturin-action@v1 + with: + target: ${{ matrix.target }} + args: --release --out dist --find-interpreter + sccache: "true" + - name: Upload wheels + uses: actions/upload-artifact@v3 + with: + name: wheels + path: dist + + sdist: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Build sdist + uses: PyO3/maturin-action@v1 + with: + command: sdist + args: --out dist + - name: Upload sdist + uses: actions/upload-artifact@v3 + with: + name: wheels + path: dist + + release: + name: Release + runs-on: ubuntu-latest + if: "startsWith(github.ref, 'refs/tags/')" + needs: [linux, windows, macos, sdist] permissions: contents: write steps: + - uses: actions/download-artifact@v3 + with: + name: wheels + - name: Publish to PyPI + uses: PyO3/maturin-action@v1 + env: + MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }} + with: + command: upload + args: --non-interactive --skip-existing * + - name: Check out code uses: actions/checkout@v2 @@ -57,18 +154,9 @@ jobs: python -m pip install --upgrade pip pip install poetry - - name: Install project dependencies - run: cd server && poetry install - - - name: Configure Poetry Token - run: cd server && poetry config pypi-token.pypi ${{ secrets.PYPI_API_TOKEN }} - - name: Bump the version run: cd server && poetry version patch - - name: Build and publish the package - run: cd server && poetry publish --build - - name: Commit changes run: | git config --local user.email "action@github.com" diff --git a/.github/workflows/preview.yaml b/.github/workflows/preview.yaml index 59f92219d..b7f4ac5c1 100644 --- a/.github/workflows/preview.yaml +++ b/.github/workflows/preview.yaml @@ -90,6 +90,10 @@ jobs: run: | pip install pyinstaller + - name: Install Maturin + run: | + pip install maturin + - name: Install Dependencies run: | pip install -r server/requirements.txt @@ -124,6 +128,11 @@ jobs: # python setup.py build_static build # if: matrix.os == 'ubuntu-latest' + - name: Build the Rust library + run: | + cd server + maturin develop + - name: Install tiktoken vocab file # Done to avoid extra network request to download the vocab file run: |