-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Build releases in a consistent Docker container environment. - Drop PE timestamps in Windows exe builds. - Pack tar.gz/zip archives with static/removed metadata attrs and stable file ordering.
- Loading branch information
Showing
6 changed files
with
108 additions
and
45 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
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
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,66 @@ | ||
#!/bin/bash | ||
set -xeo pipefail | ||
|
||
build() { | ||
name=$1; platform=$2; features=$3 | ||
ext=$([[ $platform != *"-windows-"* ]] || echo .exe) | ||
dest=dist/$name | ||
mkdir -p $dest | ||
|
||
echo Building $name for $platform with features $features | ||
|
||
# drop PE timestamps in windows builds for reproducibility (https://wiki.debian.org/ReproducibleBuilds/TimestampsInPEBinaries#building_with_mingw-w64) | ||
RUSTFLAGS="$RUSTFLAGS $([[ $platform != *"-windows-"* ]] || echo '-Clink-arg=-Wl,--no-insert-timestamp')" \ | ||
cargo build --release --target $platform --no-default-features --features "$features" | ||
|
||
mv target/$platform/release/bwt$ext $dest | ||
strip $dest/bwt$ext | ||
|
||
cp README.md LICENSE $dest/ | ||
|
||
pack $name | ||
} | ||
|
||
# pack an tar.gz/zip archive file, with fixed/removed metadata attrs and deterministic file order for reproducibility | ||
pack() { | ||
name=$1; dir=${2:-$1} | ||
pushd dist | ||
touch -t 1711081658 $name $name/* | ||
if [[ $name == *"-linux" ]]; then | ||
TZ=UTC tar --mtime='2017-11-08 16:58:00' --owner=0 --sort=name -I 'gzip --no-name' -chf $name.tar.gz $dir | ||
else | ||
find -H $dir | sort | xargs zip -X -q $name.zip | ||
fi | ||
popd | ||
} | ||
|
||
version=`cat Cargo.toml | egrep '^version =' | cut -d'"' -f2` | ||
|
||
rm -rf dist/* | ||
|
||
for target in linux,x86_64-unknown-linux-gnu \ | ||
win,x86_64-pc-windows-gnu; do | ||
IFS=',' read pnick platform <<< $target | ||
|
||
build bwt-$version-x86_64-$pnick $platform http,electrum,webhooks,track-spends | ||
build bwt-$version-electrum_only-x86_64-$pnick $platform electrum | ||
done | ||
|
||
echo Building electrum plugin | ||
for pnick in linux win; do | ||
name=bwt-$version-electrum_plugin-x86_64-$pnick | ||
dest=dist/$name | ||
mkdir $dest | ||
cp contrib/electrum-plugin/*.py $dest | ||
cp dist/bwt-$version-electrum_only-x86_64-$pnick/* $dest | ||
# needs to be inside a directory with a name that matches the plugin module name for electrum to load it, | ||
# create a temporary link to get tar/zip to pack it properly. (can also be done for tar.gz with --transform) | ||
ln -s $name dist/bwt | ||
pack $name bwt | ||
rm dist/bwt | ||
done | ||
|
||
# remove subdirectories, keep release tarballs | ||
rm -r dist/*/ | ||
|
||
[ -n "$OWNER" ] && chown -R $OWNER dist || true |
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 @@ | ||
FROM rust:1.46-slim as builder | ||
RUN apt-get update && apt-get install -y pkg-config libssl-dev gcc-mingw-w64-x86-64 zip && \ | ||
rustup target add x86_64-pc-windows-gnu | ||
|
||
WORKDIR /usr/src/bwt | ||
COPY Cargo.toml Cargo.lock ./ | ||
RUN mkdir src .cargo && touch src/lib.rs src/main.rs && \ | ||
cargo vendor > .cargo/config | ||
|
||
VOLUME /usr/src/bwt | ||
ENTRYPOINT [ "/usr/src/bwt/scripts/build.sh" ] |
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
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