mirror of
https://github.com/austinried/subtracks.git
synced 2025-12-29 17:39:27 +01:00
add scripts for bumping versions
This commit is contained in:
parent
ac175d091f
commit
a91f455534
@ -135,7 +135,7 @@ android {
|
|||||||
minSdkVersion rootProject.ext.minSdkVersion
|
minSdkVersion rootProject.ext.minSdkVersion
|
||||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0.0"
|
versionName '1.0.0'
|
||||||
}
|
}
|
||||||
splits {
|
splits {
|
||||||
abi {
|
abi {
|
||||||
@ -230,3 +230,76 @@ task copyDownloadableDepsToLibs(type: Copy) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
|
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
|
||||||
|
|
||||||
|
class Version {
|
||||||
|
|
||||||
|
private int major
|
||||||
|
private int minor
|
||||||
|
private int patch
|
||||||
|
private int code
|
||||||
|
|
||||||
|
Version(int code, String version) {
|
||||||
|
this.code = code
|
||||||
|
|
||||||
|
def (major, minor, patch) = version.tokenize('.')
|
||||||
|
this.major = major.toInteger()
|
||||||
|
this.minor = minor.toInteger()
|
||||||
|
this.patch = patch.toInteger()
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
void bumpMajor() {
|
||||||
|
major += 1
|
||||||
|
minor = 0
|
||||||
|
patch = 0
|
||||||
|
|
||||||
|
code += 1
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
void bumpMinor() {
|
||||||
|
minor += 1
|
||||||
|
patch = 0
|
||||||
|
|
||||||
|
code += 1
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
void bumpPatch() {
|
||||||
|
patch += 1
|
||||||
|
code += 1
|
||||||
|
}
|
||||||
|
|
||||||
|
String getName() { "$major.$minor.$patch" }
|
||||||
|
|
||||||
|
int getCode() { code }
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.addRule("Pattern: bump<TYPE>Version") { String taskName ->
|
||||||
|
if (taskName.matches("bump(Major|Minor|Patch)Version")) {
|
||||||
|
task(taskName) {
|
||||||
|
doLast {
|
||||||
|
String type = (taskName - 'bump' - 'Version')
|
||||||
|
|
||||||
|
println "Bumping ${type.toLowerCase()} version…"
|
||||||
|
|
||||||
|
int oldVersionCode = android.defaultConfig.versionCode
|
||||||
|
String oldVersionName = android.defaultConfig.versionName
|
||||||
|
|
||||||
|
version = new Version(oldVersionCode, oldVersionName)
|
||||||
|
version."bump$type"()
|
||||||
|
|
||||||
|
String newVersionName = version.getName()
|
||||||
|
String newVersionCode = version.getCode()
|
||||||
|
|
||||||
|
println "$oldVersionName ($oldVersionCode) → $newVersionName ($newVersionCode)"
|
||||||
|
|
||||||
|
def updated = buildFile.getText()
|
||||||
|
updated = updated.replaceFirst("versionName '$oldVersionName'", "versionName '$newVersionName'")
|
||||||
|
updated = updated.replaceFirst("versionCode $oldVersionCode", "versionCode $newVersionCode")
|
||||||
|
|
||||||
|
buildFile.setText(updated)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -12,7 +12,10 @@
|
|||||||
"license:npm": "yarn licenses generate-disclaimer --production | grep -v '^info\\s\"\\?fsevents' > android/app/src/main/assets/licenses/npm_licenses.txt",
|
"license:npm": "yarn licenses generate-disclaimer --production | grep -v '^info\\s\"\\?fsevents' > android/app/src/main/assets/licenses/npm_licenses.txt",
|
||||||
"license:android": "./android/gradlew -p android checkLicenses && ./android/gradlew -p android generateLicensePage",
|
"license:android": "./android/gradlew -p android checkLicenses && ./android/gradlew -p android generateLicensePage",
|
||||||
"license:update": "./android/gradlew -p android updateLicenses",
|
"license:update": "./android/gradlew -p android updateLicenses",
|
||||||
"license": "yarn license:npm && yarn license:android"
|
"license": "yarn license:npm && yarn license:android",
|
||||||
|
"version:patch": "yarn version --patch --no-git-tag-version && ./android/gradlew -p android bumpPatchVersion",
|
||||||
|
"version:minor": "yarn version --minor --no-git-tag-version && ./android/gradlew -p android bumpMinorVersion",
|
||||||
|
"version:major": "yarn version --major --no-git-tag-version && ./android/gradlew -p android bumpMajorVersion"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@react-native-async-storage/async-storage": "^1.15.5",
|
"@react-native-async-storage/async-storage": "^1.15.5",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user