Skip to content

Commit 056a46c

Browse files
authored
Merge pull request #1862 from gifnksm/add-musl-binary
Deploy {x86_64,aarch64}-unknown-linux-musl binary
2 parents f8df8ed + 4ebefeb commit 056a46c

File tree

3 files changed

+40
-8
lines changed

3 files changed

+40
-8
lines changed

.github/workflows/deploy.yml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,35 @@ jobs:
99
runs-on: ${{ matrix.os }}
1010
strategy:
1111
matrix:
12-
os: [ubuntu-latest, macos-latest, windows-latest]
12+
target:
13+
- aarch64-unknown-linux-musl
14+
- x86_64-unknown-linux-gnu
15+
- x86_64-unknown-linux-musl
16+
- x86_64-apple-darwin
17+
- x86_64-pc-windows-msvc
18+
include:
19+
- target: aarch64-unknown-linux-musl
20+
os: ubuntu-latest
21+
- target: x86_64-unknown-linux-gnu
22+
os: ubuntu-latest
23+
- target: x86_64-unknown-linux-musl
24+
os: ubuntu-latest
25+
- target: x86_64-apple-darwin
26+
os: macos-latest
27+
- target: x86_64-pc-windows-msvc
28+
os: windows-latest
1329
steps:
1430
- uses: actions/checkout@master
1531
- name: Install hub
1632
run: ci/install-hub.sh ${{ matrix.os }}
1733
shell: bash
1834
- name: Install Rust
19-
run: ci/install-rust.sh stable
35+
run: ci/install-rust.sh stable ${{ matrix.target }}
2036
shell: bash
2137
- name: Build and deploy artifacts
2238
env:
2339
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24-
run: ci/make-release.sh ${{ matrix.os }}
40+
run: ci/make-release.sh ${{ matrix.os }} ${{ matrix.target }}
2541
shell: bash
2642
pages:
2743
name: GitHub Pages

ci/install-rust.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ TOOLCHAIN="$1"
1313
rustup set profile minimal
1414
rustup component remove --toolchain=$TOOLCHAIN rust-docs || echo "already removed"
1515
rustup update --no-self-update $TOOLCHAIN
16+
if [ -n "$2" ]
17+
then
18+
TARGET="$2"
19+
HOST=$(rustc -Vv | grep ^host: | sed -e "s/host: //g")
20+
if [ "$HOST" != "$TARGET" ]
21+
then
22+
rustup component add llvm-tools-preview --toolchain=$TOOLCHAIN
23+
rustup component add rust-std-$TARGET --toolchain=$TOOLCHAIN
24+
fi
25+
fi
26+
1627
rustup default $TOOLCHAIN
1728
rustup -V
1829
rustc -Vv

ci/make-release.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,21 @@ fi
1111
TAG=${GITHUB_REF#*/tags/}
1212

1313
host=$(rustc -Vv | grep ^host: | sed -e "s/host: //g")
14+
target=$2
15+
if [ "$host" != "$target" ]
16+
then
17+
export "CARGO_TARGET_$(echo $target | tr a-z- A-Z_)_LINKER"=rust-lld
18+
fi
1419
export CARGO_PROFILE_RELEASE_LTO=true
15-
cargo build --bin mdbook --release
16-
cd target/release
20+
cargo build --bin mdbook --release --target $target
21+
cd target/$target/release
1722
case $1 in
1823
ubuntu*)
19-
asset="mdbook-$TAG-$host.tar.gz"
24+
asset="mdbook-$TAG-$target.tar.gz"
2025
tar czf ../../$asset mdbook
2126
;;
2227
macos*)
23-
asset="mdbook-$TAG-$host.tar.gz"
28+
asset="mdbook-$TAG-$target.tar.gz"
2429
# There is a bug with BSD tar on macOS where the first 8MB of the file are
2530
# sometimes all NUL bytes. See https://github.com/actions/cache/issues/403
2631
# and https://github.com/rust-lang/cargo/issues/8603 for some more
@@ -30,7 +35,7 @@ case $1 in
3035
tar czf ../../$asset mdbook
3136
;;
3237
windows*)
33-
asset="mdbook-$TAG-$host.zip"
38+
asset="mdbook-$TAG-$target.zip"
3439
7z a ../../$asset mdbook.exe
3540
;;
3641
*)

0 commit comments

Comments
 (0)