Browse Source

Merge pull request #3448 from yichengq/release-script

scripts: add release.sh
Yicheng Qin 10 years ago
parent
commit
c34cf04c27
4 changed files with 58 additions and 10 deletions
  1. 9 6
      scripts/build-aci
  2. 3 1
      scripts/build-binary
  3. 10 3
      scripts/build-docker
  4. 36 0
      scripts/release.sh

+ 9 - 6
scripts/build-aci

@@ -1,20 +1,23 @@
 #!/usr/bin/env bash
 #!/usr/bin/env bash
 
 
+BINARYDIR=${BINARYDIR:-bin}
+BUILDDIR=${BUILDDIR:-bin}
+
 # A non-installed actool can be used, for example:
 # A non-installed actool can be used, for example:
 # ACTOOL=../../appc/spec/bin/actool
 # ACTOOL=../../appc/spec/bin/actool
 ACTOOL=${ACTOOL:-actool}
 ACTOOL=${ACTOOL:-actool}
 
 
-IMAGEDIR=${IMAGEDIR:-bin/image-aci}
+IMAGEDIR=${IMAGEDIR:-$BUILDDIR/image-aci}
 
 
 VERSION=$1
 VERSION=$1
 
 
-if [ ! -x "$ACTOOL" ] ; then
+if ! command -v $ACTOOL >/dev/null; then
     echo "actool ($ACTOOL) is not executable"
     echo "actool ($ACTOOL) is not executable"
     exit 1
     exit 1
 fi
 fi
 
 
-if [ ! -x bin/etcd ] ; then
-    echo "bin/etcd not found. Is it compiled?"
+if [ ! -x $BINARYDIR/etcd ] ; then
+    echo "$BINARYDIR/etcd not found. Is it compiled?"
     exit 1
     exit 1
 fi
 fi
 
 
@@ -34,7 +37,7 @@ if [ -n "$(ls -A $IMAGEDIR/rootfs)" ]; then
     exit 1
     exit 1
 fi
 fi
 
 
-cp bin/etcd bin/etcdctl $IMAGEDIR/rootfs/
+cp $BINARYDIR/etcd $BINARYDIR/etcdctl $IMAGEDIR/rootfs/
 cp README.md            $IMAGEDIR/rootfs/
 cp README.md            $IMAGEDIR/rootfs/
 cp etcdctl/README.md    $IMAGEDIR/rootfs/README-etcdctl.md
 cp etcdctl/README.md    $IMAGEDIR/rootfs/README-etcdctl.md
 cp -r Documentation     $IMAGEDIR/rootfs/
 cp -r Documentation     $IMAGEDIR/rootfs/
@@ -98,4 +101,4 @@ cat <<DF > $IMAGEDIR/rootfs/etc/hosts
 127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
 127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
 DF
 DF
 
 
-$ACTOOL build -overwrite=true $IMAGEDIR bin/etcd-${1}-linux-amd64.aci
+$ACTOOL build -overwrite=true $IMAGEDIR $BUILDDIR/etcd-${1}-linux-amd64.aci

+ 3 - 1
scripts/build-release → scripts/build-binary

@@ -1,4 +1,6 @@
-#!/bin/sh -e
+#!/usr/bin/env bash
+
+set -e
 
 
 VER=$1
 VER=$1
 PROJ="etcd"
 PROJ="etcd"

+ 10 - 3
scripts/build-docker

@@ -1,7 +1,14 @@
 #!/usr/bin/env bash
 #!/usr/bin/env bash
-tar cv --files-from /dev/null | docker import - scratch
 
 
-cat <<DF > Dockerfile
+BINARYDIR=${BINARYDIR:-.}
+BUILDDIR=${BUILDDIR:-.}
+
+IMAGEDIR=${BUILDDIR}/image-docker
+
+mkdir -p ${IMAGEDIR}
+cp ${BINARYDIR}/etcd ${BINARYDIR}/etcdctl ${IMAGEDIR}
+
+cat <<DF > ${IMAGEDIR}/Dockerfile
 FROM scratch
 FROM scratch
 ADD etcd /
 ADD etcd /
 ADD etcdctl /
 ADD etcdctl /
@@ -9,4 +16,4 @@ EXPOSE 4001 7001 2379 2380
 ENTRYPOINT ["/etcd"]
 ENTRYPOINT ["/etcd"]
 DF
 DF
 
 
-docker build -t quay.io/coreos/etcd:${1} .
+docker build -t quay.io/coreos/etcd:${1} ${IMAGEDIR}

+ 36 - 0
scripts/release.sh

@@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+#
+# Build all release binaries and images to directory ./release.
+# Run from repository root.
+#
+set -e
+
+VERSION=$1
+if [ -z "${VERSION}" ]; then
+	echo "Usage: ${0} VERSION" >> /dev/stderr
+	exit 255
+fi
+
+# A non-installed actool can be used, for example:
+# ACTOOL=../../appc/spec/bin/actool
+ACTOOL=${ACTOOL:-actool}
+if ! command -v $ACTOOL >/dev/null; then
+    echo "cannot find actool ($ACTOOL)"
+    exit 1
+fi
+
+if ! command -v docker >/dev/null; then
+    echo "cannot find docker"
+    exit 1
+fi
+
+ETCD_ROOT=$(dirname "${BASH_SOURCE}")/..
+
+pushd ${ETCD_ROOT} >/dev/null
+	echo Building etcd binary...
+	./scripts/build-binary ${VERSION}
+	echo Building aci image...
+	BINARYDIR=release/etcd-${VERSION}-linux-amd64 BUILDDIR=release ./scripts/build-aci ${VERSION}
+	echo Building docker image...
+	BINARYDIR=release/etcd-${VERSION}-linux-amd64 BUILDDIR=release ./scripts/build-docker ${VERSION}
+popd >/dev/null