git describe is used for version string creation, but it had to be
reverted in commit 69da6ba because it was broken in CI builds.
Azure Pipelines and Drone perform shallow clones by default.
This change reconfigures them to fetch history and tags. It adds tens of
seconds, which is negligible compared to overall build and test time.
Related: #6466, #6509, #7601
61 lines
1.7 KiB
Bash
Executable File
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
|
|
|
|
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
|