mirror of
https://github.com/Luzifer/github-publish.git
synced 2024-11-09 23:00:14 +00:00
Add multi-package support
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
344b7cb7db
commit
f1b606d816
2 changed files with 50 additions and 33 deletions
|
@ -1,2 +1,2 @@
|
||||||
05e4977d541b2ef07c757acca912b7b58b379fb425eceb3a1f53c829a78a4aa4 docker2aci.sh
|
05e4977d541b2ef07c757acca912b7b58b379fb425eceb3a1f53c829a78a4aa4 docker2aci.sh
|
||||||
713776897de828d288a761794a4f17f59d634e20f5df4ac2b625112ba1a9e95d golang.sh
|
15304abfac81fda4eadf91ceed8028b7c510803c2bf9b8e4237679d29e0678ff golang.sh
|
||||||
|
|
81
golang.sh
81
golang.sh
|
@ -1,12 +1,18 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
( which apk 2>&1 1>/dev/null ) && apk add --update zip
|
|
||||||
( which apt-get 2>&1 1>/dev/null ) && apt-get install -y zip
|
|
||||||
|
|
||||||
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 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 "===> $@..."
|
||||||
|
}
|
||||||
|
|
||||||
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\/}
|
||||||
|
@ -14,23 +20,48 @@ 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"}
|
||||||
DEPLOYMENT_TAG=${DEPLOYMENT_TAG:-${VERSION}}
|
DEPLOYMENT_TAG=${DEPLOYMENT_TAG:-${VERSION}}
|
||||||
|
PACKAGES=${PACKAGES:-$(echo ${godir} | cut -d '/' -f 1-3)}
|
||||||
|
BUILD_DIR=${BUILD_DIR:-.build}
|
||||||
|
|
||||||
set -ex
|
step Retrieve dependencies
|
||||||
|
|
||||||
# Retrieve dependencies
|
|
||||||
go get github.com/aktau/github-release
|
go get github.com/aktau/github-release
|
||||||
go get github.com/mitchellh/gox
|
go get github.com/mitchellh/gox
|
||||||
|
|
||||||
# Test code (used in PR tests, branch tests, and builds)
|
step Test code
|
||||||
go vet .
|
go vet ${PACKAGES}
|
||||||
go test .
|
go test ${PACKAGES}
|
||||||
|
|
||||||
# Compile program
|
step Compile program
|
||||||
gox -ldflags="-X main.version=${VERSION}" -osarch="${ARCHS}"
|
mkdir ${BUILD_DIR}
|
||||||
|
gox -ldflags="-X main.version=${VERSION}" -osarch="${ARCHS}" \
|
||||||
|
-output="${BUILD_DIR}/{{.Dir}}_{{.OS}}_{{.Arch}}"\
|
||||||
|
${PACKAGES}
|
||||||
|
|
||||||
# Publish builds to Github
|
step Generate binary SHASUMs
|
||||||
|
cd ${BUILD_DIR}
|
||||||
|
sha256sum * > SHA256SUMS
|
||||||
|
|
||||||
set +x
|
step Packing archives
|
||||||
|
for file in *; do
|
||||||
|
if [ "${file}" = "SHA256SUMS" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ${file} == *linux* ]]; then
|
||||||
|
tar -czf "${file%%.*}.tar.gz" "${file}"
|
||||||
|
else
|
||||||
|
zip "${file%%.*}.zip" "${file}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm "${file}"
|
||||||
|
done
|
||||||
|
|
||||||
|
step Generate archive SHASUMs
|
||||||
|
sha256sum * >> SHA256SUMS
|
||||||
|
grep -v 'SHA256SUMS' SHA256SUMS > SHA256SUMS.tmp
|
||||||
|
mv SHA256SUMS.tmp SHA256SUMS
|
||||||
|
|
||||||
|
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."
|
||||||
|
@ -42,31 +73,17 @@ if [ -z "${GITHUB_TOKEN}" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Generate binary SHASUMs
|
step Create a drafted release
|
||||||
sha256sum ${REPO}_* > SHA256SUMS
|
|
||||||
|
|
||||||
for file in ${REPO}_*; do
|
|
||||||
if [[ ${file} == *linux* ]]; then
|
|
||||||
tar -czf "${file%%.*}.tar.gz" "${file}"
|
|
||||||
else
|
|
||||||
zip "${file%%.*}.zip" "${file}"
|
|
||||||
fi
|
|
||||||
rm "${file}"
|
|
||||||
done
|
|
||||||
|
|
||||||
set -x
|
|
||||||
|
|
||||||
# Generate archive SHASUMs
|
|
||||||
sha256sum ${REPO}_* >> SHA256SUMS
|
|
||||||
|
|
||||||
# Create a drafted release
|
|
||||||
github-release release --user ${GHUSER} --repo ${REPO} --tag ${DEPLOYMENT_TAG} --name ${DEPLOYMENT_TAG} --draft || true
|
github-release release --user ${GHUSER} --repo ${REPO} --tag ${DEPLOYMENT_TAG} --name ${DEPLOYMENT_TAG} --draft || true
|
||||||
|
|
||||||
# Upload build assets
|
step Upload build assets
|
||||||
for file in ${REPO}_* SHA256SUMS; do
|
for file in ${REPO}_* SHA256SUMS; do
|
||||||
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
|
||||||
|
|
||||||
|
cd -
|
||||||
|
rm -rf ${BUILD_DIR}
|
||||||
|
|
||||||
echo -e "\n\n=== Recorded checksums ==="
|
echo -e "\n\n=== Recorded checksums ==="
|
||||||
|
|
||||||
cat SHA256SUMS
|
cat SHA256SUMS
|
||||||
|
|
Loading…
Reference in a new issue