1
0
Fork 0

Compare commits

...

2 Commits

Author SHA1 Message Date
Ambrose Chua d3189dece2 Add multiarch builds
continuous-integration/drone/push Build is passing Details
2020-04-25 20:39:19 +08:00
Ambrose Chua 028133d29c Add release script
Gitea can't notify Drone of new tags synced from GitHub, so this script
serves to generate releases.
2020-04-25 20:34:35 +08:00
2 changed files with 64 additions and 0 deletions

1
.gitignore vendored
View File

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

63
coredns/release Executable file
View File

@ -0,0 +1,63 @@
#!/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
GOOS=linux GOARCH=amd64 go build -o coredns_${GOOS}_${GOARCH}
GOOS=linux GOARCH=arm64 go build -o coredns_${GOOS}_${GOARCH}
GOOS=linux GOARCH=armv6 go build -o coredns_${GOOS}_${GOARCH}
GOOS=linux GOARCH=armv7 go build -o coredns_${GOOS}_${GOARCH}
GOOS=mac GOARCH=amd64 go build -o coredns_${GOOS}_${GOARCH}
GOOS=windows GOARCH=amd64 go build -o coredns_${GOOS}_${GOARCH}
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"