@@ -77,7 +77,7 @@ git_config() {
7777git_co_fetch_merge_stash () {
7878 echo " script_push::git_co_fetch_merge_stash"
7979 git checkout -b travis-${TRAVIS_TAG}
80- git remote add github " https://elgalubot:${GH_TOKEN } @github.com/elgalu/docker-selenium.git"
80+ git remote add github " https://elgalubot:${GITHUB_TOKEN } @github.com/elgalu/docker-selenium.git"
8181 git fetch github
8282 git stash save || true
8383 git checkout -t github/master -b github/master
@@ -171,10 +171,41 @@ generate_NEXT_RELEASE_by_updating_TBDs() {
171171 sed -i -- " s/TBD_TIME_ZONE/${TBD_TIME_ZONE} /g" NEXT_RELEASE.md || true
172172 sed -i -- " s/UBUNTU_FLAVOR/${UBUNTU_FLAVOR} /g" NEXT_RELEASE.md || true
173173 sed -i -- " s/UBUNTU_DATE/${UBUNTU_DATE} /g" NEXT_RELEASE.md || true
174+ }
175+
176+ # ############################################################
177+ # Add commits grouped by authors in between NEXT_RELEASE.md #
178+ # ############################################################
179+ add_commits_to_NEXT_RELEASE () {
180+ # Get commits history grouped by author
181+ # https://www.kernel.org/pub/software/scm/git/docs/git-log.html#_pretty_formats
182+ # e.g. git shortlog --format="[%h] %s" 3.6.0-p6..HEAD
183+ # e.g. git shortlog --format="[%h] %s" --no-merges --author='^(?!Leo Gallucci Bot).*$' --perl-regexp 3.6.0-p6..HEAD
184+ rm -f git_shortlog.stdout
185+ git shortlog \
186+ --format=" [%h] %s" \
187+ --no-merges \
188+ --author=' ^(?!Leo Gallucci Bot).*$' --perl-regexp \
189+ ${TBD_PREV_COM} ..HEAD > git_shortlog.stdout
190+
191+ # Add some indentation prefix
192+ sed -i -e ' s/^/ + /' git_shortlog.stdout
193+
194+ # Use a temporal file
195+ rm -f temp.md
196+ mv NEXT_RELEASE.md temp.md
197+
198+ # Add first 2 lines to the final new release change log part
199+ head -n 2 temp.md > NEXT_RELEASE.md
174200
175- # TODO: Add ` git shortlog ${TBD_PREV_COM}..HEAD` with indent ` + ` in the 3rd line
176- # ...
201+ # Add git short log with indent ` + ` in the 3rd line of NEXT_RELEASE.md
202+ cat git_shortlog.stdout >> NEXT_RELEASE.md
177203
204+ # Add the rest of the original NEXT_RELEASE.md
205+ tail -n +3 temp.md >> NEXT_RELEASE.md
206+
207+ # Remove intermediate files
208+ rm temp.md git_shortlog.stdout
178209}
179210
180211add_NEXT_RELEASE_to_top_of_CHANGELOG () {
@@ -185,7 +216,28 @@ add_NEXT_RELEASE_to_top_of_CHANGELOG() {
185216}
186217
187218github_release_from_NEXT_RELEASE () {
188- echo " TODO: Release via GH API"
219+ echo " Release via GH API"
220+
221+ [ -z " ${GITHUB_TOKEN} " ] && die " Need env var GITHUB_TOKEN"
222+ [ " ${TRAVIS_TAG} " == " " ] && die " Need env var TRAVIS_TAG"
223+
224+ hub --version || die " github.com/hub is not installed!"
225+
226+ # If the release exists, delete it
227+ if hub release | grep -q " ^${TRAVIS_TAG} \$ " ; then
228+ hub release delete " ${TRAVIS_TAG} "
229+ fi
230+
231+ # https://github.com/github/hub/blob/master/share/man/man1/hub.1.ronn#L123
232+ export HUB_VERBOSE=1
233+
234+ # https://github.com/github/hub/blob/master/commands/release.go#L59
235+ # TODO: Add real assents (.deb, ...)
236+ hub release create \
237+ --asset " Dockerfile" \
238+ --asset " capabilities.json" \
239+ --file " NEXT_RELEASE.md" \
240+ " ${TRAVIS_TAG} "
189241}
190242
191243# ########################
@@ -194,8 +246,8 @@ github_release_from_NEXT_RELEASE() {
194246update_changelog () {
195247 echo " script_push::update_changelog"
196248 generate_NEXT_RELEASE_by_updating_TBDs
249+ add_commits_to_NEXT_RELEASE
197250 add_NEXT_RELEASE_to_top_of_CHANGELOG
198- github_release_from_NEXT_RELEASE
199251}
200252
201253# ###################################
@@ -224,7 +276,7 @@ git_push_tag_push() {
224276 if git push github HEAD:master > git_push_master.log 2>&1 ; then \
225277 failed=false; else failed=true; fi
226278 # hide secrets
227- sed -i -- " s/${GH_TOKEN } /\[SECRET\]/g" git_push_master.log || true
279+ sed -i -- " s/${GITHUB_TOKEN } /\[SECRET\]/g" git_push_master.log || true
228280 if [ ${failed} == " true" ]; then
229281 echoerr " Failed to git push to master!"
230282 cat git_push_master.log 1>&2
@@ -237,7 +289,7 @@ git_push_tag_push() {
237289 if git push --tags -f > git_push_tags.log 2>&1 ; then \
238290 failed=false; else failed=true; fi
239291 # hide secrets
240- sed -i -- " s/${GH_TOKEN } /\[SECRET\]/g" git_push_tags.log || true
292+ sed -i -- " s/${GITHUB_TOKEN } /\[SECRET\]/g" git_push_tags.log || true
241293 if [ ${failed} == " true" ]; then
242294 echoerr " Failed to push git tags!"
243295 cat git_push_master.log 1>&2
@@ -272,6 +324,9 @@ elif [ "${TRAVIS_TAG}" != "latest" ] && [ "${TRAVIS_TAG}" != "" ]; then
272324 update_changelog
273325 git_diff_add_commit
274326 git_push_tag_push
327+ github_release_from_NEXT_RELEASE
328+ # Remove intermediate files (optional)
329+ rm NEXT_RELEASE.md
275330else
276331 echo " This is not git tagged so no version push to docker"
277332fi
0 commit comments