From 4ebefeb43af09a7a408ad27f00c0eb4cdf983649 Mon Sep 17 00:00:00 2001 From: gifnksm Date: Fri, 22 Jul 2022 20:28:54 +0900 Subject: [PATCH] Deploy {x86_64,aarch64}-unknown-linux-musl binary --- .github/workflows/deploy.yml | 22 +++++++++++++++++++--- ci/install-rust.sh | 11 +++++++++++ ci/make-release.sh | 15 ++++++++++----- 3 files changed, 40 insertions(+), 8 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index cc01f5b5..f5487992 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -9,19 +9,35 @@ jobs: runs-on: ${{ matrix.os }} strategy: 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: - uses: actions/checkout@master - name: Install hub run: ci/install-hub.sh ${{ matrix.os }} shell: bash - name: Install Rust - run: ci/install-rust.sh stable + run: ci/install-rust.sh stable ${{ matrix.target }} shell: bash - name: Build and deploy artifacts env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: ci/make-release.sh ${{ matrix.os }} + run: ci/make-release.sh ${{ matrix.os }} ${{ matrix.target }} shell: bash pages: name: GitHub Pages diff --git a/ci/install-rust.sh b/ci/install-rust.sh index c608c70d..d97e45a0 100755 --- a/ci/install-rust.sh +++ b/ci/install-rust.sh @@ -13,6 +13,17 @@ TOOLCHAIN="$1" rustup set profile minimal rustup component remove --toolchain=$TOOLCHAIN rust-docs || echo "already removed" 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 -V rustc -Vv diff --git a/ci/make-release.sh b/ci/make-release.sh index 761923bf..8a62b700 100755 --- a/ci/make-release.sh +++ b/ci/make-release.sh @@ -11,16 +11,21 @@ fi TAG=${GITHUB_REF#*/tags/} 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 -cargo build --bin mdbook --release -cd target/release +cargo build --bin mdbook --release --target $target +cd target/$target/release case $1 in ubuntu*) - asset="mdbook-$TAG-$host.tar.gz" + asset="mdbook-$TAG-$target.tar.gz" tar czf ../../$asset mdbook ;; 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 # sometimes all NUL bytes. See https://github.com/actions/cache/issues/403 # and https://github.com/rust-lang/cargo/issues/8603 for some more @@ -30,7 +35,7 @@ case $1 in tar czf ../../$asset mdbook ;; windows*) - asset="mdbook-$TAG-$host.zip" + asset="mdbook-$TAG-$target.zip" 7z a ../../$asset mdbook.exe ;; *)