Skip to content

Commit b94de47

Browse files
authored
Merge pull request #170 from kcalvinalvin/2024-04-23-release-script
release: add a script to generate a release with bdkwallet
2 parents 4a1ca21 + 4473ac3 commit b94de47

File tree

4 files changed

+194
-0
lines changed

4 files changed

+194
-0
lines changed

release/get-alpinelinux-deps.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apk add git
2+
apk add go
3+
apk add zip # windows binary compression
4+
apk add perl-utils # To get shasum

release/get-rustup-targets.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
rustup target add aarch64-unknown-linux-musl
4+
rustup target add x86_64-unknown-linux-musl
5+
rustup target add arm-unknown-linux-musleabihf
6+
rustup target add armv7-unknown-linux-musleabihf
7+
8+
rustup target add aarch64-apple-darwin
9+
rustup target add x86_64-apple-darwin
10+
11+
rustup target add x86_64-pc-windows-gnu

release/install-musl-deps.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
cd $HOME
2+
3+
curl -LO https://musl.cc/aarch64-linux-musl-cross.tgz
4+
curl -LO https://musl.cc/arm-linux-musleabihf-cross.tgz
5+
curl -LO https://musl.cc/armv6-linux-musleabihf-cross.tgz
6+
curl -LO https://musl.cc/armv7l-linux-musleabihf-cross.tgz
7+
curl -LO https://musl.cc/x86_64-linux-musl-cross.tgz
8+
curl -LO https://musl.cc/x86_64-w64-mingw32-cross.tgz
9+
10+
tar -xzf aarch64-linux-musl-cross.tgz
11+
tar -xzf arm-linux-musleabihf-cross.tgz
12+
tar -xzf armv6-linux-musleabihf-cross.tgz
13+
tar -xzf armv7l-linux-musleabihf-cross.tgz
14+
tar -xzf x86_64-linux-musl-cross.tgz
15+
tar -xzf x86_64-w64-mingw32-cross.tgz
16+
17+
rm aarch64-linux-musl-cross.tgz
18+
rm arm-linux-musleabihf-cross.tgz
19+
rm armv6-linux-musleabihf-cross.tgz
20+
rm armv7l-linux-musleabihf-cross.tgz
21+
rm x86_64-linux-musl-cross.tgz
22+
rm x86_64-w64-mingw32-cross.tgz
23+
24+
echo export PATH=\$PATH:${HOME}/arm-linux-musleabihf-cross/bin >> $HOME/.profile
25+
echo export PATH=\$PATH:${HOME}/armv6-linux-musleabihf-cross/bin >> $HOME/.profile
26+
echo export PATH=\$PATH:${HOME}/armv7l-linux-musleabihf-cross/bin >> $HOME/.profile
27+
echo export PATH=\$PATH:${HOME}/aarch64-linux-musl-cross/bin >> $HOME/.profile
28+
echo export PATH=\$PATH:${HOME}/x86_64-linux-musl-cross/bin >> $HOME/.profile
29+
echo export PATH=\$PATH:${HOME}/x86_64-w64-mingw32-cross/bin >> $HOME/.profile
30+
31+
echo "To add the binary paths:" ". $HOME/.profile"

