1
0
Fork 0
mirror of https://github.com/Luzifer/github-publish.git synced 2024-12-21 02:11:22 +00:00

Leave build dir at the end for following tassk

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2018-03-21 11:32:58 +01:00
parent a346ae949a
commit 68ba18f83d
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E
2 changed files with 33 additions and 33 deletions

View file

@ -1,2 +1,2 @@
05e4977d541b2ef07c757acca912b7b58b379fb425eceb3a1f53c829a78a4aa4 docker2aci.sh 05e4977d541b2ef07c757acca912b7b58b379fb425eceb3a1f53c829a78a4aa4 docker2aci.sh
b3fb1862829bd85992de6c234d3895483fb92a963a489376fde32182fa5a8c55 golang.sh 635091c14de852b5cb183ebe345c2711f430907c439aec7c9d5dba1b9c8309cd golang.sh

View file

@ -1,21 +1,21 @@
#!/bin/bash #!/bin/bash
set -euo pipefail set -euo pipefail
curl -sL https://raw.githubusercontent.com/Luzifer/github-publish/master/SHA256SUMS | \ curl -sL https://raw.githubusercontent.com/Luzifer/github-publish/master/SHA256SUMS |
grep "golang.sh" | sha256sum -c || exit 2 grep "golang.sh" | sha256sum -c || exit 2
( which zip 2>&1 1>/dev/null ) || { (which zip 2>&1 1>/dev/null) || {
( which apk 2>&1 1>/dev/null ) && apk add --update zip (which apk 2>&1 1>/dev/null) && apk add --update zip
( which apt-get 2>&1 1>/dev/null ) && apt-get install -y zip (which apt-get 2>&1 1>/dev/null) && apt-get install -y zip
} }
function step { function step() {
echo "===> $@..." echo "===> $@..."
} }
VERSION=$(git describe --tags --exact-match || echo "ghpublish__notags") VERSION=$(git describe --tags --exact-match || echo "ghpublish__notags")
PWD=$(pwd) PWD=$(pwd)
godir=${PWD/${GOPATH}\/src\/} godir=${PWD/${GOPATH}\/src\//}
REPO=${REPO:-$(echo ${godir} | cut -d '/' -f 3)} REPO=${REPO:-$(echo ${godir} | cut -d '/' -f 3)}
GHUSER=${GHUSER:-$(echo ${godir} | cut -d '/' -f 2)} GHUSER=${GHUSER:-$(echo ${godir} | cut -d '/' -f 2)}
ARCHS=${ARCHS:-"linux/amd64 linux/arm darwin/amd64 windows/amd64"} ARCHS=${ARCHS:-"linux/amd64 linux/arm darwin/amd64 windows/amd64"}
@ -31,46 +31,49 @@ step Test code
go vet ${PACKAGES} go vet ${PACKAGES}
go test ${PACKAGES} go test ${PACKAGES}
step Cleanup build directory if present
rm -rf ${BUILD_DIR}
step Compile program step Compile program
mkdir ${BUILD_DIR} mkdir ${BUILD_DIR}
gox -ldflags="-X main.version=${VERSION}" -osarch="${ARCHS}" \ gox -ldflags="-X main.version=${VERSION}" -osarch="${ARCHS}" \
-output="${BUILD_DIR}/{{.Dir}}_{{.OS}}_{{.Arch}}"\ -output="${BUILD_DIR}/{{.Dir}}_{{.OS}}_{{.Arch}}" \
${PACKAGES} ${PACKAGES}
step Generate binary SHASUMs step Generate binary SHASUMs
cd ${BUILD_DIR} cd ${BUILD_DIR}
sha256sum * > SHA256SUMS sha256sum * >SHA256SUMS
step Packing archives step Packing archives
for file in *; do for file in *; do
if [ "${file}" = "SHA256SUMS" ]; then if [ "${file}" = "SHA256SUMS" ]; then
continue continue
fi fi
if [[ ${file} == *linux* ]]; then if [[ ${file} == *linux* ]]; then
tar -czf "${file%%.*}.tar.gz" "${file}" tar -czf "${file%%.*}.tar.gz" "${file}"
else else
zip "${file%%.*}.zip" "${file}" zip "${file%%.*}.zip" "${file}"
fi fi
rm "${file}" rm "${file}"
done done
step Generate archive SHASUMs step Generate archive SHASUMs
sha256sum * >> SHA256SUMS sha256sum * >>SHA256SUMS
grep -v 'SHA256SUMS' SHA256SUMS > SHA256SUMS.tmp grep -v 'SHA256SUMS' SHA256SUMS >SHA256SUMS.tmp
mv SHA256SUMS.tmp SHA256SUMS mv SHA256SUMS.tmp SHA256SUMS
step Publish builds to Github step Publish builds to Github
if ( test "${VERSION}" == "ghpublish__notags" ); then if (test "${VERSION}" == "ghpublish__notags"); then
echo "No tag present, stopping build now." echo "No tag present, stopping build now."
exit 0 exit 0
fi fi
if [ -z "${GITHUB_TOKEN}" ]; then if [ -z "${GITHUB_TOKEN}" ]; then
echo "Please set \$GITHUB_TOKEN environment variable" echo "Please set \$GITHUB_TOKEN environment variable"
exit 1 exit 1
fi fi
step Create a drafted release step Create a drafted release
@ -78,14 +81,11 @@ github-release release --user ${GHUSER} --repo ${REPO} --tag ${DEPLOYMENT_TAG} -
step Upload build assets step Upload build assets
for file in *; do for file in *; do
echo "- ${file}" echo "- ${file}"
github-release upload --user ${GHUSER} --repo ${REPO} --tag ${DEPLOYMENT_TAG} --name ${file} --file ${file} github-release upload --user ${GHUSER} --repo ${REPO} --tag ${DEPLOYMENT_TAG} --name ${file} --file ${file}
done done
echo -e "\n\n=== Recorded checksums ===" echo -e "\n\n=== Recorded checksums ==="
cat SHA256SUMS cat SHA256SUMS
step Cleanup build directory
cd - cd -
rm -rf ${BUILD_DIR}