mirror of
https://code.forgejo.org/actions/setup-forgejo.git
synced 2024-11-27 08:40:57 -05:00
42 lines
861 B
Bash
42 lines
861 B
Bash
#!/bin/bash
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
set -ex
|
|
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
|
|
function dependency_go() {
|
|
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"
|
|
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"
|
|
}
|