1
0
Fork 0

Add release script

Gitea can't notify Drone of new tags synced from GitHub, so this script
serves to generate releases.
master
Ambrose Chua 2020-04-25 20:34:35 +08:00
parent 11cc028bdf
commit 028133d29c
2 changed files with 62 additions and 0 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
coredns/coredns
coredns/gitea_token

61
coredns/release Executable file
View File

@ -0,0 +1,61 @@
#!/bin/bash
source gitea_token
set -e
GITEA_SERVER=${GITEA_SERVER:="https://git.makerforce.io"}
GITEA_TOKEN=${GITEA_TOKEN:=""}
path_to_httpie=$(which http)
if [ ! -x "$path_to_httpie" ] ; then
echo "HTTPie not installed. Please install it at (https://httpie.org/doc#installation)"
fi
path_to_jq=$(which jq)
if [ ! -x "$path_to_jq" ] ; then
echo "JQ not installed. Please install it at (https://stedolan.github.io/jq/download/)"
fi
if [ -z $GITEA_TOKEN ]; then
echo "Enter Gitea token ($GITEA_SERVER/account/token)"
echo -n "> "
read GITEA_TOKEN
echo
fi
GIT_COMMIT="$(git rev-parse HEAD)"
GIT_LAST_TAG="$(git tag -l | tail -n 1)"
# Increment version
ver=( ${GIT_LAST_TAG//./ } )
((ver[2]++))
GIT_TAG="${ver[0]}.${ver[1]}.${ver[2]}"
echo "Tagging $GIT_TAG..."
git tag "$GIT_TAG" "$GIT_COMMIT"
git push
git push --tags
echo "Building coredns..."
export CGO_ENABLED=0
export GOOS=linux
export GOARCH=amd64
go build
echo "Uploading release..."
RELEASE="$GIT_TAG"
BODY="$(cat go.mod | grep coredns/coredns | tr -d '\t')"
http --check-status -b POST \
$GITEA_SERVER/api/repos/ambrose/alias/releases \
Authorization:"Bearer $GITEA_TOKEN" \
body="$BODY" \
draft:=false \
name="$RELEASE" \
prerelease:=false \
tag_name="$GIT_TAG" \
target_commitish="$GIT_COMMIT"