added support for ghcr

This commit is contained in:
Swarup Sengupta
2025-11-29 01:20:08 +05:30
parent bcd2ec9b5a
commit a7f27f9da9
+31 -3
View File
@@ -12,6 +12,8 @@ function help_message() {
echo " --targets, -t <targets> Comma-separated list of target platforms (default: current, use 'all' for all supported targets)" echo " --targets, -t <targets> Comma-separated list of target platforms (default: current, use 'all' for all supported targets)"
echo " --version, -v <version> Psiphon version to build (default: latest available)" echo " --version, -v <version> Psiphon version to build (default: latest available)"
echo " --go, -g <version> Go version to use (default: 1.22.7)" echo " --go, -g <version> Go version to use (default: 1.22.7)"
echo " --nodockerhub Don't push image to docker.io"
echo " --noghcr Don't push image to gchr.io"
echo " --load Load the built image into local Docker (cannot be used with --push)" echo " --load Load the built image into local Docker (cannot be used with --push)"
echo " --push Push the built image to Docker Hub (cannot be used with --load)" echo " --push Push the built image to Docker Hub (cannot be used with --load)"
echo " --supported-targets Show supported targets and exit" echo " --supported-targets Show supported targets and exit"
@@ -22,6 +24,8 @@ function help_message() {
EXTRA_BUILD_ARGS="" EXTRA_BUILD_ARGS=""
VERSION="" VERSION=""
PUSH_DOCKERHUB=1
PUSH_GHCR=1
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
case "$1" in case "$1" in
@@ -52,6 +56,14 @@ while [[ $# -gt 0 ]]; do
GO_VERSION="$2" GO_VERSION="$2"
shift 2 shift 2
;; ;;
--nodockerhub)
PUSH_DOCKERHUB=0
shift
;;
--noghcr)
PUSH_GHCR=0
shift
;;
--supported-targets) --supported-targets)
echo "Supported targets: $(get_supported_targets)" echo "Supported targets: $(get_supported_targets)"
exit 0 exit 0
@@ -83,6 +95,11 @@ while [[ $# -gt 0 ]]; do
esac esac
done done
if [[ "${PUSH_GHCR}" == "0" && "${PUSH_DOCKERHUB}" == "0" && "${EXTRA_BUILD_ARGS}" == "--push" ]]; then
echo "Cannot disable both ghcr and dockerhub with --push"
help_message
fi
TARGETS=${TARGETS:-"current"} TARGETS=${TARGETS:-"current"}
GO_VERSION=${GO_VERSION:-1.22.7} GO_VERSION=${GO_VERSION:-1.22.7}
@@ -107,9 +124,20 @@ fi
DECIPHERED_TARGETS=$(decipher_targets "${TARGETS}") DECIPHERED_TARGETS=$(decipher_targets "${TARGETS}")
docker buildx build \ TAGS=()
if [[ "${PUSH_DOCKERHUB}" == "1" ]]; then
TAGS+=(-t swarupsengupta2007/psiphon:"${VERSION#v}")
TAGS+=(-t swarupsengupta2007/psiphon:latest)
fi
if [[ "${PUSH_GHCR}" == "1" ]]; then
TAGS+=(-t ghcr.io/swarupsengupta2007/psiphon:"${VERSION#v}")
TAGS+=(-t ghcr.io/swarupsengupta2007/psiphon:latest)
fi
echo docker buildx build \
"${DOCKER_BUILD_ARGS[@]}" \ "${DOCKER_BUILD_ARGS[@]}" \
-t swarupsengupta2007/psiphon:"${VERSION#v}" \ "${TAGS[@]}" \
-t swarupsengupta2007/psiphon:latest \
--platform "${DECIPHERED_TARGETS}" . \ --platform "${DECIPHERED_TARGETS}" . \
${EXTRA_BUILD_ARGS} ${EXTRA_BUILD_ARGS}