[MM-19636] make file names consistent (#1186)

* added jq

* add verbose message

* add another option for getting the path of npm

* use package.json to get desktop version

* add componentdownload property as dinamic

* fix innertext

* add namespace to element

* remove v from version
This commit is contained in:
Guillermo Vayá
2020-02-11 11:06:43 +01:00
committed by GitHub
parent 3c35767df5
commit 217947b906
4 changed files with 41 additions and 27 deletions

View File

@@ -184,51 +184,47 @@ function Run-BuildId {
# candle.exe : error CNDL0001 : Value was either too large or too small for an Int32. # candle.exe : error CNDL0001 : Value was either too large or too small for an Int32.
# Exception Type: System.OverflowException # Exception Type: System.OverflowException
# Add the revision only if we are not building a tag # Add the revision only if we are not building a tag
Print-Info "Checking build id tag..." $version = "$(jq -r '.version' package.json)"
if ($env:APPVEYOR_REPO_TAG -eq $true) { $winVersion = "$($version -Replace '-','.' -Replace '[^0-9.]')"
$version = "$env:APPVEYOR_REPO_TAG_NAME"
} else {
$version = "$(git describe --tags $(git rev-list --tags --max-count=1))"
}
Print-Info "Checking build id tag validity... [$version]" Print-Info "Checking build id tag validity... [$version]"
[version]$appVersion = New-Object -TypeName System.Version [version]$appVersion = New-Object -TypeName System.Version
[void][version]::TryParse($($version -Replace '-','.' -Replace '[^0-9.]'), [ref]$appVersion) [void][version]::TryParse($winVersion, [ref]$appVersion)
if (!($appVersion)) { if (!($appVersion)) {
Print-Error "Non parsable tag detected. Fallbacking to version 0.0.0." # if we couldn't parse, it might be a -develop or something similar, so we just add a
$version = "0.0.0" # number there that will change overtime. Most likely this is a PR to be tested
$revision = "$(git rev-list --all --count)"
$winVersion = "$($version -Replace '-.*').${revision}"
[void][version]::TryParse($winVersion, [ref]$appVersion)
if (!($appVersion)) {
Print-Error "Non parsable tag detected. Fallbacking to version 0.0.0."
$version = "0.0.0"
}
} }
Print-Info -NoNewLine "Getting build id version..." Print-Info -NoNewLine "Getting build id version..."
$env:COM_MATTERMOST_MAKEFILE_BUILD_ID = $version $env:COM_MATTERMOST_MAKEFILE_BUILD_ID = "$version"
Print " [$env:COM_MATTERMOST_MAKEFILE_BUILD_ID]" Print " [$env:COM_MATTERMOST_MAKEFILE_BUILD_ID]"
Print-Info -NoNewLine "Getting build id version for msi..." Print-Info -NoNewLine "Getting build id version for msi..."
$env:COM_MATTERMOST_MAKEFILE_BUILD_ID_MSI = ($version -Replace '-','.' -Replace '[^0-9.]').Split('.')[0..3] -Join '.' $env:COM_MATTERMOST_MAKEFILE_BUILD_ID_MSI = $winVersion.Split('.')[0..3] -Join '.'
Print " [$env:COM_MATTERMOST_MAKEFILE_BUILD_ID_MSI]" Print " [$env:COM_MATTERMOST_MAKEFILE_BUILD_ID_MSI]"
Print-Info -NoNewLine "Getting build id version for node/npm..." Print-Info -NoNewLine "Getting build id version for node/npm..."
$env:COM_MATTERMOST_MAKEFILE_BUILD_ID_NODE = ($version -Replace '^v').Split('.')[0..2] -Join '.' $env:COM_MATTERMOST_MAKEFILE_BUILD_ID_NODE = $version
Print " [$env:COM_MATTERMOST_MAKEFILE_BUILD_ID_NODE]" Print " [$env:COM_MATTERMOST_MAKEFILE_BUILD_ID_NODE]"
Print-Info "Patching version from msi xml descriptor..." Print-Info "Patching version from msi xml descriptor..."
$msiDescriptorFileName = "scripts\msi_installer.wxs" $msiDescriptorFileName = "scripts\msi_installer.wxs"
$msiDescriptor = [xml](Get-Content $msiDescriptorFileName) $msiDescriptor = [xml](Get-Content $msiDescriptorFileName)
$msiDescriptor.Wix.Product.Version = [string]$env:COM_MATTERMOST_MAKEFILE_BUILD_ID_MSI $msiDescriptor.Wix.Product.Version = [string]$env:COM_MATTERMOST_MAKEFILE_BUILD_ID_MSI
$ComponentDownload = $msiDescriptor.CreateElement("Property", "http://schemas.microsoft.com/wix/2006/wi")
$ComponentDownload.InnerText = "https://releases.mattermost.com/desktop/$version/mattermost-desktop-$version-`$(var.Platform).msi"
$ComponentDownload.SetAttribute("Id", "ComponentDownload")
$msiDescriptor.Wix.Product.AppendChild($ComponentDownload)
$msiDescriptor.Save($msiDescriptorFileName) $msiDescriptor.Save($msiDescriptorFileName)
Print-Info "Modified Wix XML"
Print-Info "Patching version from electron package.json..."
$packageFileName = "package.json"
$package = Get-Content $packageFileName -Raw | ConvertFrom-Json
$package.version = [string]$env:COM_MATTERMOST_MAKEFILE_BUILD_ID_NODE
$package | ConvertTo-Json | Set-Content $packageFileName
Print-Info "Patching version from electron src\package.json..."
$packageFileName = "src\package.json"
$package = Get-Content $packageFileName -Raw | ConvertFrom-Json
$package.version = [string]$env:COM_MATTERMOST_MAKEFILE_BUILD_ID_NODE
$package | ConvertTo-Json | Set-Content $packageFileName
} }
function Run-BuildChangelog { function Run-BuildChangelog {

View File

@@ -64,6 +64,11 @@ function Check-Deps {
if ($verbose) { Print-Error "signtool dependency missing." } if ($verbose) { Print-Error "signtool dependency missing." }
$missing += "signtool" $missing += "signtool"
} }
if ($verbose) { Print-Info "Checking jq dependency..." }
if (!(Check-Command "jq")) {
if ($verbose) { Print-Error "jq dependency missing." }
$missing += "jq"
}
if ($throwable -and $missing.Count -gt 0) { if ($throwable -and $missing.Count -gt 0) {
throw "com.mattermost.makefile.deps.missing" throw "com.mattermost.makefile.deps.missing"
@@ -128,6 +133,11 @@ function Install-Deps {
choco install nodejs-lts --yes choco install nodejs-lts --yes
break; break;
} }
"jq" {
Print-Info "Installing jq"
choco install jq --yes
break;
}
} }
Print-Info "Refreshing PATH..." Print-Info "Refreshing PATH..."

