# HG changeset patch # User smith@nwoca.org # Date 1450535206 0 # Node ID f200b931ea9de56505d06e951daae690c3e8712c # Parent 7a17678c9a73b57d7e21e0f5a2159380751fe9f7 add release and hgflow scripts diff -r 7a17678c9a73 -r f200b931ea9d scripts/release.groovy --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/release.groovy Sat Dec 19 14:26:46 2015 +0000 @@ -0,0 +1,93 @@ +#!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) + } + +} + diff -r 7a17678c9a73 -r f200b931ea9d scripts/ssdt-hgflow-init.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/ssdt-hgflow-init.sh Sat Dec 19 14:26:46 2015 +0000 @@ -0,0 +1,32 @@ +#!/bin/sh +# +# hg flow init for SSDT repositories +# +if [ -f .hgflow ] + then + echo ".hgflow already exists. Do not re-initialize!" + exit 0 +fi + + +set -e +set -x +die () { + echo "$1" + return 1 +} +# Enable hg flow with SSDT conventions. +# variances from hgflow's default: +# master stream: [default] production +# develop stream: [develop] default +cat > .hgflow << EOF +[branchname] +master = production +develop = default +feature = feature/ +release = release/ +hotfix = hotfix/ +support = support/ +version_prefix = "" +EOF +hg flow init -f