Skip to content

Commit 227129b

Browse files
fun
1 parent f5e4c8b commit 227129b

File tree

1 file changed

+45
-33
lines changed

1 file changed

+45
-33
lines changed

.github/workflows/build.yml

Lines changed: 45 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,47 +18,36 @@ jobs:
1818
matrix:
1919
platform:
2020
- runner: ubuntu-22.04
21-
target: x86_64-unknown-linux-gnu
21+
target: x86_64
2222
- runner: ubuntu-22.04
23-
target: aarch64-unknown-linux-gnu
23+
target: aarch64
2424
- runner: macos-13
25-
target: x86_64-apple-darwin
25+
target: x86_64
2626
- runner: macos-14
27-
target: aarch64-apple-darwin
27+
target: aarch64
2828
- runner: windows-latest
29-
target: x86_64-pc-windows-msvc
29+
target: x86_64
3030
steps:
3131
- uses: actions/checkout@v5
3232
with:
3333
persist-credentials: false
3434

35-
- uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c
36-
with:
37-
cache: ${{ !startsWith(github.ref, 'refs/tags/') }}
38-
target: ${{ matrix.platform.target }}
39-
40-
- name: Install cross-compilation tools (Linux ARM64)
41-
if: ${{ matrix.platform.target == 'aarch64-unknown-linux-gnu' }}
42-
run: |
43-
sudo apt-get update
44-
sudo apt-get install -y gcc-aarch64-linux-gnu
45-
46-
- name: Build
47-
run: |
48-
cargo build --release --target ${{ matrix.platform.target }}
49-
50-
- name: Prepare binary
51-
id: binary
35+
- name: Prepare platform
36+
id: platform
5237
shell: bash
5338
run: |
5439
name="djls"
40+
target="${{ matrix.platform.target }}"
5541
5642
if ${{ runner.os == 'Linux' }}; then
5743
name+="-linux"
44+
target+="-unknown-linux-gnu"
5845
elif ${{ runner.os == 'macOS' }}; then
5946
name+="-darwin"
47+
target+="-apple-darwin"
6048
elif ${{ runner.os == 'Windows' }}; then
6149
name+="-windows"
50+
target+="-pc-windows-msvc"
6251
fi
6352
6453
if ${{ contains(matrix.platform.target, 'x86_64') }}; then
@@ -68,25 +57,48 @@ jobs:
6857
fi
6958
7059
if ${{ runner.os == 'Windows' }}; then
71-
source="target/${{ matrix.platform.target }}/release/djls.exe"
72-
dest="target/${{ matrix.platform.target }}/release/${name}.exe"
60+
source="target/${target}/release/djls.exe"
61+
dest="target/${target}/release/${name}.exe"
7362
else
74-
source="target/${{ matrix.platform.target }}/release/djls"
75-
dest="target/${{ matrix.platform.target }}/release/${name}"
76-
77-
strip "$source"
63+
source="target/${target}/release/djls"
64+
dest="target/${target}/release/${name}"
7865
fi
7966
80-
mv "$source" "$dest"
81-
8267
echo "name=$name" >> $GITHUB_OUTPUT
83-
echo "path=$dest" >> $GITHUB_OUTPUT
68+
echo "target=$target" >> $GITHUB_OUTPUT
69+
echo "source=$source" >> $GITHUB_OUTPUT
70+
echo "dest=$dest" >> $GITHUB_OUTPUT
71+
72+
- uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c
73+
with:
74+
cache: ${{ !startsWith(github.ref, 'refs/tags/') }}
75+
target: ${{ steps.platform.outputs.target }}
76+
77+
- name: Install cross-compilation tools (Linux ARM64)
78+
if: ${{ steps.platform.outputs.target == 'aarch64-unknown-linux-gnu' }}
79+
run: |
80+
sudo apt-get update
81+
sudo apt-get install -y gcc-aarch64-linux-gnu
82+
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
83+
84+
- name: Build
85+
run: |
86+
cargo build --release --target ${{ steps.platform.outputs.target }}
87+
88+
- name: Prepare binary
89+
shell: bash
90+
run: |
91+
if ${{ runner.os != 'Windows' }}; then
92+
strip "${{ steps.platform.outputs.source }}"
93+
fi
94+
95+
mv "${{ steps.platform.outputs.source }}" "${{ steps.platform.outputs.dest }}"
8496
8597
- name: Upload binary
8698
uses: actions/upload-artifact@v4
8799
with:
88-
name: binary-${{ steps.binary.outputs.name }}
89-
path: ${{ steps.binary.outputs.path }}
100+
name: binary-${{ steps.platform.outputs.name }}
101+
path: ${{ steps.platform.outputs.dest }}
90102

91103
linux:
92104
runs-on: ${{ matrix.platform.runner }}

0 commit comments

Comments
 (0)