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

Replace gox with simple loop (#5)

* Replace gox with simple loop

Signed-off-by: Knut Ahlers <knut@ahlers.me>

* Properly clone array

Signed-off-by: Knut Ahlers <knut@ahlers.me>

* Use function for sub-steps

Signed-off-by: Knut Ahlers <knut@ahlers.me>

* No need to export suffix

Signed-off-by: Knut Ahlers <knut@ahlers.me>

* Use package as source for filename

Signed-off-by: Knut Ahlers <knut@ahlers.me>

* Fix iteration

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2019-07-10 14:13:32 +02:00 committed by GitHub
parent 100cb7d469
commit 87c8700991
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 18 deletions

View file

@ -1,2 +1,2 @@
05e4977d541b2ef07c757acca912b7b58b379fb425eceb3a1f53c829a78a4aa4 docker2aci.sh
3ce8fae21fc7a65e2d56981642507f35d3896a638a89413a8a9d5430fc095ca0 golang.sh
365e7c96a65ac13a36df75f6dc18583db82f4e060de5c914bd8edcc1f5c5aac7 golang.sh

View file

@ -10,7 +10,11 @@ curl -sL https://raw.githubusercontent.com/Luzifer/github-publish/master/SHA256S
}
function step() {
echo "===> $@..."
echo "===> $@..." >&2
}
function substep() {
echo "======> $@..." >&2
}
VERSION=$(git describe --tags --always || echo "dev")
@ -18,9 +22,9 @@ 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"}
ARCHS=(${ARCHS:-linux/amd64 linux/arm darwin/amd64 windows/amd64})
DEPLOYMENT_TAG=${DEPLOYMENT_TAG:-${VERSION}}
PACKAGES=${PACKAGES:-$(echo ${godir} | cut -d '/' -f 1-3)}
PACKAGES=(${PACKAGES:-$(echo ${godir} | cut -d '/' -f 1-3)})
BUILD_DIR=${BUILD_DIR:-.build}
DRAFT=${DRAFT:-true}
FORCE_SKIP_UPLOAD=${FORCE_SKIP_UPLOAD:-false}
@ -31,18 +35,17 @@ go version
step "Retrieve dependencies"
pushd ${GOPATH}
go get github.com/aktau/github-release
go get github.com/Luzifer/gox
popd
step "Test code"
test_params=()
go_params=()
if [[ -n ${MOD_MODE} ]]; then
test_params+=(-mod="${MOD_MODE}")
go_params+=(-mod="${MOD_MODE}")
fi
go vet "${test_params[@]}" ${PACKAGES}
go test "${test_params[@]}" ${PACKAGES}
go vet "${go_params[@]}" ${PACKAGES}
go test "${go_params[@]}" ${PACKAGES}
step "Cleanup build directory if present"
rm -rf ${BUILD_DIR}
@ -50,19 +53,27 @@ rm -rf ${BUILD_DIR}
step "Compile program"
mkdir ${BUILD_DIR}
build_params=(
build_params=("${go_params[@]}")
build_params+=(
-ldflags="-X main.version=${VERSION}"
-osarch="${ARCHS}"
-output="${BUILD_DIR}/{{.Dir}}_{{.OS}}_{{.Arch}}"
)
if [[ -n ${MOD_MODE} ]]; then
build_params+=(-mod="${MOD_MODE}")
fi
for package in "${PACKAGES[@]}"; do
for osarch in "${ARCHS[@]}"; do
export GOOS=${osarch%%/*}
export GOARCH=${osarch##*/}
gox \
[[ ${GOOS} == "windows" ]] && suffix=".exe" || suffix=""
outfile="${BUILD_DIR}/${package##*/}_${GOOS}_${GOARCH}${suffix}"
substep "Building for ${osarch} into ${outfile}"
go build \
-o "${outfile}" \
"${build_params[@]}" \
${PACKAGES}
"${package}"
done
done
step "Generate binary SHASUMs"
cd ${BUILD_DIR}