diff --git a/.travis.yml b/.travis.yml index e840c15f..7a7ef539 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,7 +29,7 @@ script: if [ "${TARGET}" == "amd64" ]; then GOARCH="${TARGET}" ./test.sh else - GOARCH="${TARGET}" ./build.sh + GOARCH="${TARGET}" ./build_linux.sh fi notifications: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6254ad02..6bd67e4c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -31,8 +31,8 @@ are very busy and read the mailing lists. ## Building -Each plugin is compiled simply with `go build`. A script, `build.sh`, -is supplied which will build all the plugins in the repo. +Each plugin is compiled simply with `go build`. Two scripts, `build_linux.sh` and `build_windows.sh`, +are supplied which will build all the plugins for their respective OS. ## Contribution workflow diff --git a/build.sh b/build_linux.sh similarity index 76% rename from build.sh rename to build_linux.sh index 6db861a5..ddae34b4 100755 --- a/build.sh +++ b/build_linux.sh @@ -24,15 +24,9 @@ PLUGINS="plugins/meta/* plugins/main/* plugins/ipam/* plugins/sample" for d in $PLUGINS; do if [ -d "$d" ]; then plugin="$(basename "$d")" - if [ $plugin == "windows" ] - then - if [ "$GOARCH" == "amd64" ] - then - GOOS=windows . $d/build.sh - fi - else + if [ $plugin != "windows" ]; then echo " $plugin" - $GO build -o "${PWD}/bin/$plugin" "$@" "$REPO_PATH"/$d + $GO build -o "${PWD}/bin/$plugin" "$@" "$REPO_PATH"/$d fi fi done diff --git a/build_windows.sh b/build_windows.sh new file mode 100755 index 00000000..02b946f5 --- /dev/null +++ b/build_windows.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +set -e +cd $(dirname "$0") + +ORG_PATH="github.com/containernetworking" +export REPO_PATH="${ORG_PATH}/plugins" + +if [ ! -h gopath/src/${REPO_PATH} ]; then + mkdir -p gopath/src/${ORG_PATH} + ln -s ../../../.. gopath/src/${REPO_PATH} || exit 255 +fi + +export GOPATH=${PWD}/gopath +export GO="${GO:-go}" +export GOOS=windows + +PLUGINS=$(cat plugins/windows_only.txt) +for d in $PLUGINS; do + if [ -d "$d" ]; then + plugin="$(basename "$d").exe" + echo " $plugin" + $GO build -o "${PWD}/bin/$plugin" "$@" "$REPO_PATH"/$d + fi +done diff --git a/scripts/release.sh b/scripts/release.sh index 0956e9b8..bd59ba0e 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -19,15 +19,26 @@ docker run -v ${SRC_DIR}:/go/src/github.com/containernetworking/plugins --rm gol /bin/sh -xe -c "\ apk --no-cache add bash tar; cd /go/src/github.com/containernetworking/plugins; umask 0022; + for arch in amd64 arm arm64 ppc64le s390x; do \ rm -f ${OUTPUT_DIR}/*; \ - CGO_ENABLED=0 GOARCH=\$arch ./build.sh ${BUILDFLAGS}; \ + CGO_ENABLED=0 GOARCH=\$arch ./build_linux.sh ${BUILDFLAGS}; \ for format in tgz; do \ - FILENAME=cni-plugins-\$arch-${TAG}.\$format; \ + FILENAME=cni-plugins-linux-\$arch-${TAG}.\$format; \ FILEPATH=${RELEASE_DIR}/\$FILENAME; \ tar -C ${OUTPUT_DIR} --owner=0 --group=0 -caf \$FILEPATH .; \ done; \ done; + + rm -rf ${OUTPUT_DIR}/*; \ + CGO_ENABLED=0 GOARCH=amd64 ./build_windows.sh ${BUILDFLAGS}; \ + for format in tgz; do \ + FILENAME=cni-plugins-windows-amd64-${TAG}.\$format; \ + FILEPATH=${RELEASE_DIR}/\$FILENAME; \ + tar -C ${OUTPUT_DIR} --owner=0 --group=0 -caf \$FILEPATH .; \ + done; + + cd ${RELEASE_DIR}; for f in *.tgz; do sha1sum \$f > \$f.sha1; done; for f in *.tgz; do sha256sum \$f > \$f.sha256; done; diff --git a/test.sh b/test.sh index 0c48852d..34b64f80 100755 --- a/test.sh +++ b/test.sh @@ -6,7 +6,7 @@ # set -e -source ./build.sh +source ./build_linux.sh echo "Running tests"