Files
Gitea/tools/build-release.sh
T
silverwind ad38b60983 refactor!: remove go-git backend (#39487)
Removes the go-git backend so every build uses the git CLI backend. Its
Windows performance advantage is gone, it lacks SHA-256 support, and it
breaks repositories on Windows.

The performance changes moved to
https://github.com/go-gitea/gitea/pull/39526.

Fixes https://github.com/go-gitea/gitea/issues/38359
Fixes https://github.com/go-gitea/gitea/issues/34694

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2026-10-03 10:04:24 +00:00

55 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
GO="${GO:-go}"
RELEASE_LDFLAGS="-s -w $LDFLAGS"
RELEASE_TAGS="bindata $TAGS"
RELEASE_PATH_PREFIX="${DIST}/binaries/gitea-${VERSION##*/}"
RELEASE_PLATFORMS_DEFAULT=(
linux/amd64 linux/arm-5 linux/arm-6 linux/arm64 linux/riscv64 \
windows/amd64 windows/arm64 \
darwin/amd64 darwin/arm64 \
freebsd/amd64
)
build() {
echo "building ${*} ..."
local target="${1:?}"
local goos="${target%%/*}"
local goarch="${target##*/}"
local goarm=""
if [[ "$goarch" == arm-* ]]; then
goarm="${goarch#arm-}"
goarch="arm"
fi
local output="${RELEASE_PATH_PREFIX}-${target//\//-}"
local args=()
if [[ "$goos" == "windows" ]]; then
output="${output}.exe"
fi
args+=(-tags "$RELEASE_TAGS")
args+=(-ldflags "$RELEASE_LDFLAGS")
echo " args: ${args[*]}"
echo " output: ${output}"
# must disable CGO (host compiler & linker) to get host-independent static builds
CGO_ENABLED=0 GOOS="$goos" GOARCH="$goarch" GOARM="$goarm" "$GO" build "${args[@]}" -o "$output" .
}
main() {
# When building release binaries, some TAGS (bindata) are needed by the release script,
# so here it needs to use the TAGS to generate the assets (embed bindata).
echo "generating assets with tags=${RELEASE_TAGS}"
"$GO" generate -tags "${RELEASE_TAGS}" ./...
local platform="${1:-}"
for target in "${RELEASE_PLATFORMS_DEFAULT[@]}"; do
if [[ -z "$platform" || "$target" == "$platform/"* ]]; then
build "$target"
fi
done
}
main "$@"