Merge pull request #955 from cdrage/add-generating-packages

Add script for generating deb / rpm packages
This commit is contained in:
Charlie Drage 2018-03-22 10:28:47 -04:00 committed by GitHub
commit ff97e413f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,6 +27,7 @@ usage() {
echo " hub"
echo " github-release"
echo " github_changelog_generator"
echo " fpm"
echo " GITHUB_TOKEN in your env variable"
echo " "
echo "Not only that, but you must have permission for:"
@ -56,6 +57,11 @@ requirements() {
exit 0
fi
if ! hash fpm 2>/dev/null; then
echo "ERROR: fpm required to generate deb/rpm packages. Please run 'gem install fpm"
exit 0
fi
if ! hash hub 2>/dev/null; then
echo "ERROR: Hub needed in order to create the relevant PR's. Please install hub @ https://github.com/github/hub"
exit 0
@ -122,6 +128,45 @@ build_binaries() {
make cross
}
build_packages() {
# fpm is required installed (https://github.com/jordansissel/fpm)
BIN_DIR="./bin/"
PKG_DIR="./bin/"
mkdir -p $PKG_DIR
# package version, use current date by default (if build from master)
PKG_VERSION=$1
# create packages using fpm
fpm -h >/dev/null 2>&1 || {
echo "ERROR: fpm (https://github.com/jordansissel/fpm) is not installed. Can't create linux packages"
exit 1
}
TMP_DIR=$(mktemp -d)
mkdir -p $TMP_DIR/usr/local/bin/
cp $BIN_DIR/kompose-linux-amd64 $TMP_DIR/usr/local/bin/kompose
echo "creating DEB package"
fpm \
--input-type dir --output-type deb \
--chdir $TMP_DIR \
--name kompose --version $PKG_VERSION \
--architecture amd64 \
--maintainer "Charlie Drage <cdrage@redhat.com>" \
--package $PKG_DIR
echo "creating RPM package"
fpm \
--input-type dir --output-type rpm \
--chdir $TMP_DIR \
--name kompose --version $PKG_VERSION \
--architecture x86_64 --rpm-os linux \
--maintainer "Charlie Drage <cdrage@redhat.com>" \
--package $PKG_DIR
}
create_tarballs() {
# cd into the bin directory so we don't have '/bin' inside the tarball
cd bin
@ -248,6 +293,7 @@ push() {
clean() {
rm changes.txt install_guide.txt
rm -r bin/*
}
main() {
@ -290,6 +336,7 @@ main() {
"Sync with upstream"
"Create tag"
"Build binaries"
"Build packages"
"Create tarballs"
"Generate install guide"
"Upload the binaries and push to GitHub release page"
@ -323,6 +370,9 @@ main() {
"Build binaries")
build_binaries
;;
"Build packages")
build_packages $VERSION
;;
"Create tarballs")
create_tarballs
;;