mirror of
https://github.com/cmderdev/cmder.git
synced 2024-11-10 09:49:12 +08:00
new version handle logic
This commit is contained in:
parent
3965852c26
commit
b36b8a4cb3
@ -58,14 +58,14 @@ $ScriptRoot = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition
|
||||
$cmder_root = $ScriptRoot.replace("\scripts","")
|
||||
|
||||
# Dot source util functions into this scope
|
||||
. ".\utils.ps1"
|
||||
. "$PSScriptRoot\utils.ps1"
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
Push-Location -Path $saveTo
|
||||
$sources = Get-Content $sourcesPath | Out-String | Convertfrom-Json
|
||||
|
||||
# Get the version string
|
||||
$Version = Get-VersionStr ($PSScriptRoot + '\..\' + 'CHANGELOG.md')
|
||||
$version = Get-VersionStr
|
||||
|
||||
# Check for requirements
|
||||
Ensure-Exists $sourcesPath
|
||||
@ -119,13 +119,13 @@ Pop-Location
|
||||
|
||||
if($Compile) {
|
||||
Push-Location -Path $launcher
|
||||
Create-RC $Version ($launcher + '\src\version.rc2');
|
||||
Create-RC $version ($launcher + '\src\version.rc2');
|
||||
msbuild CmderLauncher.vcxproj /t:Clean,Build /p:configuration=Release
|
||||
if ($LastExitCode -ne 0) {
|
||||
throw "msbuild failed to build the executable."
|
||||
}
|
||||
else {
|
||||
Write-Verbose "successfully built Cmder v$Version!"
|
||||
Write-Verbose "successfully built Cmder v$version!"
|
||||
}
|
||||
Pop-Location
|
||||
} else {
|
||||
|
@ -48,7 +48,7 @@ $targets = @{
|
||||
Delete-Existing "..\Version*"
|
||||
Delete-Existing "..\build\*"
|
||||
|
||||
$version = Invoke-Expression "git describe --abbrev=0 --tags"
|
||||
$version = Get-VersionStr
|
||||
(New-Item -ItemType file "$cmderRoot\Version $version") | Out-Null
|
||||
|
||||
foreach ($t in $targets.GetEnumerator()) {
|
||||
|
@ -62,7 +62,45 @@ function Digest-Hash($path) {
|
||||
return Invoke-Expression "md5sum $path"
|
||||
}
|
||||
|
||||
function Get-VersionStr($file) {
|
||||
function Get-VersionStr() {
|
||||
|
||||
# Clear existing variable
|
||||
Clear-Variable -name string
|
||||
|
||||
# Determine if git is available
|
||||
if (Get-Command "git.exe" -ErrorAction SilentlyContinue)
|
||||
{
|
||||
|
||||
# Determine if the current diesctory is a git repository
|
||||
$GitPresent = Invoke-Expression "git rev-parse --is-inside-work-tree" -erroraction SilentlyContinue 2>$null
|
||||
|
||||
if ( $GitPresent -eq 'true' )
|
||||
{
|
||||
$string = Invoke-Expression "git describe --abbrev=0 --tags"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# Fallback used when Git is not available
|
||||
if ( -not($string) )
|
||||
{
|
||||
$string = Parse-Changelog ($PSScriptRoot + '\..\' + 'CHANGELOG.md')
|
||||
}
|
||||
|
||||
# Add build number, if AppVeyor is present
|
||||
if ( $Env:APPVEYOR -eq 'True' )
|
||||
{
|
||||
$string = $string + '.' + $Env:APPVEYOR_BUILD_NUMBER
|
||||
}
|
||||
|
||||
# Remove starting 'v' characters
|
||||
$string = $string -replace '^v+','' # normalize version string
|
||||
|
||||
return $string
|
||||
|
||||
}
|
||||
|
||||
function Parse-Changelog($file) {
|
||||
|
||||
# Define the regular expression to match the version string from changelog
|
||||
[regex]$regex = '^## \[(?<version>[\w\-\.]+)\]\([^\n()]+\)\s+\([^\n()]+\)$';
|
||||
@ -75,7 +113,7 @@ function Get-VersionStr($file) {
|
||||
|
||||
function Create-RC($string, $path) {
|
||||
|
||||
$version = $string + '.0.0.0.0' # padding for version string
|
||||
$version = $string + '.0.0.0.0' # padding for version string
|
||||
|
||||
if ( !(Test-Path "$path.sample") ) {
|
||||
throw "Invalid path provided for resources file."
|
||||
|
Loading…
Reference in New Issue
Block a user