Skip to content

Commit 86030fb

Browse files
committed
feat: Add support for arm64 and 32-bit architectures, update build and release processes
1 parent 595b8a2 commit 86030fb

1 file changed

Lines changed: 44 additions & 3 deletions

File tree

.github/workflows/rust.yml

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,39 @@ jobs:
2929
strategy:
3030
matrix:
3131
include:
32+
# 现有的amd64架构
3233
- os: ubuntu-latest
3334
artifact_name: ocr
3435
asset_name: ocr-linux-amd64
36+
target: x86_64-unknown-linux-gnu
3537
- os: windows-latest
3638
artifact_name: ocr.exe
3739
asset_name: ocr-windows-amd64.exe
40+
target: x86_64-pc-windows-msvc
3841
- os: macos-latest
3942
artifact_name: ocr
4043
asset_name: ocr-macos-amd64
44+
target: x86_64-apple-darwin
45+
46+
# 添加arm64架构支持
47+
- os: ubuntu-latest
48+
artifact_name: ocr
49+
asset_name: ocr-linux-arm64
50+
target: aarch64-unknown-linux-gnu
51+
- os: macos-latest
52+
artifact_name: ocr
53+
asset_name: ocr-macos-arm64
54+
target: aarch64-apple-darwin
55+
56+
# 添加32位架构支持
57+
- os: ubuntu-latest
58+
artifact_name: ocr
59+
asset_name: ocr-linux-x86
60+
target: i686-unknown-linux-gnu
61+
- os: windows-latest
62+
artifact_name: ocr.exe
63+
asset_name: ocr-windows-x86.exe
64+
target: i686-pc-windows-msvc
4165

4266
steps:
4367
- uses: actions/checkout@v4
@@ -47,17 +71,34 @@ jobs:
4771
with:
4872
toolchain: stable
4973
override: true
74+
target: ${{ matrix.target }}
75+
76+
- name: Install Cross-Compilation Dependencies
77+
if: contains(matrix.target, 'aarch64') || contains(matrix.target, 'i686')
78+
run: |
79+
if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
80+
sudo apt-get update
81+
if [[ "${{ matrix.target }}" == "aarch64-unknown-linux-gnu" ]]; then
82+
sudo apt-get install -y gcc-aarch64-linux-gnu
83+
elif [[ "${{ matrix.target }}" == "i686-unknown-linux-gnu" ]]; then
84+
sudo apt-get install -y gcc-multilib
85+
fi
86+
fi
87+
shell: bash
5088

5189
- name: Build Release Binary
52-
run: cargo build --release --bin ocr
90+
uses: actions-rs/cargo@v1
91+
with:
92+
command: build
93+
args: --release --bin ocr --target ${{ matrix.target }}
5394

5495
- name: Rename Binary
5596
shell: bash
5697
run: |
5798
if [ "${{ matrix.os }}" = "windows-latest" ]; then
58-
cp target/release/${{ matrix.artifact_name }} ${{ matrix.asset_name }}
99+
cp target/${{ matrix.target }}/release/${{ matrix.artifact_name }} ${{ matrix.asset_name }}
59100
else
60-
cp target/release/${{ matrix.artifact_name }} ${{ matrix.asset_name }}
101+
cp target/${{ matrix.target }}/release/${{ matrix.artifact_name }} ${{ matrix.asset_name }}
61102
fi
62103
63104
- name: Upload Release Asset

0 commit comments

Comments
 (0)