View File

@@ -35,7 +35,7 @@
- there are any changes in the feature hierarchy (child - there are any changes in the feature hierarchy (child
feature moving out of a parent, or a parent feature getting a new child). feature moving out of a parent, or a parent feature getting a new child).
--> -->
<Product Id="*" UpgradeCode="8523DAF0-699D-4CC7-9A65-C5E696A9DE6D" Name="Mattermost" Manufacturer="Mattermost, Inc." Language="1033" Codepage="1252" Version="4.1.2"> <Product Id="*" UpgradeCode="8523DAF0-699D-4CC7-9A65-C5E696A9DE6D" Name="Mattermost" Manufacturer="Mattermost, Inc." Language="1033" Codepage="1252" Version="0.0.0">
<!-- <!--
perMachine installs the app system wide (ALLUSERS is set to 1) perMachine installs the app system wide (ALLUSERS is set to 1)
src.: https://www.joyofsetup.com/2008/04/01/new-wix-feature-setting-package-installation-scope/ src.: https://www.joyofsetup.com/2008/04/01/new-wix-feature-setting-package-installation-scope/
@@ -134,7 +134,10 @@
<Property Id="ARPCONTACT">https://pre-release.mattermost.com</Property> <Property Id="ARPCONTACT">https://pre-release.mattermost.com</Property>
<Property Id="ARPHELPLINK">https://docs.mattermost.com/</Property> <Property Id="ARPHELPLINK">https://docs.mattermost.com/</Property>
<Property Id="ARPURLINFOABOUT">https://mattermost.com/</Property> <Property Id="ARPURLINFOABOUT">https://mattermost.com/</Property>
<Property Id="ComponentDownload"><![CDATA[https://releases.mattermost.com/desktop/4.1.2/mattermost-setup-4.1.2-win64.msi]]></Property> <!--
Next line will be added by `Makefile.ps1`, leaving it here for reference, as it will be added before constructing the MSI
<Property Id="ComponentDownload">https://releases.mattermost.com/desktop/0.0.0/mattermost-desktop-0.0.0-$(var.Platform).msi</Property>
-->
<Property Id="ADDDESKTOPSHORTCUT">true</Property> <Property Id="ADDDESKTOPSHORTCUT">true</Property>
<Property Id="ADDSTARTMENUSHORTCUT">true</Property> <Property Id="ADDSTARTMENUSHORTCUT">true</Property>
<UI> <UI>

View File

@@ -158,6 +158,11 @@ function Get-NpmDir {
if ([System.IO.File]::Exists("$npmDir\npm.cmd")) { if ([System.IO.File]::Exists("$npmDir\npm.cmd")) {
return $npmDir return $npmDir
} }
$progFile = ${env:ProgramW6432}
$npmDir = Join-Path -Path "$progFile" -ChildPath "nodejs"
if ([System.IO.File]::Exists("$npmDir\npm.cmd")) {
return $npmDir
}
return $null return $null
} }