build_gitea: add: custom destination and use system binary

This commit is contained in:
minoplhy 2025-01-23 23:03:34 +07:00
parent d6fefa5932
commit 09ad9fc2bf
Signed by: minoplhy
GPG Key ID: 41D406044E2434BF
2 changed files with 37 additions and 20 deletions

View File

@ -1,10 +1,5 @@
#!/bin/bash #!/bin/bash
DESTINATION=~/gitea-binaries
rm -rf $DESTINATION
mkdir -p $DESTINATION
while [ ${#} -gt 0 ]; do while [ ${#} -gt 0 ]; do
case "$1" in case "$1" in
--git-tag | -v) --git-tag | -v)
@ -19,9 +14,16 @@ while [ ${#} -gt 0 ]; do
shift shift
NODEJS_VERSION=$1 NODEJS_VERSION=$1
;; # NodeJS Version ;; # NodeJS Version
--dest | -d )
shift
DESTINATION=$1
;; # Destination Dir
--static | -s) --static | -s)
BUILD_STATIC=true BUILD_STATIC=true
;; # Also Build Static Assets file ;; # Also Build Static Assets file
--system | -s)
USE_SYSTEM=true
;; # Use system's NPM and Go
--type=* ) --type=* )
BUILD_TYPE="${1#*=}" BUILD_TYPE="${1#*=}"
BUILD_TYPE="${BUILD_TYPE,,}" BUILD_TYPE="${BUILD_TYPE,,}"
@ -74,6 +76,11 @@ done
NODEJS_VERSION=${NODEJS_VERSION:-"v20.17.0"} NODEJS_VERSION=${NODEJS_VERSION:-"v20.17.0"}
GO_VERSION=${GO_VERSION:-"1.23.2"} GO_VERSION=${GO_VERSION:-"1.23.2"}
BUILD_TYPE=${BUILD_TYPE:-"gitea"} BUILD_TYPE=${BUILD_TYPE:-"gitea"}
DESTINATION=${DESTINATION:-"~/gitea-binaries"}
# Clean up old build
rm -rf $DESTINATION
mkdir -p $DESTINATION
# OS # OS
GOOS=linux GOOS=linux
@ -146,6 +153,8 @@ case $DISTRO in
;; ;;
esac esac
# This part will be skip if USE_SYSTEM=true
if [[ ! "${USE_SYSTEM}" == true ]]; then
# NodeJS # NodeJS
case $DISTRO in case $DISTRO in
"alpine") "alpine")
@ -162,6 +171,7 @@ esac
wget https://go.dev/dl/go$GO_VERSION.$GOOS-$BASE_GOARCH.tar.gz -O $DESTINATION/go$GO_VERSION.$GOOS-$BASE_GOARCH.tar.gz wget https://go.dev/dl/go$GO_VERSION.$GOOS-$BASE_GOARCH.tar.gz -O $DESTINATION/go$GO_VERSION.$GOOS-$BASE_GOARCH.tar.gz
tar -C $DESTINATION -xzf $DESTINATION/go$GO_VERSION.$GOOS-$BASE_GOARCH.tar.gz tar -C $DESTINATION -xzf $DESTINATION/go$GO_VERSION.$GOOS-$BASE_GOARCH.tar.gz
export PATH=$PATH:$DESTINATION/go/bin export PATH=$PATH:$DESTINATION/go/bin
fi
# Gitea # Gitea

View File

@ -27,9 +27,16 @@ while [ ${#} -gt 0 ]; do
shift shift
NODEJS_VERSION=$1 NODEJS_VERSION=$1
;; # NodeJS Version ;; # NodeJS Version
--dest | -d )
shift
DESTINATION=$1
;; # Destination Dir
--static | -s) --static | -s)
BUILD_STATIC=true BUILD_STATIC=true
;; # Also Build Static Assets file ;; # Also Build Static Assets file
--system | -s)
USE_SYSTEM=true
;; # Use system's NPM and Go
--type=* ) --type=* )
BUILD_TYPE="${1#*=}" BUILD_TYPE="${1#*=}"
BUILD_TYPE="${BUILD_TYPE,,}" BUILD_TYPE="${BUILD_TYPE,,}"