mirror of
https://github.com/Luzifer/github-publish.git
synced 2024-12-29 22:31:21 +00:00
Leave build dir at the end for following tassk
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
a346ae949a
commit
68ba18f83d
2 changed files with 33 additions and 33 deletions
|
@ -1,2 +1,2 @@
|
|||
05e4977d541b2ef07c757acca912b7b58b379fb425eceb3a1f53c829a78a4aa4 docker2aci.sh
|
||||
b3fb1862829bd85992de6c234d3895483fb92a963a489376fde32182fa5a8c55 golang.sh
|
||||
635091c14de852b5cb183ebe345c2711f430907c439aec7c9d5dba1b9c8309cd golang.sh
|
||||
|
|
64
golang.sh
64
golang.sh
|
@ -1,21 +1,21 @@
|
|||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
curl -sL https://raw.githubusercontent.com/Luzifer/github-publish/master/SHA256SUMS | \
|
||||
grep "golang.sh" | sha256sum -c || exit 2
|
||||
curl -sL https://raw.githubusercontent.com/Luzifer/github-publish/master/SHA256SUMS |
|
||||
grep "golang.sh" | sha256sum -c || exit 2
|
||||
|
||||
( which zip 2>&1 1>/dev/null ) || {
|
||||
( 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 zip 2>&1 1>/dev/null) || {
|
||||
(which apk 2>&1 1>/dev/null) && apk add --update zip
|
||||
(which apt-get 2>&1 1>/dev/null) && apt-get install -y zip
|
||||
}
|
||||
|
||||
function step {
|
||||
echo "===> $@..."
|
||||
function step() {
|
||||
echo "===> $@..."
|
||||
}
|
||||
|
||||
VERSION=$(git describe --tags --exact-match || echo "ghpublish__notags")
|
||||
PWD=$(pwd)
|
||||
godir=${PWD/${GOPATH}\/src\/}
|
||||
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"}
|
||||
|
@ -31,46 +31,49 @@ step Test code
|
|||
go vet ${PACKAGES}
|
||||
go test ${PACKAGES}
|
||||
|
||||
step Cleanup build directory if present
|
||||
rm -rf ${BUILD_DIR}
|
||||
|
||||
step Compile program
|
||||
mkdir ${BUILD_DIR}
|
||||
gox -ldflags="-X main.version=${VERSION}" -osarch="${ARCHS}" \
|
||||
-output="${BUILD_DIR}/{{.Dir}}_{{.OS}}_{{.Arch}}"\
|
||||
${PACKAGES}
|
||||
-output="${BUILD_DIR}/{{.Dir}}_{{.OS}}_{{.Arch}}" \
|
||||
${PACKAGES}
|
||||
|
||||
step Generate binary SHASUMs
|
||||
cd ${BUILD_DIR}
|
||||
sha256sum * > SHA256SUMS
|
||||
sha256sum * >SHA256SUMS
|
||||
|
||||
step Packing archives
|
||||
for file in *; do
|
||||
if [ "${file}" = "SHA256SUMS" ]; then
|
||||
continue
|
||||
fi
|
||||
if [ "${file}" = "SHA256SUMS" ]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
if [[ ${file} == *linux* ]]; then
|
||||
tar -czf "${file%%.*}.tar.gz" "${file}"
|
||||
else
|
||||
zip "${file%%.*}.zip" "${file}"
|
||||
fi
|
||||
if [[ ${file} == *linux* ]]; then
|
||||
tar -czf "${file%%.*}.tar.gz" "${file}"
|
||||
else
|
||||
zip "${file%%.*}.zip" "${file}"
|
||||
fi
|
||||
|
||||
rm "${file}"
|
||||
rm "${file}"
|
||||
done
|
||||
|
||||
step Generate archive SHASUMs
|
||||
sha256sum * >> SHA256SUMS
|
||||
grep -v 'SHA256SUMS' SHA256SUMS > SHA256SUMS.tmp
|
||||
sha256sum * >>SHA256SUMS
|
||||
grep -v 'SHA256SUMS' SHA256SUMS >SHA256SUMS.tmp
|
||||
mv SHA256SUMS.tmp SHA256SUMS
|
||||
|
||||
step Publish builds to Github
|
||||
|
||||
if ( test "${VERSION}" == "ghpublish__notags" ); then
|
||||
echo "No tag present, stopping build now."
|
||||
exit 0
|
||||
if (test "${VERSION}" == "ghpublish__notags"); then
|
||||
echo "No tag present, stopping build now."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -z "${GITHUB_TOKEN}" ]; then
|
||||
echo "Please set \$GITHUB_TOKEN environment variable"
|
||||
exit 1
|
||||
echo "Please set \$GITHUB_TOKEN environment variable"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
step Create a drafted release
|
||||
|
@ -78,14 +81,11 @@ github-release release --user ${GHUSER} --repo ${REPO} --tag ${DEPLOYMENT_TAG} -
|
|||
|
||||
step Upload build assets
|
||||
for file in *; do
|
||||
echo "- ${file}"
|
||||
github-release upload --user ${GHUSER} --repo ${REPO} --tag ${DEPLOYMENT_TAG} --name ${file} --file ${file}
|
||||
echo "- ${file}"
|
||||
github-release upload --user ${GHUSER} --repo ${REPO} --tag ${DEPLOYMENT_TAG} --name ${file} --file ${file}
|
||||
done
|
||||
|
||||
echo -e "\n\n=== Recorded checksums ==="
|
||||
cat SHA256SUMS
|
||||
|
||||
step Cleanup build directory
|
||||
cd -
|
||||
rm -rf ${BUILD_DIR}
|
||||
|
||||
|
|
Loading…
Reference in a new issue