2023-01-13 15:54:01 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2022-12-02 14:08:30 +00:00
|
|
|
MAKE_DIR=$(mktemp -d)
|
|
|
|
DESTINATION=~/gitea-binaries/
|
|
|
|
|
|
|
|
mkdir -p $DESTINATION
|
|
|
|
cd $MAKE_DIR
|
|
|
|
|
2023-11-21 12:43:59 +00:00
|
|
|
while getopts 'v:g:n:' flag
|
|
|
|
do
|
|
|
|
case "${flag}" in
|
|
|
|
v) GITEA_GIT_TAG=${OPTARG};; # Gitea Git Tag
|
|
|
|
g) GO_VERSION=${OPTARG};; # GOLANG Version
|
|
|
|
n) NODEJS_VERSION=${OPTARG};; # NodeJS Version
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
if [[ -n $NODEJS_VERSION ]]
|
|
|
|
then
|
|
|
|
NODEJS_VERSION=v20.3.1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -n $GO_VERSION ]]
|
|
|
|
then
|
|
|
|
GO_VERSION=1.20.5
|
|
|
|
fi
|
|
|
|
|
|
|
|
# GITEA_GIT_TAG is being process below
|
2023-01-11 13:10:08 +00:00
|
|
|
|
2023-01-13 15:48:37 +00:00
|
|
|
# Install Dependencies
|
|
|
|
|
2023-01-13 16:01:50 +00:00
|
|
|
sudo apt-get update && sudo apt-get install xz-utils wget git tar g++ make -y
|
2023-01-13 15:48:37 +00:00
|
|
|
|
2022-12-02 14:08:30 +00:00
|
|
|
# NodeJS
|
|
|
|
DISTRO=linux-x64
|
|
|
|
|
2023-11-21 12:43:59 +00:00
|
|
|
wget https://nodejs.org/dist/$NODEJS_VERSION/node-$NODEJS_VERSION-$DISTRO.tar.xz
|
2022-12-02 14:08:30 +00:00
|
|
|
sudo mkdir -p /usr/local/lib/nodejs
|
2023-11-21 12:43:59 +00:00
|
|
|
sudo tar -xJvf node-$NODEJS_VERSION-$DISTRO.tar.xz -C /usr/local/lib/nodejs
|
|
|
|
export PATH=/usr/local/lib/nodejs/node-$NODEJS_VERSION-$DISTRO/bin:$PATH
|
2022-12-02 14:08:30 +00:00
|
|
|
. ~/.profile
|
|
|
|
|
|
|
|
# Golang
|
|
|
|
sudo unlink /usr/bin/go
|
|
|
|
wget https://go.dev/dl/go$GO_VERSION.linux-amd64.tar.gz
|
|
|
|
sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go$GO_VERSION.linux-amd64.tar.gz
|
|
|
|
export PATH=$PATH:/usr/local/go/bin
|
|
|
|
sudo ln -s /usr/local/go/bin /usr/bin/go
|
|
|
|
|
|
|
|
# Gitea
|
|
|
|
|
2023-01-11 13:10:08 +00:00
|
|
|
# GIT_TAG=
|
|
|
|
# specify the tag which gitea will build on
|
|
|
|
|
|
|
|
git clone https://github.com/go-gitea/gitea
|
2022-12-02 13:52:57 +00:00
|
|
|
cd gitea
|
2023-01-11 13:10:08 +00:00
|
|
|
|
2023-11-21 12:43:59 +00:00
|
|
|
if [[ -n $GITEA_GIT_TAG ]]
|
2023-01-11 13:10:08 +00:00
|
|
|
then
|
2023-11-21 12:43:59 +00:00
|
|
|
if git show-ref $GITEA_GIT_TAG --quiet; then
|
|
|
|
git checkout $GITEA_GIT_TAG
|
2023-01-11 13:10:08 +00:00
|
|
|
else
|
2023-07-27 16:00:22 +00:00
|
|
|
echo -e "\nGIT_TAG variable doesn't match the repo tag/version. exit to prevent further issue." && exit 1 && rm -rf $MAKE_DIR
|
2023-01-11 13:10:08 +00:00
|
|
|
fi
|
|
|
|
else
|
2023-07-27 16:00:22 +00:00
|
|
|
echo -e "GIT_TAG variable not found. will build on "main" branch."
|
2023-01-11 13:10:08 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
LDFLAGS="-X \"code.gitea.io/gitea/modules/setting.AppWorkPath=/var/lib/gitea/\" -X \"code.gitea.io/gitea/modules/setting.CustomConf=/etc/gitea/app.ini\"" TAGS="bindata sqlite sqlite_unlock_notify" GOOS=linux GOARCH=amd64 make build
|
2022-12-02 13:52:57 +00:00
|
|
|
mv gitea $DESTINATION/gitea
|
2022-12-02 14:08:30 +00:00
|
|
|
|
|
|
|
# Cleanup
|
2023-01-11 13:10:08 +00:00
|
|
|
|
2022-12-02 13:52:57 +00:00
|
|
|
rm -rf $MAKE_DIR
|