setup-forgejo/forgejo-runner-lib.sh

43 lines
861 B
Bash
Raw Normal View History

#!/bin/bash
# SPDX-License-Identifier: MIT
set -ex
export DEBIAN_FRONTEND=noninteractive
function dependency_go() {
2023-11-09 10:02:08 -05:00
go_version="1.21.4.linux-amd64" # Set the desired Go version here
if ! which wget tar > /dev/null ; then
apt-get install -y -qq wget tar
fi
if ! which go > /dev/null ; then
wget --quiet "https://go.dev/dl/go$go_version.tar.gz"
tar zxf "go$go_version.tar.gz"
export PATH="$(pwd)/go/bin:$PATH"
fi
}
function checkout() {
local git="$1"
2023-11-04 09:44:18 -04:00
git clone $git forgejo-runner
}
function build_runner() {
local git="$1"
local version="${2:-main}"
local dir=$(mktemp -d)
(
cd $dir
checkout "$git"
dependency_go
cd forgejo-runner
git checkout "$version"
make build
)
mv $dir/forgejo-runner/forgejo-runner /usr/local/bin
forgejo-runner --version
rm -fr "$dir"
}