Skip to content

Instantly share code, notes, and snippets.

@maestre3d
Created June 17, 2022 04:57
Show Gist options
  • Save maestre3d/5e443474f8764734bce73dc3401e982f to your computer and use it in GitHub Desktop.
Save maestre3d/5e443474f8764734bce73dc3401e982f to your computer and use it in GitHub Desktop.
Force a Go package publishing using pure Curl and shell commands.
#!/bin/bash
while getopts ":v:" opt; do
case $opt in
v) VERSION_TAG=$OPTARG;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
MAJOR_VERSION=""
VERSION_PREFIX=""
if [ "${#VERSION_TAG}" -ge 2 ]
then
VERSION_PREFIX="${VERSION_TAG:0:2}"
fi
if [ "$VERSION_PREFIX" != "" ] && [ "$VERSION_PREFIX" != "v0" ] && [ "$VERSION_PREFIX" != "v1" ]
then
MAJOR_VERSION="/$VERSION_PREFIX"
fi
GO_PROXY_URL=https://proxy.golang.org/github.com/REPO_OWNER_USERNAME/REPO_NAME"$MAJOR_VERSION"/@v/"$VERSION_TAG".info
echo "forcing package publishing using URL: $GO_PROXY_URL"
curl "$GO_PROXY_URL"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment