Skip to content

Commit

Permalink
Imps: 1. improve release scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
platonai committed Jul 2, 2024
1 parent 9b58554 commit bb2348d
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 27 deletions.
10 changes: 7 additions & 3 deletions bin/pulsar.ps1
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
$ErrorActionPreference = "Stop"

$BIN = Split-Path -Parent $MyInvocation.MyCommand.Definition
$APP_HOME = (Resolve-Path "$BIN/..").Path
# Find the first parent directory containing the VERSION file
$AppHome=(Get-Item -Path $MyInvocation.MyCommand.Path).Directory
while ($AppHome -ne $null -and !(Test-Path "$AppHome/VERSION")) {
$AppHome=$AppHome.Parent
}
cd $AppHome

$UBERJAR = Join-Path $PWD "target\PulsarRPA.jar"
if (-not (Test-Path $UBERJAR)) {
$SERVER_HOME = Join-Path $APP_HOME "pulsar-app\pulsar-master"
$SERVER_HOME = Join-Path $AppHome "pulsar-app\pulsar-master"
Copy-Item (Join-Path $SERVER_HOME "target\PulsarRPA.jar") -Destination $UBERJAR
}

Expand Down
24 changes: 13 additions & 11 deletions bin/release/next-minor.ps1
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Set up variables
$bin = Split-Path -Parent $MyInvocation.MyCommand.Definition
$bin = (Resolve-Path "$bin\..").Path
$APP_HOME = (Resolve-Path "$bin\..").Path
# Find the first parent directory containing the VERSION file
$AppHome=(Get-Item -Path $MyInvocation.MyCommand.Path).Directory
while ($AppHome -ne $null -and !(Test-Path "$AppHome/VERSION")) {
$AppHome=$AppHome.Parent
}
cd $AppHome

# Get version information
$SNAPSHOT_VERSION = Get-Content "$APP_HOME\VERSION" -TotalCount 1
$SNAPSHOT_VERSION = Get-Content "$AppHome\VERSION" -TotalCount 1
$VERSION = $SNAPSHOT_VERSION -replace "-SNAPSHOT", ""
$parts = $VERSION -split "\."
$PREFIX = $parts[0] + "." + $parts[1]
Expand All @@ -18,21 +20,21 @@ $NEXT_SNAPSHOT_VERSION = "$NEXT_VERSION-SNAPSHOT"
Write-Host "New version: $NEXT_SNAPSHOT_VERSION"

# Update VERSION file
$NEXT_SNAPSHOT_VERSION | Set-Content "$APP_HOME\VERSION"
$NEXT_SNAPSHOT_VERSION | Set-Content "$AppHome\VERSION"

# Update $APP_HOME/pom.xml
$pomXmlPath = "$APP_HOME\pom.xml"
# Update $AppHome/pom.xml
$pomXmlPath = "$AppHome\pom.xml"
((Get-Content $pomXmlPath) -replace "<tag>v$VERSION</tag>", "<tag>v$NEXT_VERSION</tag>") | Set-Content $pomXmlPath

# Update pom.xml files
Get-ChildItem "$APP_HOME" -Depth 3 -Filter 'pom.xml' -Recurse | ForEach-Object {
Get-ChildItem "$AppHome" -Depth 3 -Filter 'pom.xml' -Recurse | ForEach-Object {
((Get-Content $_.FullName) -replace $SNAPSHOT_VERSION, $NEXT_SNAPSHOT_VERSION) | Set-Content $_.FullName
}

# Files containing the version number to upgrade
$VERSION_AWARE_FILES = @(
"$APP_HOME\README.md"
"$APP_HOME\README-CN.md"
"$AppHome\README.md"
"$AppHome\README-CN.md"
)

# Replace version numbers in files
Expand Down
6 changes: 3 additions & 3 deletions bin/release/next-minor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ find "$APP_HOME" -name 'pom.xml' -exec sed -i "s/$SNAPSHOT_VERSION/$NEXT_SNAPSHO

# The following files contains the version number to upgrade
VERSION_AWARE_FILES=(
"$APP_HOME/README.adoc"
"$APP_HOME/README.md"
"$APP_HOME/README.md"
"$APP_HOME/README.md"
"$APP_HOME/README.md"
"$APP_HOME/README-CN.adoc"
"$APP_HOME/README-CN.md"
)
# replace version numbers to be the next numbers in files
for F in "${VERSION_AWARE_FILES[@]}"; do
Expand Down
12 changes: 8 additions & 4 deletions bin/release/release.ps1
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# Set up variables
$bin = Split-Path -Parent $MyInvocation.MyCommand.Definition
$APP_HOME = (Resolve-Path "$bin\..").Path
# Find the first parent directory containing the VERSION file
$AppHome=(Get-Item -Path $MyInvocation.MyCommand.Path).Directory
while ($AppHome -ne $null -and !(Test-Path "$AppHome/VERSION")) {
$AppHome=$AppHome.Parent
}
cd $AppHome

$gitExe = "git" # Assuming git is in the system PATH

# Switching remote URLs from HTTPS to SSH
& $gitExe remote set-url origin git@github.com:platonai/PulsarRPA.git

# Get version information
$SNAPSHOT_VERSION = Get-Content "$APP_HOME\VERSION" -TotalCount 1
$SNAPSHOT_VERSION = Get-Content "$AppHome\VERSION" -TotalCount 1
$VERSION =$SNAPSHOT_VERSION -replace "-SNAPSHOT", ""
$LAST_COMMIT_ID = &$gitExe log --format="%H" -n 1
$BRANCH = &$gitExe branch --show-current
Expand Down
13 changes: 7 additions & 6 deletions bin/version.ps1
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/usr/bin/env ps1

$bin = Split-Path $MyInvocation.MyCommand.Path
Push-Location $bin -ErrorAction SilentlyContinue; Pop-Location
$APP_HOME = Split-Path $bin
# Find the first parent directory containing the VERSION file
$AppHome=(Get-Item -Path $MyInvocation.MyCommand.Path).Directory
while ($AppHome -ne $null -and !(Test-Path "$AppHome/VERSION")) {
$AppHome=$AppHome.Parent
}
cd $AppHome

$VERSION = "v$(Get-Content "$APP_HOME/VERSION")"
$VERSION = "v$(Get-Content "$AppHome/VERSION")"

if ($args.Count -gt 0 -and $args[0] -eq "-v") {
# dynamically pull more interesting stuff from latest git commit
Expand Down

0 comments on commit bb2348d

Please sign in to comment.