mirror of
https://github.com/Luzifer/github-publish.git
synced 2024-12-20 09:51:22 +00:00
Add code testing for branches and PRs (#1)
* Add code testing for branches and PRs Signed-off-by: Knut Ahlers <knut@ahlers.me> * Allow overwriting deployment tag Signed-off-by: Knut Ahlers <knut@ahlers.me> * Use an arbitrary string to prevent collisions Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
f70612b9e8
commit
ae2f34579a
2 changed files with 22 additions and 12 deletions
|
@ -1,2 +1,2 @@
|
|||
05e4977d541b2ef07c757acca912b7b58b379fb425eceb3a1f53c829a78a4aa4 docker2aci.sh
|
||||
baae3f7cfe082d64882bdc2ec914962434f88bf18985ec0accdb74f36c6cb645 golang.sh
|
||||
7b9bf8129ec65d26be25621bd39b37e77ff128d662140c8e6e95ad65efa6b3f3 golang.sh
|
||||
|
|
32
golang.sh
32
golang.sh
|
@ -3,16 +3,32 @@
|
|||
curl -sL https://raw.githubusercontent.com/Luzifer/github-publish/master/SHA256SUMS | \
|
||||
grep "golang.sh" | sha256sum -c || exit 2
|
||||
|
||||
VERSION=$(git describe --tags --exact-match)
|
||||
VERSION=$(git describe --tags --exact-match || echo "ghpublish__notags")
|
||||
PWD=$(pwd)
|
||||
godir=${PWD/${GOPATH}\/src\/}
|
||||
REPO=${REPO:-$(echo ${godir} | cut -d '/' -f 3)}
|
||||
GHUSER=${GHUSER:-$(echo ${godir} | cut -d '/' -f 2)}
|
||||
ARCHS=${ARCHS:-"linux/amd64 linux/arm darwin/amd64 windows/amd64"}
|
||||
DEPLOYMENT_TAG=${DEPLOYMENT_TAG:-${VERSION}}
|
||||
|
||||
set -e
|
||||
set -ex
|
||||
|
||||
if [ -z "${VERSION}" ]; then
|
||||
# Retrieve dependencies
|
||||
go get github.com/aktau/github-release
|
||||
go get github.com/mitchellh/gox
|
||||
|
||||
# Test code (used in PR tests, branch tests, and builds)
|
||||
go vet .
|
||||
go test .
|
||||
|
||||
# Compile program
|
||||
gox -ldflags="-X main.version=${VERSION}" -osarch="${ARCHS}"
|
||||
|
||||
# Publish builds to Github
|
||||
|
||||
set +x
|
||||
|
||||
if ( test "${VERSION}" == "ghpublish__notags" ); then
|
||||
echo "No tag present, stopping build now."
|
||||
exit 0
|
||||
fi
|
||||
|
@ -24,19 +40,13 @@ fi
|
|||
|
||||
set -x
|
||||
|
||||
# Retrieve dependencies
|
||||
go get github.com/aktau/github-release
|
||||
go get github.com/mitchellh/gox
|
||||
|
||||
# Compile program
|
||||
gox -ldflags="-X main.version=${VERSION}" -osarch="${ARCHS}"
|
||||
# Generate SHASUMs
|
||||
sha256sum ${REPO}_* > SHA256SUMS
|
||||
|
||||
# Create a drafted release
|
||||
github-release release --user ${GHUSER} --repo ${REPO} --tag ${VERSION} --name ${VERSION} --draft || true
|
||||
github-release release --user ${GHUSER} --repo ${REPO} --tag ${DEPLOYMENT_TAG} --name ${DEPLOYMENT_TAG} --draft || true
|
||||
|
||||
# Upload build assets
|
||||
for file in ${REPO}_* SHA256SUMS; do
|
||||
github-release upload --user ${GHUSER} --repo ${REPO} --tag ${VERSION} --name ${file} --file ${file}
|
||||
github-release upload --user ${GHUSER} --repo ${REPO} --tag ${DEPLOYMENT_TAG} --name ${file} --file ${file}
|
||||
done
|
||||
|
|
Loading…
Reference in a new issue