From bb2348d65d45672dac4c18db7330a9d06de6fc66 Mon Sep 17 00:00:00 2001 From: PlatonAI Date: Wed, 3 Jul 2024 00:39:47 +0800 Subject: [PATCH] Imps: 1. improve release scripts --- bin/pulsar.ps1 | 10 +++++++--- bin/release/next-minor.ps1 | 24 +++++++++++++----------- bin/release/next-minor.sh | 6 +++--- bin/release/release.ps1 | 12 ++++++++---- bin/version.ps1 | 13 +++++++------ 5 files changed, 38 insertions(+), 27 deletions(-) diff --git a/bin/pulsar.ps1 b/bin/pulsar.ps1 index b80309f7d..d6c363c71 100644 --- a/bin/pulsar.ps1 +++ b/bin/pulsar.ps1 @@ -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 } diff --git a/bin/release/next-minor.ps1 b/bin/release/next-minor.ps1 index 492c51eae..ceda4179b 100644 --- a/bin/release/next-minor.ps1 +++ b/bin/release/next-minor.ps1 @@ -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] @@ -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 "v$VERSION", "v$NEXT_VERSION") | 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 diff --git a/bin/release/next-minor.sh b/bin/release/next-minor.sh index 9eedee5ba..1da67cb6e 100755 --- a/bin/release/next-minor.sh +++ b/bin/release/next-minor.sh @@ -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 diff --git a/bin/release/release.ps1 b/bin/release/release.ps1 index 11bf93c03..c083e1f39 100644 --- a/bin/release/release.ps1 +++ b/bin/release/release.ps1 @@ -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 diff --git a/bin/version.ps1 b/bin/version.ps1 index 043966a1b..7f5823e37 100644 --- a/bin/version.ps1 +++ b/bin/version.ps1 @@ -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