summaryrefslogtreecommitdiffstats
path: root/build.xml
diff options
context:
space:
mode:
authorFlorian Zschocke <florian.zschocke@devolo.de>2020-01-26 16:47:44 +0100
committerFlorian Zschocke <florian.zschocke@devolo.de>2020-01-27 21:48:20 +0100
commite0e23d872c625c8b5494c37b0e5b90475a3cee78 (patch)
tree1d5b28f6471509537daaf0d8177ba086b1923404 /build.xml
parent8463244e78c9d6fdfed8ebb1227b9a9494219567 (diff)
downloadgitblit-e0e23d872c625c8b5494c37b0e5b90475a3cee78.tar.gz
gitblit-e0e23d872c625c8b5494c37b0e5b90475a3cee78.zip
Add deployment of a release to GitHub
Add Ant tasks and macros to deploy binaries to GitHub, using GitHub's releases. Adds an Awk script to extract GH flavoured markdown release notes from the release.moxie file. Adds `ok.sh` to the repository so that it is readily available. This is a Bourne shell GitHub API client, used to create a release on GitHub and upload the binaries.
Diffstat (limited to 'build.xml')
-rw-r--r--build.xml168
1 files changed, 159 insertions, 9 deletions
diff --git a/build.xml b/build.xml
index 68b31422..144aab08 100644
--- a/build.xml
+++ b/build.xml
@@ -27,7 +27,12 @@
<property name="project.src.dir" value="${basedir}/src/main/java" />
<property name="project.resources.dir" value="${basedir}/src/main/resources" />
<property name="project.distrib.dir" value="${basedir}/src/main/distrib" />
-
+
+ <!-- Tools -->
+ <property name="octokit" location="${basedir}/.github/ok.sh" />
+ <property name="relnoawk" location="${basedir}/src/site/templates/ghreleasenotes.awk" />
+
+
<!--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Initialize Moxie and setup build properties
@@ -50,6 +55,8 @@
<property name="authority.zipfile" value="authority-${project.version}.zip" />
<property name="gbapi.zipfile" value="gbapi-${project.version}.zip" />
<property name="maven.directory" value="${basedir}/../gitblit-maven" />
+ <property name="releaselog" value="${basedir}/releases.moxie" />
+
<!-- Download links -->
<property name="gc.url" value="http://dl.bintray.com/gitblit/releases/" />
@@ -480,9 +487,9 @@
</fileset>
</delete>
</target>
-
-
- <!--
+
+
+ <!--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Build the Gitblit Website
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -491,8 +498,6 @@
<echo>Building Gitblit Website ${project.version}</echo>
- <property name="releaselog" value="${basedir}/releases.moxie" />
-
<!-- Build Site -->
<mx:doc googleplusid="114464678392593421684" googleanalyticsid="UA-24377072-1"
googlePlusOne="true" minify="true" customless="custom.less">
@@ -688,7 +693,7 @@
<!-- Build gh-pages branch -->
<mx:ghpages repositorydir="${basedir}" obliterate="true" />
</target>
-
+
<!--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -731,7 +736,76 @@
</target>
-
+
+ <!--
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ Publish binaries to GitHub release
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ -->
+ <target name="releaseBinaries" depends="prepare" description="Publish the Gitblit binaries to a GitHub release">
+ <property name="project.tag" value="v${project.version}" />
+
+ <ghReleaseDraft
+ releaselog="${releaselog}"/>
+
+ <echo>Uploading Gitblit ${project.version} binaries</echo>
+
+ <!-- Upload Gitblit GO Windows ZIP file -->
+ <githubUpload
+ source="${project.targetDirectory}/${distribution.zipfile}"
+ target="gitblit-${project.version}.zip" />
+
+ <!-- Upload Gitblit GO Linux/Unix tar.gz file -->
+ <githubUpload
+ source="${project.targetDirectory}/${distribution.tgzfile}"
+ target="gitblit-${project.version}.tar.gz" />
+
+ <!-- Upload Gitblit WAR file -->
+ <githubUpload
+ source="${project.targetDirectory}/${distribution.warfile}"
+ target="gitblit-${project.version}.war" />
+
+ <!-- Upload Gitblit FedClient -->
+ <githubUpload
+ source="${project.targetDirectory}/${fedclient.zipfile}"
+ target="fedclient-${project.version}.zip" />
+
+ <!-- Upload Gitblit Manager -->
+ <githubUpload
+ source="${project.targetDirectory}/${manager.zipfile}"
+ target="manager-${project.version}.zip" />
+
+ <!-- Upload Gitblit API Library -->
+ <githubUpload
+ source="${project.targetDirectory}/${gbapi.zipfile}"
+ target="gbapi-${project.version}.zip" />
+
+
+ </target>
+
+
+ <!--
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ Publish GH release draft
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ -->
+ <target name="publishRelease" depends="prepare" description="Publish the GitHub release draft" >
+ <property name="project.tag" value="v${project.version}" />
+
+ <echo>Publishing Gitblit ${project.version} release draft on GitHub</echo>
+
+ <ghGetReleaseId
+ releaseVersion="${project.version}"/>
+ <exec executable="bash" logError="true" >
+ <arg value="-c" />
+ <arg value="${octokit} -q edit_release fzs gitblit ${ghrelease.id} tag_name='${project.tag}'"></arg>
+ </exec>
+ <ghPublishReleaseDraft
+ releaseid="${ghrelease.id}"/>
+
+ </target>
+
+
<!--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Publish site to site hosting service
@@ -983,7 +1057,7 @@
</copy>
</sequential>
</macrodef>
-
+
<!--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Macro to upload binaries to Bintray
@@ -1002,6 +1076,82 @@
<!--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ Macro to create release draft on GitHub
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ -->
+ <macrodef name="ghReleaseDraft">
+ <attribute name="releaselog" />
+ <sequential>
+ <echo>Creating release ${project.tag} draft on GitHub</echo>
+ <exec executable="bash" logError="true" failonerror="true" outputproperty="ghrelease.id">
+ <arg value="-c" />
+ <arg value="${octokit} create_release fzs gitblit ${project.tag} name=${project.version} draft=true | cut -f2"></arg>
+ </exec>
+ <exec executable="bash" logError="true" failonerror="true" outputproperty="ghrelease.upldUrl">
+ <arg value="-c" />
+ <arg value="${octokit} release fzs gitblit ${ghrelease.id} _filter=.upload_url | sed 's/{.*$/?name=/'"></arg>
+ </exec>
+ <exec executable="bash" logError="true" failonerror="true" outputproperty="ghrelease.notes">
+ <arg value="-c" />
+ <arg value="cat @{releaselog} | awk -f ${relnoawk} protect=true"></arg>
+ </exec>
+ <exec executable="bash" logError="true" >
+ <arg value="-c" />
+ <arg value="${octokit} -q edit_release fzs gitblit ${ghrelease.id} body='${ghrelease.notes}'"></arg>
+ </exec>
+ </sequential>
+ </macrodef>
+
+ <!--
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ Macro to upload binaries to GitHub
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ -->
+ <macrodef name="githubUpload">
+ <attribute name="source"/>
+ <attribute name="target"/>
+ <sequential>
+ <echo>uploading @{source} to GitHub release ${ghrelease.id}</echo>
+ <exec executable="bash" logError="true" failonerror="true" >
+ <arg value="-c" />
+ <arg value="${octokit} upload_asset ${ghrelease.upldUrl}@{target} @{source}"></arg>
+ </exec>
+ </sequential>
+ </macrodef>
+
+ <!--
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ Macro to publish release draft on GitHub
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ -->
+ <macrodef name="ghPublishReleaseDraft">
+ <attribute name="releaseid"/>
+ <sequential>
+ <echo>publishing GitHub release draft @{releaseid}</echo>
+ <exec executable="bash" logError="true" >
+ <arg value="-c" />
+ <arg value="${octokit} -q edit_release fzs gitblit @{releaseid} draft=false"></arg>
+ </exec>
+ </sequential>
+ </macrodef>
+
+ <!--
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ Macro to publish release draft on GitHub
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ -->
+ <macrodef name="ghGetReleaseId">
+ <attribute name="releaseVersion"/>
+ <sequential>
+ <exec executable="bash" logError="true" failonerror="true" outputproperty="ghrelease.id">
+ <arg value="-c" />
+ <arg value="${octokit} list_releases fzs gitblit _filter='.[] | &quot;\(.name)\t\(.tag_name)\t\(.id)&quot;' | grep @{releaseVersion} | cut -f3"></arg>
+ </exec>
+ </sequential>
+ </macrodef>
+
+ <!--
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Install Gitblit JAR for usage as Maven module
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-->