annotate 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
rev   line source
208
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
1 #!groovy
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
2
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
3 /**
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
4 This script implements the SSDT branching strategy based on hg flow.
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
5
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
6 The intension is to reduce dudgery of creating release branches. The
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
7 script tries to do the right thing based on standard SSDT project structures,
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
8 but it is the user's responsibility to ensure it's correct.
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
9
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
10 The script does NOT "hg push --new-branch". That step is left for you
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
11 if the branch was created correctly.
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
12
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
13 */
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
14 def project = new Properties()
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
15
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
16 if (new File('gradle.properties').exists() ) {
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
17 project.load(new File('gradle.properties').newInputStream())
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
18 }
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
19
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
20 println "\nCurrent project:"
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
21 println "\tversion: " + project.version ?: "Unknown"
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
22 println "-" * 20
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
23
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
24 if (args.size() < 2) {
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
25 println """
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
26 usage: release.groovy {releaseVersion} {nextVersion}\n
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
27 e.g: release.groovy 1.6.0 1.7.0 (SNAPSHOT will be added automatically)
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
28
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
29 If release ends in ".0", then will create 'release' stream, otherwise 'hotfix'.
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
30 For hotfix, current working branch should be the release branch.
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
31
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
32 Recommend that this script be executed in a fresh clone of the repo.
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
33
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
34 ** Any uncommitted changes in the working directory will be committed with
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
35 the initial setting of the version. This are assumed to be
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
36 'latest.integration' changes.
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
37 """
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
38
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
39 System.exit(0)
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
40 }
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
41
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
42 def releaseVersion = args[0]
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
43 def nextVersion = args[1]
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
44 def hotfix = !releaseVersion.endsWith('.0')
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
45 def stream = hotfix ? 'hotfix' : 'release'
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
46
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
47 println "Creating ${hotfix ? 'hotfix' : 'release'} branch for $releaseVersion"
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
48
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
49 checkForSnapshots()
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
50
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
51 println "hg flow $stream start v${releaseVersion} --dry-run".execute().text
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
52
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
53 println "Continue? Enter = Yes, ^C to cancel"
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
54 System.in.newReader().readLine()
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
55
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
56 updateVersion(releaseVersion)
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
57
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
58 println 'hg com -m "release: set release version"'.execute().text
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
59
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
60 println "hg flow ${stream} start v${releaseVersion} --dirty".execute().text
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
61
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
62 println "hg update default".execute().text
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
63
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
64 updateVersion(nextVersion + ".SNAPSHOT")
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
65
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
66 println 'hg com -m "release: set next release version"'.execute().text
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
67
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
68 println "hg update ${stream}/v${releaseVersion}".execute().text
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
69
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
70 println "Done! Created $releaseVersion $stream branch."
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
71 println " Verify the branch created correctly then push the new branch."
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
72 println " If any problems, then delete repo and clone fresh repository."
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
73
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
74 def updateVersion(String newVersion) {
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
75
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
76 new File('gradle.properties').write(
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
77 new File('gradle.properties').text.replaceAll(/version=(.*)/,"version=$newVersion")
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
78 )
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
79 }
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
80
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
81 def checkForSnapshots() {
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
82 def lines = new File('gradle.properties').readLines() + new File('build.gradle').readLines()
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
83 def snapshots = lines.collect { it.trim() }.findAll{
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
84 it.contains('.SNAPSHOT') && !it.startsWith('version=') ||
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
85 it.contains('latest.') && (it.startsWith('compile') || it.startsWith('runtime'))
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
86 }
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
87 if (snapshots) {
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
88 println "project contains SNAPSHOT dependencies: \n\t" + snapshots.join('\n\t')
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
89 System.exit(1)
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
90 }
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
91
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
92 }
f200b931ea9d add release and hgflow scripts
smith@nwoca.org
parents:
diff changeset
93