release/release-with-wallet.sh

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
#!/bin/bash
2+
3+
# Copyright (c) 2016 Company 0, LLC.
4+
# Copyright (c) 2016-2020 The btcsuite developers
5+
# Use of this source code is governed by an ISC
6+
# license that can be found in the LICENSE file.
7+
8+
# Simple bash script to build basic utreexod tools for all the platforms we support
9+
# with the golang cross-compiler.
10+
11+
set -e
12+
13+
# If no tag specified, use date + version otherwise use tag.
14+
if [[ $1x = x ]]; then
15+
DATE=`date +%Y%m%d`
16+
VERSION="01"
17+
TAG=$DATE-$VERSION
18+
else
19+
TAG=$1
20+
fi
21+
22+
go mod vendor
23+
tar -cvzf vendor.tar.gz vendor
24+
25+
PACKAGE=utreexod
26+
MAINDIR=$PACKAGE-$TAG
27+
mkdir -p $MAINDIR
28+
29+
cp vendor.tar.gz $MAINDIR/
30+
rm vendor.tar.gz
31+
rm -r vendor
32+
33+
PACKAGESRC="$MAINDIR/$PACKAGE-source-$TAG.tar"
34+
git archive -o $PACKAGESRC HEAD
35+
gzip -f $PACKAGESRC > "$PACKAGESRC.gz"
36+
37+
cd $MAINDIR
38+
39+
SYS=
40+
41+
if [[ $(uname) == Linux ]]; then
42+
# If BTCDBUILDSYS is set the default list is ignored. Useful to release
43+
# for a subset of systems/architectures.
44+
SYS=${BTCDBUILDSYS:-"
45+
linux-armv6
46+
linux-armv7
47+
linux-arm64
48+
linux-amd64
49+
windows-amd64
50+
"}
51+
elif [[ $(uname) == Darwin ]]; then
52+
# If BTCDBUILDSYS is set the default list is ignored. Useful to release
53+
# for a subset of systems/architectures.
54+
SYS=${BTCDBUILDSYS:-"
55+
darwin-amd64
56+
darwin-arm64
57+
"}
58+
fi
59+
60+
CPUCORES=
61+
if [[ $(uname) == Linux ]]; then
62+
CPUCORES=$(lscpu | grep "Core(s) per socket" | awk '{print $4}')
63+
elif [[ $(uname) == Darwin ]]; then
64+
CPUCORES=$(sysctl -n hw.physicalcpu)
65+
fi
66+
67+
# Use the first element of $GOPATH in the case where GOPATH is a list
68+
# (something that is totally allowed).
69+
PKG="github.com/utreexo/utreexod"
70+
COMMIT=$(git describe --tags --abbrev=40 --dirty)
71+
72+
for i in $SYS; do
73+
OS=$(echo $i | cut -f1 -d-)
74+
ARCH=$(echo $i | cut -f2 -d-)
75+
ARM=
76+
CC=
77+
78+
if [[ $ARCH = "armv6" ]]; then
79+
ARCH=arm
80+
ARM=6
81+
elif [[ $ARCH = "armv7" ]]; then
82+
ARCH=arm
83+
ARM=7
84+
fi
85+
86+
mkdir $PACKAGE-$i-$TAG
87+
echo "cd to" $PACKAGE-$i-$TAG
88+
cd $PACKAGE-$i-$TAG
89+
90+
# Build bdk wallet(rust) dependency.
91+
if [[ $ARCH = "arm64" ]] && [[ $OS = "linux" ]]; then
92+
TARGET="aarch64-unknown-linux-musl"
93+
CC=aarch64-linux-musl-gcc
94+
95+
elif [[ $ARCH = "amd64" ]] && [[ $OS = "linux" ]]; then
96+
TARGET="x86_64-unknown-linux-musl"
97+
CC=x86_64-linux-musl-gcc
98+
99+
elif [[ $ARCH = "arm" ]] && [[ $OS = "linux" ]] && [[ $ARM=7 ]]; then
100+
TARGET="armv7-unknown-linux-musleabihf"
101+
CC=armv7l-linux-musleabihf-gcc
102+
103+
elif [[ $ARCH = "arm" ]] && [[ $OS = "linux" ]] && [[ $ARM=6 ]]; then
104+
TARGET="armv6-unknown-linux-musleabihf"
105+
CC=armv6-linux-musleabihf-gcc
106+
107+
elif [[ $ARCH = "arm64" ]] && [[ $OS = "darwin" ]]; then
108+
TARGET="aarch64-apple-darwin"
109+
110+
elif [[ $ARCH = "amd64" ]] && [[ $OS = "darwin" ]]; then
111+
TARGET="x86_64-apple-darwin"
112+
113+
elif [[ $ARCH = "amd64" ]] && [[ $OS = "windows" ]]; then
114+
TARGET="x86_64-pc-windows-gnu"
115+
CC=x86_64-w64-mingw32-gcc
116+
fi
117+
118+
env CARGO_TARGET_DIR=. cargo build --release --target=$TARGET --jobs=$CPUCORES
119+
mv $TARGET target
120+
121+
echo "Building:" $OS $ARCH $ARM
122+
123+
# Build utreexod
124+
if [[ $OS == "linux" ]]; then
125+
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
126+
elif [[ $OS == "darwin" ]]; then
127+
env CGO_ENABLED=1 GOOS=$OS GOARCH=$ARCH GOARM=$ARM go build -v -tags="bdkwallet" -ldflags="-s -w -buildid=" github.com/utreexo/utreexod
128+
fi
129+
130+
# Remove bdk build things.
131+
rm -rf target
132+
rm -rf release
133+
134+
# Build utreexoctl
135+
env CGO_ENABLED=0 GOOS=$OS GOARCH=$ARCH GOARM=$ARM go build -v -trimpath -ldflags="-s -w -buildid=" github.com/utreexo/utreexod/cmd/utreexoctl
136+
137+
cd ..
138+
139+
if [[ $OS = "windows" ]]; then
140+
zip -r $PACKAGE-$i-$TAG.zip $PACKAGE-$i-$TAG
141+
else
142+
tar -cvzf $PACKAGE-$i-$TAG.tar.gz $PACKAGE-$i-$TAG
143+
fi
144+
145+
rm -r $PACKAGE-$i-$TAG
146+
done
147+
148+
shasum -a 256 * > manifest-$TAG.txt

0 commit comments

Comments
 (0)