Skip to content

Commit 6e3e0b1

Browse files
committed
Improved release script
1 parent a1d7df9 commit 6e3e0b1

File tree

2 files changed

+43
-7
lines changed

2 files changed

+43
-7
lines changed

kotlin/internal/tool/prepare-release/src/main/java/com/squareup/stoic/preparerelease/Main.kt

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ fun main(args: Array<String>) {
3232
exitProcess(1)
3333
}
3434

35-
// TODO: verify git is clean
35+
ensureCleanGitRepo(stoicDir)
3636

3737
println("running test/regression-check.sh... (this will take a while)")
3838
check(ProcessBuilder("$stoicDir/test/regression-check.sh").inheritIO().start().waitFor() == 0)
@@ -58,15 +58,36 @@ fun main(args: Array<String>) {
5858

5959
versionFile.writeText("$postReleaseVersion\n")
6060

61+
val releaseTag = "v$releaseVersion"
6162
println(
6263
"""
64+
65+
66+
67+
Release version: $releaseVersion
68+
Release tag: $releaseTag
6369
Release prepared successfully: $releaseTar
6470
Version incremented to: $postReleaseVersion
71+
72+
73+
Next steps:
74+
75+
# Make sure you're in the right directory
76+
cd $stoicDir
77+
78+
# tag the release and push it
79+
git tag $releaseTag && git push origin $releaseTag
80+
81+
# Commit the version bump and push it
82+
git add prebuild/STOIC_VERSION && git commit -m "$postReleaseVersion version bump" && git push
83+
84+
# Upload the release to Github
85+
gh release create $releaseTag $releaseTar --title $releaseTag
86+
87+
88+
6589
""".trimIndent()
6690
)
67-
// TODO:
68-
// prompt the user to commit/push the changes to the version file and
69-
// upload the release
7091
}
7192

7293
fun validateSemver(version: String): Boolean =
@@ -77,3 +98,18 @@ fun incrementSemver(version: String): String {
7798
val parts = clean.split(".").map { it.toInt() }
7899
return "${parts[0]}.${parts[1]}.${parts[2] + 1}-SNAPSHOT"
79100
}
101+
102+
fun ensureCleanGitRepo(stoicDir: File) {
103+
val process = ProcessBuilder("git", "status", "--porcelain")
104+
.directory(stoicDir)
105+
.redirectErrorStream(true)
106+
.start()
107+
108+
val output = process.inputStream.bufferedReader().readText().trim()
109+
process.waitFor()
110+
111+
if (output.isNotEmpty()) {
112+
System.err.println("The git repository has uncommitted changes or untracked files. Aborting...")
113+
exitProcess(1)
114+
}
115+
}

prepare-release.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ cd "$script_dir"/kotlin
88

99
echo
1010
echo
11-
echo 'Next steps:'
12-
echo '1. commit version change and push (git commit -m "version bump" && git push)'
13-
echo '2. Upload /Users/tomm/Development/stoic/releases/stoic-0.0.2.tar.gz to Github Releases'
11+
echo 'Release prepared locally.'
12+
echo 'To actually complete the release, see "Next Steps" above'
13+
echo
1414
echo

0 commit comments

Comments
 (0)