Project

General

Profile

Download (4.69 KB) Statistics
| Branch: | Tag: | Revision:

foreman_docker / release / rollout-release @ b5e8802d

1
#!/bin/bash
2

    
3
GITHUB_TOKEN=$(cat ~/.codereview)
4
RED='\e[31m';
5
BLUE='\e[44m';
6
GREEN='\e[32m';
7
PLUGIN_DIR=$(pwd)
8
DATE="$(date +'%a %b %d %Y')"
9

    
10
echo -e "${GREEN} foreman-docker releaser $1\033[0m"
11
echo -e "--------------------------"
12
echo -e "${BLUE} Part 1: Rubygems $1\033[0m"
13
echo -e "--------------------------"
14
echo -e "${GREEN} Current version: $(grep VERSION lib/foreman_docker/version.rb) $1\033[0m"
15
echo -e "${GREEN} -- Checking out branch master $1\033[0m"
16
hub checkout master --quiet
17
if [ $? -ne 0 ]; then
18
  echo -e "${RED} -- Error checking out master branch. Aborting... \033[0m"
19
  exit 1
20
fi
21
read -p "What version are we going to release today? : " VERSION
22
sed -i s/"VERSION = .*"/"VERSION = '${VERSION}'"/g  lib/foreman_docker/version.rb
23
echo -e "${GREEN} -- Creating contributors list and CHANGELOG $1\033[0m"
24
./release/changelog
25
echo -e "${GREEN} -- Commiting version bump $1\033[0m"
26
git add lib/foreman_docker/version.rb
27
git add CHANGELOG
28
git add Contributors
29
git commit -m "Bump version to ${VERSION}"
30
git push upstream master
31

    
32
echo -e "${GREEN} -- Tagging version ${VERSION} $1\033[0m"
33
git tag ${VERSION}
34
git push upstream ${VERSION}
35

    
36
MAJOR_VERSION=$(echo $VERSION | cut -c1)
37
echo -e "${GREEN} -- Checking out stable branch ${MAJOR_VERSION} $1\033[0m"
38
git checkout ${MAJOR_VERSION}.0-stable
39
git pull --rebase upstream master
40
git push upstream ${MAJOR_VERSION}.0-stable
41

    
42
echo -e "${GREEN} -- Pushing ${VERSION} to rubygems $1\033[0m"
43
gem build foreman_docker.gemspec
44
gem push foreman_docker-${VERSION}.gem
45

    
46
echo -e "${GREEN} -- Done! Gem is published in rubygems and your repository is tagged. $1\033[0m"
47

    
48
###########################
49
####### PACKAGING #########
50
###########################
51

    
52
echo -e "--------------------------"
53
echo -e "${BLUE} Part 2: Red Hat packaging $1\033[0m"
54
echo -e "--------------------------"
55

    
56
# Assume there is a foreman-packaging directory with two remotes:
57
#   origin pointing to fork
58
#   upstream pointing to theforeman/foreman-packaging
59
cd foreman-packaging
60
read -p "CHANGELOG: What's your full name? e.g: John Doe : " NAME
61
read -p "CHANGELOG: What's your email? e.g: jdoe@foo.bar : " EMAIL
62

    
63
## RPM packaging
64
git checkout rpm/develop
65
git pull --rebase upstream rpm/develop
66
echo -e "${GREEN} -- Checking out branch rpm/foreman-docker-$VERSION $1\033[0m"
67
git checkout -b rpm/foreman-docker-${VERSION}
68
echo -e "${GREEN} -- Bumping version and changelog $1\033[0m"
69
# Bump rubygem-foreman_docker.spec version
70
sed -i s/"Version: .*"/"Version: ${VERSION}"/g rubygem-foreman_docker/rubygem-foreman_docker.spec
71
## Add changelog date and message
72
awk -i inplace -v VERSION="$VERSION" -v EMAIL="$EMAIL" -v NAME="$NAME" -v DATE="$(date +'%a %b %d %Y')" '/%changelog/ { print; print "* " DATE " " NAME " <" EMAIL "> " VERSION "-1.fm1_10"; print "- plugins:foreman_docker - Release " VERSION " (" EMAIL ")"; print ""; next }1' rubygem-foreman_docker/rubygem-foreman_docker.spec
73
echo -e "${GREEN} -- Annexing rubygem to commit $1\033[0m"
74
git rm rubygem-foreman_docker/foreman_docker-*.gem
75
cp $PLUGIN_DIR/foreman_docker-${VERSION}.gem rubygem-foreman_docker/
76
git annex add rubygem-foreman_docker/foreman_docker-${VERSION}.gem
77
echo -e "${GREEN} -- Committing changes to git $1\033[0m"
78
git add .
79
git commit -m "plugins:foreman_docker - Release ${VERSION}"
80
git push origin rpm/foreman-docker-${VERSION}
81
hub pull-request -b rpm/develop
82
echo -e "${GREEN} -- Pull request submitted to rpm/develop $1\033[0m"
83

    
84
echo -e "--------------------------"
85
echo -e "${BLUE} Part 2.1: Debian packaging $1\033[0m"
86
echo -e "--------------------------"
87
git checkout deb/develop
88
git pull --rebase upstream deb/develop
89
echo -e "${GREEN} -- Checking out branch deb/foreman-docker-$VERSION $1\033[0m"
90
git checkout -b deb/foreman-docker-${VERSION}
91
echo -e "${GREEN} -- Bumping version and changelog $1\033[0m"
92
# Bump version in plugins/ruby-foreman-docker/foreman_docker.rb with sed
93
sed -i s/"gem 'foreman_docker', .*"/"gem 'foreman_docker', '${VERSION}'"/g  plugins/ruby-foreman-docker/foreman_docker.rb
94
# update changelog in plugins/ruby-foreman-docker/debian/changelog
95
sed -i "1i ruby-foreman-docker ($VERSION-1) stable; urgency=low\n\n  * Update release to $VERSION\n -- $NAME <$EMAIL> $(date +'%a, %b %d %Y %T %z')" plugins/ruby-foreman-docker/debian/changelog
96
# update gem.list in plugins/ruby-foreman-docker/debian/gem.list
97
sed -i s/"foreman_docker.*"/"foreman_docker-${VERSION}.gem"/g  plugins/ruby-foreman-docker/debian/gem.list
98
echo -e "${GREEN} -- Committing changes to git $1\033[0m"
99
git add .
100
git commit -m "plugins:foreman_docker - Release ${VERSION}"
101
git push origin deb/foreman-docker-${VERSION}
102
hub pull-request -b deb/develop
103
echo -e "${GREEN} -- Pull request submitted to deb/develop $1\033[0m"
104
echo -e "${BLUE} -- DONE! Congratulations, your plugin has been released. $1\033[0m"