Sam Therapy
317c157dac
All checks were successful
pkgcheck / build (push) Successful in 1m2s
Signed-off-by: Sam Therapy <sam@samtherapy.net>
52 lines
1.1 KiB
Bash
Executable file
52 lines
1.1 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
set -eo pipefail
|
|
|
|
# These variables should be set per-instance.
|
|
# PLEASE CHANGE THEM.
|
|
GITEA_URL="https://git.froth.zone"
|
|
OWNER="packaging"
|
|
USER="oauth2" # Can be set to your username if you're not using a token.
|
|
PACKAGER_NAME="portage"
|
|
PACKAGER_VERSION="deps"
|
|
|
|
[[ $# -ne 2 ]] && {
|
|
echo "Usage: $0 <package> <tag>"
|
|
exit 1
|
|
}
|
|
|
|
PACKAGE_NAME=$1
|
|
PACKAGE_TAG=$2
|
|
|
|
|
|
if [[ -z "${GITEA_TOKEN}" ]]; then
|
|
if [[ -z "${GITHUB_TOKEN}" ]]; then
|
|
echo "Please set \$GITEA_TOKEN."
|
|
exit 1
|
|
fi
|
|
GITEA_TOKEN=${GITHUB_TOKEN}
|
|
fi
|
|
|
|
curl https://github.com/$PACKAGE_NAME/archive/$PACKAGE_TAG.tar.gz -L -O
|
|
|
|
|
|
PKG=${PACKAGE_NAME##*/}-${PACKAGE_TAG//v/}
|
|
|
|
tar -xzf "$PACKAGE_TAG".tar.gz
|
|
rm "$PACKAGE_TAG".tar.gz
|
|
|
|
cd "$PKG" || exit 1
|
|
|
|
if [[ -f go.mod ]]; then
|
|
go mod vendor
|
|
cd .. || exit 1
|
|
tar --create --auto-compress --file "$PKG"-vendor.tar.xz "$PKG"/vendor
|
|
rm -rf "$PKG"
|
|
curl --user $USER:"$GITEA_TOKEN" --upload-file ./"$PKG"-vendor.tar.xz $GITEA_URL/api/packages/$OWNER/generic/$PACKAGER_NAME/$PACKAGER_VERSION/"$PKG"-vendor.tar.xz
|
|
echo "Uploaded $PKG-vendor.tar.xz!"
|
|
rm "$PKG"-vendor.tar.xz
|
|
exit 0
|
|
else
|
|
echo "This package does not have a go.mod file."
|
|
exit 1
|
|
fi
|