-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #170 from kcalvinalvin/2024-04-23-release-script
release: add a script to generate a release with bdkwallet
- Loading branch information
Showing
4 changed files
with
194 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
apk add git | ||
apk add go | ||
apk add zip # windows binary compression | ||
apk add perl-utils # To get shasum |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
rustup target add aarch64-unknown-linux-musl | ||
rustup target add x86_64-unknown-linux-musl | ||
rustup target add arm-unknown-linux-musleabihf | ||
rustup target add armv7-unknown-linux-musleabihf | ||
|
||
rustup target add aarch64-apple-darwin | ||
rustup target add x86_64-apple-darwin | ||
|
||
rustup target add x86_64-pc-windows-gnu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
cd $HOME | ||
|
||
curl -LO https://musl.cc/aarch64-linux-musl-cross.tgz | ||
curl -LO https://musl.cc/arm-linux-musleabihf-cross.tgz | ||
curl -LO https://musl.cc/armv6-linux-musleabihf-cross.tgz | ||
curl -LO https://musl.cc/armv7l-linux-musleabihf-cross.tgz | ||
curl -LO https://musl.cc/x86_64-linux-musl-cross.tgz | ||
curl -LO https://musl.cc/x86_64-w64-mingw32-cross.tgz | ||
|
||
tar -xzf aarch64-linux-musl-cross.tgz | ||
tar -xzf arm-linux-musleabihf-cross.tgz | ||
tar -xzf armv6-linux-musleabihf-cross.tgz | ||
tar -xzf armv7l-linux-musleabihf-cross.tgz | ||
tar -xzf x86_64-linux-musl-cross.tgz | ||
tar -xzf x86_64-w64-mingw32-cross.tgz | ||
|
||
rm aarch64-linux-musl-cross.tgz | ||
rm arm-linux-musleabihf-cross.tgz | ||
rm armv6-linux-musleabihf-cross.tgz | ||
rm armv7l-linux-musleabihf-cross.tgz | ||
rm x86_64-linux-musl-cross.tgz | ||
rm x86_64-w64-mingw32-cross.tgz | ||
|
||
echo export PATH=\$PATH:${HOME}/arm-linux-musleabihf-cross/bin >> $HOME/.profile | ||
echo export PATH=\$PATH:${HOME}/armv6-linux-musleabihf-cross/bin >> $HOME/.profile | ||
echo export PATH=\$PATH:${HOME}/armv7l-linux-musleabihf-cross/bin >> $HOME/.profile | ||
echo export PATH=\$PATH:${HOME}/aarch64-linux-musl-cross/bin >> $HOME/.profile | ||
echo export PATH=\$PATH:${HOME}/x86_64-linux-musl-cross/bin >> $HOME/.profile | ||
echo export PATH=\$PATH:${HOME}/x86_64-w64-mingw32-cross/bin >> $HOME/.profile | ||
|
||
echo "To add the binary paths:" ". $HOME/.profile" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
#!/bin/bash | ||
|
||
# Copyright (c) 2016 Company 0, LLC. | ||
# Copyright (c) 2016-2020 The btcsuite developers | ||
# Use of this source code is governed by an ISC | ||
# license that can be found in the LICENSE file. | ||
|
||
# Simple bash script to build basic utreexod tools for all the platforms we support | ||
# with the golang cross-compiler. | ||
|
||
set -e | ||
|
||
# If no tag specified, use date + version otherwise use tag. | ||
if [[ $1x = x ]]; then | ||
DATE=`date +%Y%m%d` | ||
VERSION="01" | ||
TAG=$DATE-$VERSION | ||
else | ||
TAG=$1 | ||
fi | ||
|
||
go mod vendor | ||
tar -cvzf vendor.tar.gz vendor | ||
|
||
PACKAGE=utreexod | ||
MAINDIR=$PACKAGE-$TAG | ||
mkdir -p $MAINDIR | ||
|
||
cp vendor.tar.gz $MAINDIR/ | ||
rm vendor.tar.gz | ||
rm -r vendor | ||
|
||
PACKAGESRC="$MAINDIR/$PACKAGE-source-$TAG.tar" | ||
git archive -o $PACKAGESRC HEAD | ||
gzip -f $PACKAGESRC > "$PACKAGESRC.gz" | ||
|
||
cd $MAINDIR | ||
|
||
SYS= | ||
|
||
if [[ $(uname) == Linux ]]; then | ||
# If BTCDBUILDSYS is set the default list is ignored. Useful to release | ||
# for a subset of systems/architectures. | ||
SYS=${BTCDBUILDSYS:-" | ||
linux-armv6 | ||
linux-armv7 | ||
linux-arm64 | ||
linux-amd64 | ||
windows-amd64 | ||
"} | ||
elif [[ $(uname) == Darwin ]]; then | ||
# If BTCDBUILDSYS is set the default list is ignored. Useful to release | ||
# for a subset of systems/architectures. | ||
SYS=${BTCDBUILDSYS:-" | ||
darwin-amd64 | ||
darwin-arm64 | ||
"} | ||
fi | ||
|
||
CPUCORES= | ||
if [[ $(uname) == Linux ]]; then | ||
CPUCORES=$(lscpu | grep "Core(s) per socket" | awk '{print $4}') | ||
elif [[ $(uname) == Darwin ]]; then | ||
CPUCORES=$(sysctl -n hw.physicalcpu) | ||
fi | ||
|
||
# Use the first element of $GOPATH in the case where GOPATH is a list | ||
# (something that is totally allowed). | ||
PKG="github.com/utreexo/utreexod" | ||
COMMIT=$(git describe --tags --abbrev=40 --dirty) | ||
|
||
for i in $SYS; do | ||
OS=$(echo $i | cut -f1 -d-) | ||
ARCH=$(echo $i | cut -f2 -d-) | ||
ARM= | ||
CC= | ||
|
||
if [[ $ARCH = "armv6" ]]; then | ||
ARCH=arm | ||
ARM=6 | ||
elif [[ $ARCH = "armv7" ]]; then | ||
ARCH=arm | ||
ARM=7 | ||
fi | ||
|
||
mkdir $PACKAGE-$i-$TAG | ||
echo "cd to" $PACKAGE-$i-$TAG | ||
cd $PACKAGE-$i-$TAG | ||
|
||
# Build bdk wallet(rust) dependency. | ||
if [[ $ARCH = "arm64" ]] && [[ $OS = "linux" ]]; then | ||
TARGET="aarch64-unknown-linux-musl" | ||
CC=aarch64-linux-musl-gcc | ||
|
||
elif [[ $ARCH = "amd64" ]] && [[ $OS = "linux" ]]; then | ||
TARGET="x86_64-unknown-linux-musl" | ||
CC=x86_64-linux-musl-gcc | ||
|
||
elif [[ $ARCH = "arm" ]] && [[ $OS = "linux" ]] && [[ $ARM=7 ]]; then | ||
TARGET="armv7-unknown-linux-musleabihf" | ||
CC=armv7l-linux-musleabihf-gcc | ||
|
||
elif [[ $ARCH = "arm" ]] && [[ $OS = "linux" ]] && [[ $ARM=6 ]]; then | ||
TARGET="armv6-unknown-linux-musleabihf" | ||
CC=armv6-linux-musleabihf-gcc | ||
|
||
elif [[ $ARCH = "arm64" ]] && [[ $OS = "darwin" ]]; then | ||
TARGET="aarch64-apple-darwin" | ||
|
||
elif [[ $ARCH = "amd64" ]] && [[ $OS = "darwin" ]]; then | ||
TARGET="x86_64-apple-darwin" | ||
|
||
elif [[ $ARCH = "amd64" ]] && [[ $OS = "windows" ]]; then | ||
TARGET="x86_64-pc-windows-gnu" | ||
CC=x86_64-w64-mingw32-gcc | ||
fi | ||
|
||
env CARGO_TARGET_DIR=. cargo build --release --target=$TARGET --jobs=$CPUCORES | ||
mv $TARGET target | ||
|
||
echo "Building:" $OS $ARCH $ARM | ||
|
||
# Build utreexod | ||
if [[ $OS == "linux" ]]; then | ||
env CC=$CC CGO_ENABLED=1 GOOS=$OS GOARCH=$ARCH GOARM=$ARM go build -v -tags="bdkwallet" -ldflags="-s -w -extldflags "-static" -buildid=" github.com/utreexo/utreexod | ||
elif [[ $OS == "darwin" ]]; then | ||
env CGO_ENABLED=1 GOOS=$OS GOARCH=$ARCH GOARM=$ARM go build -v -tags="bdkwallet" -ldflags="-s -w -buildid=" github.com/utreexo/utreexod | ||
fi | ||
|
||
# Remove bdk build things. | ||
rm -rf target | ||
rm -rf release | ||
|
||
# Build utreexoctl | ||
env CGO_ENABLED=0 GOOS=$OS GOARCH=$ARCH GOARM=$ARM go build -v -trimpath -ldflags="-s -w -buildid=" github.com/utreexo/utreexod/cmd/utreexoctl | ||
|
||
cd .. | ||
|
||
if [[ $OS = "windows" ]]; then | ||
zip -r $PACKAGE-$i-$TAG.zip $PACKAGE-$i-$TAG | ||
else | ||
tar -cvzf $PACKAGE-$i-$TAG.tar.gz $PACKAGE-$i-$TAG | ||
fi | ||
|
||
rm -r $PACKAGE-$i-$TAG | ||
done | ||
|
||
shasum -a 256 * > manifest-$TAG.txt |