zig/ci/drone/linux_script
2020-05-29 13:34:15 -04:00

59 lines
1.6 KiB
Bash
Executable File

#!/bin/sh
set -x
set -e
TRIPLEARCH="$(uname -m)"
BUILDDIR="$(pwd)"
DISTDIR="$(pwd)/dist"
apk update
apk add py3-pip xz perl-utils jq curl samurai
pip3 install s3cmd
# Make the `zig version` number consistent.
# This will affect the cmake command below.
git config core.abbrev 9
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release "-DCMAKE_INSTALL_PREFIX=$DISTDIR" -DZIG_STATIC=ON -DCMAKE_PREFIX_PATH=/deps/local -GNinja
samu install
./zig build test -Dskip-release -Dskip-non-native
if [ -z "$DRONE_PULL_REQUEST" ]; then
mv ../LICENSE "$DISTDIR/"
mv ../zig-cache/langref.html "$DISTDIR/"
mv "$DISTDIR/bin/zig" "$DISTDIR/"
rmdir "$DISTDIR/bin"
GITBRANCH="$DRONE_BRANCH"
VERSION="$("$DISTDIR/zig" version)"
DIRNAME="zig-linux-$TRIPLEARCH-$VERSION"
TARBALL="$DIRNAME.tar.xz"
mv "$DISTDIR" "$DIRNAME"
tar cfJ "$TARBALL" "$DIRNAME"
s3cmd put -P --add-header="cache-control: public, max-age=31536000, immutable" "$TARBALL" s3://ziglang.org/builds/
SHASUM=$(shasum -a 256 $TARBALL | cut '-d ' -f1)
BYTESIZE=$(wc -c < $TARBALL)
JSONFILE="$TRIPLEARCH-linux-$GITBRANCH.json"
touch $JSONFILE
echo "{\"tarball\": \"$TARBALL\"," >>$JSONFILE
echo "\"shasum\": \"$SHASUM\"," >>$JSONFILE
echo "\"size\": \"$BYTESIZE\"}" >>$JSONFILE
s3cmd put -P --add-header="Cache-Control: max-age=0, must-revalidate" "$JSONFILE" "s3://ziglang.org/builds/$JSONFILE"
s3cmd put -P "$JSONFILE" "s3://ziglang.org/builds/$TRIPLEARCH-linux-$VERSION.json"
if [ "$GITBRANCH" = "master" ]; then
# avoid leaking oauth token
set +x
cd "$BUILDDIR"
./ci/srht/on_master_success "$VERSION" "$SRHT_OAUTH_TOKEN"
fi
fi