Automate circleci package process
This commit is contained in:
parent
7a23eb69eb
commit
a3e20ab2d6
11
circle.yml
11
circle.yml
|
@ -1,14 +1,17 @@
|
||||||
dependencies:
|
dependencies:
|
||||||
post:
|
post:
|
||||||
|
# install rpm & fpm for packaging
|
||||||
|
- which rpmbuild || sudo apt-get install rpm
|
||||||
|
- gem install fpm
|
||||||
# install golint
|
# install golint
|
||||||
- go get github.com/golang/lint/golint
|
- go get github.com/golang/lint/golint
|
||||||
# install gox
|
# install gox
|
||||||
- go get -u -f github.com/mitchellh/gox
|
- go get -u -f github.com/mitchellh/gox
|
||||||
# install binaries
|
|
||||||
- go install ./...
|
|
||||||
|
|
||||||
test:
|
test:
|
||||||
pre:
|
pre:
|
||||||
|
# install binaries
|
||||||
|
- go install ./...
|
||||||
# Go fmt should pass all files
|
# Go fmt should pass all files
|
||||||
- "[ `git ls-files | grep '.go$' | xargs gofmt -l 2>&1 | wc -l` -eq 0 ]"
|
- "[ `git ls-files | grep '.go$' | xargs gofmt -l 2>&1 | wc -l` -eq 0 ]"
|
||||||
- go vet ./...
|
- go vet ./...
|
||||||
|
@ -18,5 +21,9 @@ test:
|
||||||
override:
|
override:
|
||||||
- make test-short
|
- make test-short
|
||||||
post:
|
post:
|
||||||
|
# Build linux binaries
|
||||||
- gox -os="linux" -arch="386 amd64" ./...
|
- gox -os="linux" -arch="386 amd64" ./...
|
||||||
- mv telegraf* $CIRCLE_ARTIFACTS
|
- mv telegraf* $CIRCLE_ARTIFACTS
|
||||||
|
# Build .deb and .rpm files
|
||||||
|
- "GOPATH=/home/ubuntu/.go_project ./package.sh `git rev-parse --short HEAD`"
|
||||||
|
- mv telegraf*{deb,rpm} $CIRCLE_ARTIFACTS
|
||||||
|
|
11
package.sh
11
package.sh
|
@ -224,10 +224,14 @@ fi
|
||||||
|
|
||||||
echo -e "\nStarting package process...\n"
|
echo -e "\nStarting package process...\n"
|
||||||
|
|
||||||
|
if [ $CIRCLE_BRANCH == "" ]; then
|
||||||
check_gvm
|
check_gvm
|
||||||
|
fi
|
||||||
check_gopath
|
check_gopath
|
||||||
|
if [ $CIRCLE_BRANCH == "" ]; then
|
||||||
check_clean_tree
|
check_clean_tree
|
||||||
update_tree
|
update_tree
|
||||||
|
fi
|
||||||
check_tag_exists $VERSION
|
check_tag_exists $VERSION
|
||||||
do_build $VERSION
|
do_build $VERSION
|
||||||
make_dir_tree $TMP_WORK_DIR $VERSION
|
make_dir_tree $TMP_WORK_DIR $VERSION
|
||||||
|
@ -270,6 +274,7 @@ generate_postinstall_script $VERSION
|
||||||
###########################################################################
|
###########################################################################
|
||||||
# Create the actual packages.
|
# Create the actual packages.
|
||||||
|
|
||||||
|
if [ $CIRCLE_BRANCH == "" ]; then
|
||||||
echo -n "Commence creation of $ARCH packages, version $VERSION? [Y/n] "
|
echo -n "Commence creation of $ARCH packages, version $VERSION? [Y/n] "
|
||||||
read response
|
read response
|
||||||
response=`echo $response | tr 'A-Z' 'a-z'`
|
response=`echo $response | tr 'A-Z' 'a-z'`
|
||||||
|
@ -277,6 +282,7 @@ if [ "x$response" == "xn" ]; then
|
||||||
echo "Packaging aborted."
|
echo "Packaging aborted."
|
||||||
cleanup_exit 1
|
cleanup_exit 1
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if [ $ARCH == "i386" ]; then
|
if [ $ARCH == "i386" ]; then
|
||||||
rpm_package=telegraf-$VERSION-1.i686.rpm
|
rpm_package=telegraf-$VERSION-1.i686.rpm
|
||||||
|
@ -309,6 +315,7 @@ echo "Debian package created successfully."
|
||||||
###########################################################################
|
###########################################################################
|
||||||
# Offer to tag the repo.
|
# Offer to tag the repo.
|
||||||
|
|
||||||
|
if [ $CIRCLE_BRANCH == "" ]; then
|
||||||
echo -n "Tag source tree with v$VERSION and push to repo? [y/N] "
|
echo -n "Tag source tree with v$VERSION and push to repo? [y/N] "
|
||||||
read response
|
read response
|
||||||
response=`echo $response | tr 'A-Z' 'a-z'`
|
response=`echo $response | tr 'A-Z' 'a-z'`
|
||||||
|
@ -327,11 +334,12 @@ if [ "x$response" == "xy" ]; then
|
||||||
else
|
else
|
||||||
echo "Not creating tag v$VERSION."
|
echo "Not creating tag v$VERSION."
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
# Offer to publish the packages.
|
# Offer to publish the packages.
|
||||||
|
|
||||||
|
if [ $CIRCLE_BRANCH == "" ]; then
|
||||||
echo -n "Publish packages to S3? [y/N] "
|
echo -n "Publish packages to S3? [y/N] "
|
||||||
read response
|
read response
|
||||||
response=`echo $response | tr 'A-Z' 'a-z'`
|
response=`echo $response | tr 'A-Z' 'a-z'`
|
||||||
|
@ -355,6 +363,7 @@ if [ "x$response" == "xy" ]; then
|
||||||
else
|
else
|
||||||
echo "Not publishing packages to S3."
|
echo "Not publishing packages to S3."
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
###########################################################################
|
###########################################################################
|
||||||
# All done.
|
# All done.
|
||||||
|
|
Loading…
Reference in New Issue