forked from openai/tiktoken
-
Notifications
You must be signed in to change notification settings - Fork 0
125 lines (110 loc) · 4 KB
/
Copy pathbuild-riscv64.yml
File metadata and controls
125 lines (110 loc) · 4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
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:
ref: ${{ inputs.release_tag || github.ref }}
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
# cffi must be installed in every Python maturin auto-discovers for
# FFI declaration generation. uvx --with cffi covers the tool env
# (Python 3.14); install it separately into the RISE runner's opt
# Python so maturin can generate declarations for that interpreter too.
# Discover the path dynamically — runner image updates may change the version.
OPT_PYTHON=$(find /opt -maxdepth 3 -name "python3" -type f 2>/dev/null | head -1)
if [ -n "$OPT_PYTHON" ]; then
sudo "$OPT_PYTHON" -m pip install --quiet cffi
fi
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