From 4fce09dcf2b53168cfa8253173341636053fd734 Mon Sep 17 00:00:00 2001 From: Michael Bausor Date: Fri, 14 Apr 2017 08:36:44 -0700 Subject: [PATCH 1/2] Update build process with doc publishing --- build.gradle | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- version.txt | 1 + 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 version.txt diff --git a/build.gradle b/build.gradle index 812fb9ea2..11c60648c 100644 --- a/build.gradle +++ b/build.gradle @@ -24,7 +24,8 @@ apply plugin: 'com.github.sherter.google-java-format' group = "com.google.api" archivesBaseName = "api-common" -version = "0.1.0" + +project.version = new File("version.txt").text.trim() sourceCompatibility = 1.7 targetCompatibility = 1.7 @@ -69,6 +70,10 @@ dependencies { libraries.commons } +clean.doFirst { + delete 'tmp_gh-pages/' +} + jacocoTestReport { reports { xml.enabled true @@ -264,3 +269,47 @@ tasks.verifyGoogleJavaFormat { exclude 'build/**' } test.dependsOn verifyGoogleJavaFormat + +// Release +// ======= + +task checkOutGhPages { + if (!new File('tmp_gh-pages').exists()) { + exec { + commandLine 'git', 'clone', '--branch', 'gh-pages', + '--single-branch', 'https://github.com/googleapis/api-common-java/', 'tmp_gh-pages' + } + } +} + +task copyFilesToGhPages { + dependsOn 'checkOutGhPages' + dependsOn 'javadoc' + doLast { + def newSiteDirPath = 'tmp_gh-pages/' + project.version + '/apidocs/' + new File(newSiteDirPath).mkdirs() + copy { + from 'build/docs/javadoc' + into newSiteDirPath + } + copy { + from 'README.md' + into 'tmp_gh-pages' + rename { filename -> filename.replace 'README', 'index' } + } + } +} + +task createApiDocsRedirect { + dependsOn 'copyFilesToGhPages' + doLast { + def template = new File('templates/apidocs_index.html.template').text + def outputContent = template.replace('{{siteVersion}}', project.version) + new File('tmp_gh-pages/apidocs/index.html').write(outputContent) + } +} + +// Regenerates the gh-pages branch under tmp_gh-pages, which must be committed separately +task updateDocsWithCurrentVersion { + dependsOn 'createApiDocsRedirect' +} diff --git a/version.txt b/version.txt new file mode 100644 index 000000000..f7fe072ac --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ +0.1.1-SNAPSHOT From 219bfde47a3d226764016229d1418e32c652adc9 Mon Sep 17 00:00:00 2001 From: Michael Bausor Date: Fri, 14 Apr 2017 08:51:19 -0700 Subject: [PATCH 2/2] Add template and update .gitignore --- .gitignore | 1 + templates/apidocs_index.html.template | 1 + 2 files changed, 2 insertions(+) create mode 100644 templates/apidocs_index.html.template diff --git a/.gitignore b/.gitignore index 27d921deb..1204a607d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ bin build .gradle +tmp_gh-pages # Eclipse .apt_generated diff --git a/templates/apidocs_index.html.template b/templates/apidocs_index.html.template new file mode 100644 index 000000000..66505a09f --- /dev/null +++ b/templates/apidocs_index.html.template @@ -0,0 +1 @@ +