Skip to content

Commit c4aabc5

Browse files
authored
Cross compile Rust binaries (#138)
1 parent 3de2dae commit c4aabc5

File tree

2 files changed

+28
-69
lines changed

2 files changed

+28
-69
lines changed

.github/workflows/build.yml

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,39 @@ on:
99

1010
jobs:
1111
build-binary:
12-
runs-on: ${{ matrix.os.runner }}
12+
runs-on: ${{ matrix.target.runner }}
1313
permissions:
1414
contents: write
1515
id-token: write
1616
strategy:
1717
fail-fast: false
1818
matrix:
19-
arch:
20-
- x64
21-
- arm64
22-
os:
23-
- name: linux
19+
target:
20+
- name: linux-x86_64
2421
runner: ubuntu-latest
2522
ext: ""
26-
- name: windows
23+
target: x86_64-unknown-linux-gnu
24+
- name: windows-x86_64
2725
runner: windows-latest
2826
ext: ".exe"
29-
- name: macos
27+
target: x86_64-pc-windows-msvc
28+
- name: macos-x86_64
3029
runner: macos-latest
3130
ext: ""
31+
target: x86_64-apple-darwin
32+
- name: linux-arm64
33+
runner: ubuntu-latest
34+
ext: ""
35+
target: aarch64-unknown-linux-gnu
36+
- name: windows-arm64
37+
runner: windows-latest
38+
ext: ".exe"
39+
target: aarch64-pc-windows-msvc
40+
- name: macos-arm64
41+
runner: macos-latest
42+
ext: ""
43+
target: aarch64-apple-darwin
3244
steps:
33-
- name: Install missing OS dependencies for Linux
34-
if: ${{ matrix.os.name == 'linux' && matrix.arch == 'arm64' }}
35-
run: sudo apt update && sudo apt install -y gcc-aarch64-linux-gnu
3645
- name: Checkout
3746
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
3847
with:
@@ -42,30 +51,17 @@ jobs:
4251
with:
4352
ref: ${{ inputs.version }}
4453
path: checkout-tag
45-
- name: Get Rust target name
46-
id: rust-target
47-
env:
48-
RUST_OS: ${{ matrix.os.name }}
49-
RUST_ARCH: ${{ matrix.arch }}
50-
shell: bash
51-
run: |
52-
echo target=$($GITHUB_WORKSPACE/checkout-main/.github/workflows/scripts/rust-build.sh --print-target) >> "$GITHUB_OUTPUT"
53-
- name: Rust toolkit setup
54-
uses: actions-rust-lang/setup-rust-toolchain@v1
54+
- name: Build binary
55+
uses: houseabsolute/[email protected]
5556
with:
56-
target: ${{ steps.rust-target.outputs.target }}
57-
- name: Build binary ${{ matrix.os.name }}-${{ matrix.arch }}
58-
env:
59-
RUST_OS: ${{ matrix.os.name }}
60-
RUST_ARCH: ${{ matrix.arch }}
61-
shell: bash
62-
run: |
63-
cd $GITHUB_WORKSPACE/checkout-tag
64-
$GITHUB_WORKSPACE/checkout-main/.github/workflows/scripts/rust-build.sh
57+
command: build
58+
target: ${{ matrix.target.target }}
59+
args: "--locked --release"
60+
working-directory: ${{ github.workspace }}/checkout-tag
6561
- name: Upload binaries to release
6662
uses: svenstaro/upload-release-action@v2
6763
with:
6864
tag: ${{ inputs.version }}
69-
file: checkout-tag/target/${{ steps.rust-target.outputs.target }}/release/elasticsearch-core-mcp-server${{ matrix.os.ext }}
70-
asset_name: elasticsearch-core-mcp-server-${{ inputs.version }}-${{ matrix.os.name }}-${{ matrix.arch }}${{ matrix.os.ext }}
65+
file: checkout-tag/target/${{ matrix.target.target }}/release/elasticsearch-core-mcp-server${{ matrix.target.ext }}
66+
asset_name: elasticsearch-core-mcp-server-${{ inputs.version }}-${{ matrix.target.name }}${{ matrix.target.ext }}
7167
overwrite: true

.github/workflows/scripts/rust-build.sh

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)