Make the build work
This commit was merged in pull request #12.
This commit is contained in:
50
scripts/create_release_artifacts.sh
Executable file
50
scripts/create_release_artifacts.sh
Executable file
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env bash
|
||||
# vim: set expandtab shiftwidth=4 softtabstop=4 tabstop=4 :
|
||||
set -euo pipefail
|
||||
|
||||
if [ -z "${CI_COMMIT_TAG:-}" ]; then
|
||||
echo "No commit tag set"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DIR=$(realpath $(dirname "${BASH_SOURCE[0]}") )
|
||||
|
||||
echo ${DIR}
|
||||
|
||||
${DIR}/install_tea.sh linux-amd64 https://gitea.com/api/v1/repos/gitea/tea/releases/latest
|
||||
|
||||
## Log in to Gitea
|
||||
|
||||
TEA=$(pwd)/tea
|
||||
|
||||
if [ -z "${GITEA_SERVER_URL:-}" ]; then
|
||||
|
||||
if [ -z "${CI_FORGE_URL:-}" ]; then
|
||||
echo "Cannot log in to gitea: GITEA_SERVER_URL or CI_FORGE_URL missing"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
GITEA_SERVER_URL=${CI_FORGE_URL}
|
||||
fi
|
||||
|
||||
if [ -z "${GITEA_SERVER_TOKEN:-}" ]; then
|
||||
echo "Cannot log in to gitea: GITEA_SERVER_TOKEN missing"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! ${TEA} login ls | grep ${GITEA_SERVER_URL} 2>&1 > /dev/null || false; then
|
||||
${TEA} login add
|
||||
else
|
||||
echo "Already logged in to ${GITEA_SERVER_URL}"
|
||||
fi
|
||||
|
||||
## Check and create tag
|
||||
|
||||
if ${TEA} release ls -o json | jq -e --arg tag "${CI_COMMIT_TAG}" 'map(.["tag-_name"]) | index($tag) != null' >/dev/null; then
|
||||
echo "Release ${CI_COMMIT_TAG} exists"
|
||||
else
|
||||
echo "Creating release ${CI_COMMIT_TAG}"
|
||||
${TEA} release create -o json --tag "${CI_COMMIT_TAG}" --title "${CI_COMMIT_TAG}" --draft
|
||||
fi
|
||||
|
||||
find $(dirname ${DIR})/artifacts -type f -exec ${TEA} releases assets create -o json ${CI_COMMIT_TAG} {} +
|
||||
39
scripts/install_tea.sh
Executable file
39
scripts/install_tea.sh
Executable file
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail
|
||||
|
||||
if [ -x ./tea ]; then
|
||||
echo "tea already installed in current directory"; exit 0
|
||||
fi
|
||||
|
||||
platform="${1:-linux-amd64}"
|
||||
src="${2:-release.json}"
|
||||
|
||||
# obtain JSON: if src looks like a URL fetch it, otherwise treat as filename (or default file)
|
||||
if [[ "$src" =~ ^https?:// ]]; then
|
||||
curl -fsSL "$src" -o /tmp/release.json.$$
|
||||
json="/tmp/release.json.$$"
|
||||
trap 'rm -f "$json"' EXIT
|
||||
elif [ -f "$src" ]; then
|
||||
json="$src"
|
||||
else
|
||||
echo "release JSON not found; provide a filename or URL as second arg" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# read tag and find binary URL (exclude archives/checksums/sigs)
|
||||
tag=$(jq -r '.tag_name' "$json")
|
||||
url=$(jq -r --arg p "$platform" '.assets[]
|
||||
| select(.name | test($p))
|
||||
| select(.name | test("\\.(xz|zip|gz|tar|bz2|7z|sha256|sha256sum|sig|asc)$") | not)
|
||||
| .browser_download_url' "$json" | head -n1)
|
||||
|
||||
[ -n "$url" ] || { echo "binary not found for $platform" >&2; exit 1; }
|
||||
|
||||
tmp="$(mktemp)"
|
||||
trap 'rm -f "$tmp"' EXIT
|
||||
|
||||
curl -fsSL "$url" -o "$tmp"
|
||||
mv "$tmp" tea
|
||||
chmod +x tea
|
||||
echo "Downloaded tag ${tag}: $url -> ./tea"
|
||||
|
||||
Reference in New Issue
Block a user