Skip to content

Commit e19f246

Browse files
Build standalone binaries in build workflow
1 parent 5ba8500 commit e19f246

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

.github/workflows/build.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,65 @@ permissions:
1212
contents: read
1313

1414
jobs:
15+
binary:
16+
runs-on: ${{ matrix.platform.runner }}
17+
strategy:
18+
matrix:
19+
platform:
20+
- runner: ubuntu-22.04
21+
target: x86_64-unknown-linux-gnu
22+
name: djls-linux-x64
23+
- runner: ubuntu-22.04
24+
target: aarch64-unknown-linux-gnu
25+
name: djls-linux-arm64
26+
- runner: macos-13
27+
target: x86_64-apple-darwin
28+
name: djls-darwin-x64
29+
- runner: macos-14
30+
target: aarch64-apple-darwin
31+
name: djls-darwin-arm64
32+
- runner: windows-latest
33+
target: x86_64-pc-windows-msvc
34+
name: djls-windows-x64.exe
35+
steps:
36+
- uses: actions/checkout@v5
37+
with:
38+
persist-credentials: false
39+
40+
- uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c
41+
with:
42+
cache: ${{ !startsWith(github.ref, 'refs/tags/') }}
43+
target: ${{ matrix.platform.target }}
44+
45+
- name: Install cross-compilation tools (Linux ARM64)
46+
if: matrix.platform.target == 'aarch64-unknown-linux-gnu'
47+
run: |
48+
sudo apt-get update
49+
sudo apt-get install -y gcc-aarch64-linux-gnu
50+
51+
- name: Build
52+
run: |
53+
cargo build --release --target ${{ matrix.platform.target }}
54+
55+
- name: Prepare binary (Unix)
56+
if: runner.os != "Windows"
57+
shell: bash
58+
run: |
59+
strip target/${{ matrix.platform.target }}/release/djls
60+
mv target/${{ matrix.platform.target }}/release/djls target/${{ matrix.platform.target }}/release/${{ matrix.platform.name }}
61+
62+
- name: Prepare binary (Windows)
63+
if: runner.os == "Windows"
64+
shell: bash
65+
run: |
66+
mv target/${{ matrix.platform.target }}/release/djls.exe target/${{ matrix.platform.target }}/release/${{ matrix.platform.name }}
67+
68+
- name: Upload binary
69+
uses: actions/upload-artifact@v4
70+
with:
71+
name: binary-${{ matrix.platform.name }}
72+
path: target/${{ matrix.platform.target }}/release/${{ matrix.platform.name }}
73+
1574
linux:
1675
runs-on: ${{ matrix.platform.runner }}
1776
strategy:

0 commit comments

Comments
 (0)