Merge pull request #1862 from gifnksm/add-musl-binary

Deploy {x86_64,aarch64}-unknown-linux-musl binary
This commit is contained in:
Eric Huss 2022-10-13 17:17:53 -07:00 committed by GitHub
commit 056a46cc97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 8 deletions

View File

@ -9,19 +9,35 @@ jobs:
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
strategy: strategy:
matrix: matrix:
os: [ubuntu-latest, macos-latest, windows-latest] target:
- aarch64-unknown-linux-musl
- x86_64-unknown-linux-gnu
- x86_64-unknown-linux-musl
- x86_64-apple-darwin
- x86_64-pc-windows-msvc
include:
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
steps: steps:
- uses: actions/checkout@master - uses: actions/checkout@master
- name: Install hub - name: Install hub
run: ci/install-hub.sh ${{ matrix.os }} run: ci/install-hub.sh ${{ matrix.os }}
shell: bash shell: bash
- name: Install Rust - name: Install Rust
run: ci/install-rust.sh stable run: ci/install-rust.sh stable ${{ matrix.target }}
shell: bash shell: bash
- name: Build and deploy artifacts - name: Build and deploy artifacts
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ci/make-release.sh ${{ matrix.os }} run: ci/make-release.sh ${{ matrix.os }} ${{ matrix.target }}
shell: bash shell: bash
pages: pages:
name: GitHub Pages name: GitHub Pages

View File

@ -13,6 +13,17 @@ TOOLCHAIN="$1"
rustup set profile minimal rustup set profile minimal
rustup component remove --toolchain=$TOOLCHAIN rust-docs || echo "already removed" rustup component remove --toolchain=$TOOLCHAIN rust-docs || echo "already removed"
rustup update --no-self-update $TOOLCHAIN rustup update --no-self-update $TOOLCHAIN
if [ -n "$2" ]
then
TARGET="$2"
HOST=$(rustc -Vv | grep ^host: | sed -e "s/host: //g")
if [ "$HOST" != "$TARGET" ]
then
rustup component add llvm-tools-preview --toolchain=$TOOLCHAIN
rustup component add rust-std-$TARGET --toolchain=$TOOLCHAIN
fi
fi
rustup default $TOOLCHAIN rustup default $TOOLCHAIN
rustup -V rustup -V
rustc -Vv rustc -Vv

View File

@ -11,16 +11,21 @@ fi
TAG=${GITHUB_REF#*/tags/} TAG=${GITHUB_REF#*/tags/}
host=$(rustc -Vv | grep ^host: | sed -e "s/host: //g") host=$(rustc -Vv | grep ^host: | sed -e "s/host: //g")
target=$2
if [ "$host" != "$target" ]
then
export "CARGO_TARGET_$(echo $target | tr a-z- A-Z_)_LINKER"=rust-lld
fi
export CARGO_PROFILE_RELEASE_LTO=true export CARGO_PROFILE_RELEASE_LTO=true
cargo build --bin mdbook --release cargo build --bin mdbook --release --target $target
cd target/release cd target/$target/release
case $1 in case $1 in
ubuntu*) ubuntu*)
asset="mdbook-$TAG-$host.tar.gz" asset="mdbook-$TAG-$target.tar.gz"
tar czf ../../$asset mdbook tar czf ../../$asset mdbook
;; ;;
macos*) macos*)
asset="mdbook-$TAG-$host.tar.gz" asset="mdbook-$TAG-$target.tar.gz"
# There is a bug with BSD tar on macOS where the first 8MB of the file are # There is a bug with BSD tar on macOS where the first 8MB of the file are
# sometimes all NUL bytes. See https://github.com/actions/cache/issues/403 # sometimes all NUL bytes. See https://github.com/actions/cache/issues/403
# and https://github.com/rust-lang/cargo/issues/8603 for some more # and https://github.com/rust-lang/cargo/issues/8603 for some more
@ -30,7 +35,7 @@ case $1 in
tar czf ../../$asset mdbook tar czf ../../$asset mdbook
;; ;;
windows*) windows*)
asset="mdbook-$TAG-$host.zip" asset="mdbook-$TAG-$target.zip"
7z a ../../$asset mdbook.exe 7z a ../../$asset mdbook.exe
;; ;;
*) *)