1#!/bin/bash
2# Publishes artifacts from a Travis CI build.
3#
4# Copyright (C) 2019 Peter Wu <peter@lekensteyn.nl>
5# SPDX-License-Identifier: GPL-2.0-or-later
6#
7# Currently it dumps a base64-encoded xz-compressed tarball as Travis CI
8# does not have a nice way to publish artifacts (like Gitlab does).
9#
10
11shopt -s nullglob
12files=(*screenshot.png)
13
14if [ ${#files[@]} -eq 0 ]; then
15    echo "No artifacts found"
16    exit
17fi
18
19output=travis.tar.xz
20tar -cJvf "$output" "${files[@]}"
21
22# Print some details for an integrity check.
23ls -l "$output"
24openssl dgst -sha256 "$output"
25
26# Upload to other services just in case the log output is corrupted.
27curl -F 'f:1=<-' ix.io < "$output"
28
29# Dump the contents to the log (note: Travis has a 4MiB limit)
30cat <<EOF
31base64 -d > $output <<ARTIFACTS_BASE64
32$(base64 < "$output" | tr -d '\n' | fold -w200)
33ARTIFACTS_BASE64
34EOF
35