Skip to content

Commit

Permalink
Add release-build.sh (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrgn committed Feb 13, 2018
1 parent 4393b99 commit 9053745
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions release-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env bash

set -euo pipefail

VERSION=$(grep '^version = ' Cargo.toml | sed 's/.*"\([0-9\.]*\)".*/\1/')
GPG_KEY=EA456E8BAF0109429583EED83578F667F2F3A5FA

declare -a targets=(
"x86_64-musl"
"i686-musl"
"armv7-musleabihf"
"arm-musleabi"
"arm-musleabihf"
)

declare -a rusttargets=(
"x86_64-unknown-linux-musl"
"i686-unknown-linux-musl"
"armv7-unknown-linux-musleabihf"
"arm-unknown-linux-musleabi"
"arm-unknown-linux-musleabihf"
)

function docker-download {
echo "==> Downloading Docker image: messense/rust-musl-cross:$1"
docker pull messense/rust-musl-cross:$1
}

function docker-build {
echo "==> Building target: $1"
docker run --rm -it -v "$(pwd)":/home/rust/src messense/rust-musl-cross:$1 cargo build --release
}

function copy {
cp target/
}

echo -e "==> Version $VERSION\n"

for target in ${targets[@]}; do docker-download $target; done
echo ""
for target in ${targets[@]}; do docker-build $target; done
echo ""

rm -rf "dist-$VERSION"
mkdir "dist-$VERSION"

for i in ${!targets[@]}; do
echo "==> Copying ${targets[$i]}"
cp "target/${rusttargets[$i]}/release/tldr" "dist-$VERSION/tldr-${targets[$i]}"
done
echo ""

# TODO: Strip binaries, see https://github.com/messense/rust-musl-cross/issues/9

for target in ${targets[@]}; do
echo "==> Signing $target"
gpg -a --output "dist-$VERSION/tldr-$target.sig" --detach-sig "dist-$VERSION/tldr-$target"
done
echo ""

echo "Done."

2 comments on commit 9053745

@messense
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can now use rust-musl-cross to strip binaries, see the instruction here: https://github.com/messense/rust-musl-cross#strip-binaries

@dbrgn
Copy link
Collaborator Author

@dbrgn dbrgn commented on 9053745 Feb 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@messense awesome, thanks!

Please sign in to comment.