Skip to content

Instantly share code, notes, and snippets.

@bertptrs
Created October 31, 2019 17:38
Show Gist options
  • Save bertptrs/17f5b9fc41d56d7f8493215eec5ef752 to your computer and use it in GitHub Desktop.
Save bertptrs/17f5b9fc41d56d7f8493215eec5ef752 to your computer and use it in GitHub Desktop.
#!/bin/bash
get_latest_release() {
curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api
grep '"tag_name":' | # Get tag line
sed -E 's/.*"v([^"]+)".*/\1/' # Pluck JSON value
}
VERSION=$(get_latest_release "go-gitea/gitea")
if test -z "$VERSION"
then
echo "Invalid version: $VERSION"
exit 1
else
echo "Newest version: $VERSION"
read -p "Press <enter> to install."
fi
# Create a temporary directory for our adventures
WORKDIR="$(mktemp -d)"
trap "rm -r '$WORKDIR'" EXIT
set -e
cd "$WORKDIR"
FILENAME="gitea-$VERSION-linux-amd64"
wget "https://dl.gitea.io/gitea/$VERSION/$FILENAME"{,.asc}
gpg --verify "$FILENAME".asc
systemctl stop gitea
install -m0755 -o root "$FILENAME" /usr/local/bin/gitea
systemctl start gitea
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment