Build riscv64 wheel #27
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: Build riscv64 wheel | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| release_tag: | |
| description: 'Upstream release tag to build from' | |
| required: false | |
| type: string | |
| schedule: | |
| - cron: '0 2 * * 0' | |
| jobs: | |
| build: | |
| runs-on: ubuntu-24.04-riscv | |
| timeout-minutes: 120 | |
| env: | |
| CARGO_NET_GIT_FETCH_WITH_CLI: "true" | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: openai/tiktoken | |
| ref: ${{ inputs.release_tag || 'main' }} | |
| fetch-depth: 0 | |
| - name: Setup Rust | |
| run: | | |
| export PATH=$(echo "$PATH" | tr ':' '\n' | grep -v /opt/rust | tr '\n' ':' | sed 's/:$//') | |
| curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable | |
| echo "$HOME/.cargo/bin" >> "$GITHUB_PATH" | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@v7 | |
| - name: Build wheel | |
| run: | | |
| sudo apt-get update && sudo apt-get install -y libffi-dev | |
| uvx --python 3.14 --with maturin --with setuptools --with cffi maturin build \ | |
| --release --out /tmp/wheels/ | |
| - name: Verify platform tag | |
| run: | | |
| ls /tmp/wheels/*.whl | |
| for whl in /tmp/wheels/*.whl; do | |
| if echo "$whl" | grep -q "linux_riscv64\|manylinux.*riscv64"; then | |
| echo "OK: $whl" | |
| else | |
| echo "FAIL: $whl does not have riscv64 platform tag" | |
| exit 1 | |
| fi | |
| done | |
| - name: Upload wheel artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheel-riscv64 | |
| path: /tmp/wheels/*.whl | |
| retention-days: 90 | |
| release: | |
| needs: build | |
| runs-on: ubuntu-24.04-riscv | |
| if: success() | |
| env: | |
| GH_REPO: ${{ github.repository }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Download wheel artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: wheel-riscv64 | |
| path: /tmp/wheels/ | |
| - name: Get wheel info | |
| id: wheel_info | |
| run: | | |
| WHL=$(ls /tmp/wheels/*.whl | head -1) | |
| BASENAME=$(basename "$WHL") | |
| VERSION=$(echo "$BASENAME" | sed 's/^[^-]*-\([^-]*\)-.*/\1/') | |
| echo "whl_path=$WHL" >> "$GITHUB_OUTPUT" | |
| echo "whl_name=$BASENAME" >> "$GITHUB_OUTPUT" | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| - name: Generate checksums | |
| run: | | |
| cd /tmp/wheels | |
| sha256sum *.whl > SHA256SUMS | |
| - name: Create or update release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| TAG="riscv64-v${{ steps.wheel_info.outputs.version }}" | |
| TITLE="riscv64 wheel v${{ steps.wheel_info.outputs.version }}" | |
| gh release delete "$TAG" --yes 2>/dev/null || true | |
| git tag -d "$TAG" 2>/dev/null || true | |
| git push origin ":refs/tags/$TAG" 2>/dev/null || true | |
| gh release create "$TAG" \ | |
| --title "$TITLE" \ | |
| --notes "Prebuilt riscv64 wheel. | |
| Built on: RISE riscv64 runner (ubuntu-24.04-riscv) | |
| Wheel: ${{ steps.wheel_info.outputs.whl_name }} | |
| Install: | |
| \`\`\` | |
| pip install tiktoken --find-links https://github.com/${{ github.repository }}/releases/download/$TAG/ | |
| \`\`\`" \ | |
| /tmp/wheels/*.whl \ | |
| /tmp/wheels/SHA256SUMS | |
| - name: Cleanup | |
| if: always() | |
| run: rm -rf /tmp/wheels |