Skip to content

Commit

Permalink
Add script to make it easier to make a patch release.
Browse files Browse the repository at this point in the history
  • Loading branch information
metaprime committed May 9, 2017
1 parent df64597 commit 63e7e14
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions patch.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
Param (
[Parameter(Mandatory=$True)]
[string]$message
)

# This script will:
# - read current version
# - increment patch version
# - update version in a few places
# - insert new line in ripme.json with $message

$ripmeJson = (Get-Content "ripme.json") -join "`n" | ConvertFrom-Json
$currentVersion = $ripmeJson.latestVersion

Write-Output (("Current version", $currentVersion) -join ' ')

$versionFields = $currentVersion.split('.')
$patchCurr = [int]($versionFields[2])
$patchNext = $patchCurr + 1
$majorMinor = $versionFields[0..1]
$majorMinorPatch = $majorMinor + $patchNext
$nextVersion = $majorMinorPatch -join '.'

Write-Output (("Updating to", $nextVersion) -join ' ')

$substExpr = "s/${currentVersion}/${nextVersion}/"
sed src/main/java/com/rarchives/ripme/ui/UpdateUtils.java -i -e "${substExpr}"
git grep "DEFAULT_VERSION.*${nextVersion}" src/main/java/com/rarchives/ripme/ui/UpdateUtils.java

$substExpr = "s/\`"latestVersion\`" : \`"${currentVersion}\`"/\`"latestVersion\`" : \`"${nextVersion}\`"/"
sed ripme.json -i -e "${substExpr}"
git grep "latestVersion" ripme.json

$substExpr = "s/<version>${currentVersion}/<version>${nextVersion}/"
sed pom.xml -i -e "${substExpr}"
git grep "<version>${nextVersion}" pom.xml

$commitMessage = "${nextVersion}: ${message}"

$ripmeJsonLines = Get-Content "ripme.json"
$ripmeJsonHead = $ripmeJsonLines[0..2]
$ripmeJsonRest = $ripmeJsonLines[3..$ripmeJsonLines.length]
$changelogLine = " `"${commitMessage}`","
$updatedLines = $ripmeJsonHead + $changelogLine + $ripmeJsonRest + ""
$outputContent = $updatedLines -join "`n"

$outputPath = (Resolve-Path .\ripme.json).Path
$Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False
[System.IO.File]::WriteAllText($outputPath, $outputContent, $Utf8NoBomEncoding)

git add -u
git commit -m $commitMessage
git tag $nextVersion

0 comments on commit 63e7e14

Please sign in to comment.