Mercurial > public > develkit
view scripts/release.groovy @ 212:349fca275129
Subscribing Becher to push notification emails.
author | Jodi Becher <becher@nwoca.org> |
---|---|
date | Mon, 28 Mar 2016 08:56:18 -0400 |
parents | f200b931ea9d |
children | 5bebb590b30e |
line wrap: on
line source
#!groovy /** This script implements the SSDT branching strategy based on hg flow. The intension is to reduce dudgery of creating release branches. The script tries to do the right thing based on standard SSDT project structures, but it is the user's responsibility to ensure it's correct. The script does NOT "hg push --new-branch". That step is left for you if the branch was created correctly. */ def project = new Properties() if (new File('gradle.properties').exists() ) { project.load(new File('gradle.properties').newInputStream()) } println "\nCurrent project:" println "\tversion: " + project.version ?: "Unknown" println "-" * 20 if (args.size() < 2) { println """ usage: release.groovy {releaseVersion} {nextVersion}\n e.g: release.groovy 1.6.0 1.7.0 (SNAPSHOT will be added automatically) If release ends in ".0", then will create 'release' stream, otherwise 'hotfix'. For hotfix, current working branch should be the release branch. Recommend that this script be executed in a fresh clone of the repo. ** Any uncommitted changes in the working directory will be committed with the initial setting of the version. This are assumed to be 'latest.integration' changes. """ System.exit(0) } def releaseVersion = args[0] def nextVersion = args[1] def hotfix = !releaseVersion.endsWith('.0') def stream = hotfix ? 'hotfix' : 'release' println "Creating ${hotfix ? 'hotfix' : 'release'} branch for $releaseVersion" checkForSnapshots() println "hg flow $stream start v${releaseVersion} --dry-run".execute().text println "Continue? Enter = Yes, ^C to cancel" System.in.newReader().readLine() updateVersion(releaseVersion) println 'hg com -m "release: set release version"'.execute().text println "hg flow ${stream} start v${releaseVersion} --dirty".execute().text println "hg update default".execute().text updateVersion(nextVersion + ".SNAPSHOT") println 'hg com -m "release: set next release version"'.execute().text println "hg update ${stream}/v${releaseVersion}".execute().text println "Done! Created $releaseVersion $stream branch." println " Verify the branch created correctly then push the new branch." println " If any problems, then delete repo and clone fresh repository." def updateVersion(String newVersion) { new File('gradle.properties').write( new File('gradle.properties').text.replaceAll(/version=(.*)/,"version=$newVersion") ) } def checkForSnapshots() { def lines = new File('gradle.properties').readLines() + new File('build.gradle').readLines() def snapshots = lines.collect { it.trim() }.findAll{ it.contains('.SNAPSHOT') && !it.startsWith('version=') || it.contains('latest.') && (it.startsWith('compile') || it.startsWith('runtime')) } if (snapshots) { println "project contains SNAPSHOT dependencies: \n\t" + snapshots.join('\n\t') System.exit(1) } }