zig/ci/drone/linux_script
Andrew Kelley 5c92e24a29 drone ci: skip compile error tests to save time
These are covered by other CI scripts and we're up against Drone CI time
limits.
2021-01-03 20:10:07 -07:00

61 lines
1.7 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
git fetch --unshallow || true
git fetch --tags
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 -Dskip-compile-errors
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