mirror of
https://code.forgejo.org/actions/setup-forgejo.git
synced 2024-11-27 16:51:00 -05:00
43 lines
860 B
Bash
43 lines
860 B
Bash
|
#!/bin/bash
|
||
|
# SPDX-License-Identifier: MIT
|
||
|
|
||
|
set -ex
|
||
|
|
||
|
export DEBIAN_FRONTEND=noninteractive
|
||
|
|
||
|
function dependency_go() {
|
||
|
go_version="1.21.3.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 --depth 1 $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 .
|
||
|
./forgejo-runner --version
|
||
|
rm -fr "$dir"
|
||
|
}
|