diff --git a/Apollo_releasing.main.kts b/Apollo_releasing.main.kts new file mode 100644 index 000000000..4a7a3cfbb --- /dev/null +++ b/Apollo_releasing.main.kts @@ -0,0 +1,114 @@ +#!/usr/bin/env kotlin + +import java.io.File + +/** + * A script to run locally in order to make a release. + * + * You need kotlin 1.3.70+ installed on your machine + */ + +fun runCommand(vararg args: String): String { + val builder = ProcessBuilder(*args) + .redirectError(ProcessBuilder.Redirect.INHERIT) + + val process = builder.start() + val ret = process.waitFor() + + val output = process.inputStream.bufferedReader().readText() + if (ret != 0) { + throw java.lang.Exception("command ${args.joinToString(" ")} failed:\n$output") + } + + return output +} + +fun setCurrentVersion(version: String) { + val gradleProperties = File("gradle.properties") + var newContent = gradleProperties.readLines().map { + it.replace(Regex("VERSION_NAME=.*"), "VERSION_NAME=$version") + }.joinToString(separator = "\n", postfix = "\n") + gradleProperties.writeText(newContent) + + val dependencies = File("gradle/dependencies.gradle") + // apollo : '1.2.2', // This should only be used by apollo-gradle-plugin-incubating:test to get the artifacts locally + newContent = dependencies.readLines().map { + it.replace(Regex("( *apollo *: *').*('.*)")) { + "${it.groupValues[1]}$version${it.groupValues[2]}" + } + }.joinToString(separator = "\n", postfix = "\n") + dependencies.writeText(newContent) +} + +fun getCurrentVersion(): String { + val versionLines = File("gradle.properties").readLines().filter { it.startsWith("VERSION_NAME=") } + + require(versionLines.size > 0) { + "cannot find the version in ./gradle.properties" + } + + require(versionLines.size == 1) { + "multiple versions found in ./gradle.properties" + } + + val regex = Regex("VERSION_NAME=(.*)-SNAPSHOT") + val matchResult = regex.matchEntire(versionLines.first()) + + require(matchResult != null) { + "'${versionLines.first()}' doesn't match VERSION_NAME=(.*)-SNAPSHOT" + } + + return matchResult.groupValues[1] +} + +fun getNext(version: String, position: Int) = version.split(".").mapIndexed { index, s -> + when { + index == position -> (s.toInt() + 1).toString() + index > position -> "0" + else -> s + } +}.joinToString(".") + +fun getNextPatch(version: String) = getNext(version, 2) +fun getNextMinor(version: String) = getNext(version, 1) +fun getNextMajor(version: String) = getNext(version, 0) + +if (runCommand("git", "status", "--porcelain").isNotEmpty()) { + println("Your git repo is not clean. Make sur to stash or commit your changes before making a release") + System.exit(1) +} + +val version = getCurrentVersion() +val nextPatch = getNextPatch(version) +val nextMinor = getNextMinor(version) +val nextPatchAfterMinor = getNextPatch(nextMinor) +val nextMajor = getNextMajor(version) +val nextPatchAfterMajor = getNextPatch(nextMajor) + +var tagVersion: String = "" + +while (tagVersion.isEmpty()) { + println("Current version is '$version-SNAPSHOT'.") + println("1. patch: tag $version and bump to $nextPatch") + println("2. minor: tag $nextMinor and bump to $nextPatchAfterMinor") + println("3. major: tag $nextMajor and bump to $nextPatchAfterMajor") + println("What do you want to do [1/2/3]?") + + val answer = readLine()!!.trim() + when (answer) { + "1" -> tagVersion = version + "2" -> tagVersion = nextMinor + "3" -> tagVersion = nextMajor + } +} + +setCurrentVersion(tagVersion) + +runCommand("git", "commit", "-a", "-m", "release $tagVersion") +runCommand("git", "tag", "v$tagVersion") + +val snapshot = "${getNextPatch(tagVersion)}-SNAPSHOT" +setCurrentVersion(snapshot) +runCommand("git", "commit", "-a", "-m", "version is now $snapshot") + +println("Everything is done. Verify everything is ok and type `git push origin master` to trigger the new version.") diff --git a/CHANGELOG.md b/CHANGELOG.md index 185578fa4..0002b7224 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,6 @@ # Change log for refreshVersions - -## [Unreleased] +## Version 0.9.5 (2020-08-21) This is a **major release** that brings surface-level and internal changes, paving the way for the upcoming 1.0 release. diff --git a/TODO_libs_for_publishing.md b/TODO_libs_for_publishing.md new file mode 100644 index 000000000..c9c3daf8b --- /dev/null +++ b/TODO_libs_for_publishing.md @@ -0,0 +1,11 @@ +## Priority + +- Find a way to keep track of the previous dev versions without is being overwritten by non stable releases. +- Make a script for dev versions. + +## Other +- Open files (with text editor command defaulting to `idea`) + +- Get new version string based on last version(s) and channel(s) +- Update version in README (check side-effects are almost impossible) + diff --git a/docs/Setting-up.adoc b/docs/Setting-up.adoc index 8d298d402..3622ed4a8 100644 --- a/docs/Setting-up.adoc +++ b/docs/Setting-up.adoc @@ -1,7 +1,7 @@ :sectanchors: :gradle_version: 6.4.1 :last_version: 0.9.5 -:last_dev_version: 0.9.5-dev-006 +:last_dev_version: 0.9.5-dev-017 :buildSrc_doc: https://docs.gradle.org/current/userguide/organizing_gradle_projects.html#sec:build_sources :included_builds_support: https://github.com/jmfayard/refreshVersions/issues/205 diff --git a/plugins/version.txt b/plugins/version.txt index 5c11a25a7..03834411d 100644 --- a/plugins/version.txt +++ b/plugins/version.txt @@ -1 +1 @@ -0.9.5-SNAPSHOT +0.9.5 \ No newline at end of file diff --git a/sample-kotlin/build.gradle.kts b/sample-kotlin/build.gradle.kts index fd1c5bf1f..4d4f666ae 100644 --- a/sample-kotlin/build.gradle.kts +++ b/sample-kotlin/build.gradle.kts @@ -13,6 +13,8 @@ buildscript { plugins { kotlin("jvm") + id("org.gradle.hello-world") + //id("io.gitlab.arturbosch.detekt") apply false } group = "de.fayard" @@ -47,6 +49,7 @@ dependencies { api("org.apache.poi:poi:_") api("org.apache.poi:poi-ooxml:_") + //detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:_") } tasks.register("run", JavaExec::class.java) { diff --git a/sample-kotlin/refreshVersions-extra-rules.txt b/sample-kotlin/refreshVersions-extra-rules.txt index 74886adc0..899fc4609 100644 --- a/sample-kotlin/refreshVersions-extra-rules.txt +++ b/sample-kotlin/refreshVersions-extra-rules.txt @@ -1,2 +1,4 @@ org.apache.poi:poi(-*) ^^^^^^.^^^ +io.gitlab.arturbosch.detekt:detekt(-*) + ^^^^^^ diff --git a/sample-kotlin/versions.properties b/sample-kotlin/versions.properties index 3818fdd40..4e2bba617 100644 --- a/sample-kotlin/versions.properties +++ b/sample-kotlin/versions.properties @@ -5,6 +5,13 @@ ## Generated by $ ./gradlew refreshVersions ## Please, don't put extra comments in that file yet, keeping them is not supported yet. +plugin.io.gitlab.arturbosch.detekt=version.detekt + +plugin.org.gradle.hello-world=0.1 +## # available=0.2 + +plugin.org.gradle.hello-world=version.org.gradle..gradle-hello-world-plugin + version.androidx.browser=1.0.0 ## # available=1.2.0-alpha07 ## # available=1.2.0-alpha08 @@ -22,6 +29,7 @@ version.androidx.cardview=1.0.0 version.androidx.core=1.3.1 ## # available=1.4.0-alpha01 ## # available=1.5.0-alpha01 +## # available=1.5.0-alpha02 version.apache.poi=4.0.0 ## # available=4.0.1 @@ -32,6 +40,8 @@ version.apache.poi=4.0.0 version.kotest=4.1.3 ## # available=4.2.0.RC1 ## # available=4.2.0.RC2 +## # available=4.2.0.RC3 +## # available=4.2.0 version.kotlin=1.3.72 ## # available=1.4-M1 @@ -45,6 +55,7 @@ version.kotlinx.coroutines=1.3.8 ## # available=1.3.8-1.4-rc-154 ## # available=1.3.8-1.4.0-rc ## # available=1.3.8-1.4.0-rc-218 +## # available=1.3.9-native-mt ## # available=1.3.9 version.org.gradle..gradle-hello-world-plugin=0.1