mirror of
https://github.com/greenshot/greenshot
synced 2025-07-30 19:50:11 -07:00
Adapting the build.ps1 and templates for AppVeyor
This commit is contained in:
parent
db7d38ef72
commit
4a22a01d31
4 changed files with 32 additions and 191 deletions
|
@ -5,7 +5,7 @@ Apply text and shapes to the screenshot. Offers capture of window, region or ful
|
|||
|
||||
CHANGE LOG:
|
||||
|
||||
@READABLEVERSION@
|
||||
@DETAILVERSION@
|
||||
|
||||
Features:
|
||||
* Added a speech bubble to the editor.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[Format]
|
||||
Type=PortableApps.comFormat
|
||||
Version=@GITVERSION@
|
||||
Version=@VERSION@
|
||||
|
||||
[Details]
|
||||
Name=Greenshot Portable
|
||||
|
@ -21,8 +21,8 @@ CommercialUse=true
|
|||
EULAVersion=true
|
||||
|
||||
[Version]
|
||||
PackageVersion=@GITDETAILVERSION@
|
||||
DisplayVersion=@GITVERSION@
|
||||
PackageVersion=@DETAILVERSION@
|
||||
DisplayVersion=@VERSION@
|
||||
|
||||
[SpecialPaths]
|
||||
Plugins=NONE
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#define ExeName "Greenshot"
|
||||
#define Version "@GITVERSION@"
|
||||
#define Version "@VERSION@"
|
||||
#define DetailVersion "@DETAILVERSION@"
|
||||
|
||||
; Include the scripts to install .NET Framework
|
||||
; See http://www.codeproject.com/KB/install/dotnetfx_innosetup_instal.aspx
|
||||
|
|
212
build.ps1
212
build.ps1
|
@ -22,22 +22,12 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
################################################################
|
||||
|
||||
Add-Type -Assembly System.ServiceModel.Web,System.Runtime.Serialization
|
||||
|
||||
# Collect GIT information
|
||||
$gitversion = git describe --long
|
||||
$gittag = $gitversion -replace '-.*',''
|
||||
$commitversion = $gitversion -replace ($gittag + '-'),'' -replace '-.*',''
|
||||
$githash = $gitversion -replace '.*-',''
|
||||
$version = $gittag + '.' + $commitversion
|
||||
$detailversion = $gittag + '.' + $commitversion + '-' + $githash
|
||||
$readableversion = $gittag + ' build ' + $commitversion + " (" + $githash + ")" + '-UNSTABLE'
|
||||
$fileversion = $gittag + '.' + $commitversion + '-UNSTABLE'
|
||||
|
||||
Function WaitForKey {
|
||||
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
|
||||
return
|
||||
if ($args.length -eq 0) {
|
||||
Write-Host "please supply the version and the detail version as arguments"
|
||||
exit -1
|
||||
}
|
||||
$version = $args[0]
|
||||
$detailversion = $args[1]
|
||||
|
||||
# Create a MD5 string for the supplied filename
|
||||
Function MD5($filename) {
|
||||
|
@ -47,148 +37,27 @@ Function MD5($filename) {
|
|||
return [System.BitConverter]::ToString($hash) -replace "-", ""
|
||||
}
|
||||
|
||||
# Convert a JSON string to XML, this is a workaround for not having a JSON parser
|
||||
Function Convert-JsonToXml([string]$json) {
|
||||
$bytes = [byte[]][char[]]$json
|
||||
$quotas = [System.Xml.XmlDictionaryReaderQuotas]::Max
|
||||
$jsonReader = [System.Runtime.Serialization.Json.JsonReaderWriterFactory]::CreateJsonReader($bytes,$quotas)
|
||||
try {
|
||||
$xml = new-object System.Xml.XmlDocument
|
||||
$xml.Load($jsonReader)
|
||||
$xml
|
||||
} finally {
|
||||
$jsonReader.Close()
|
||||
}
|
||||
}
|
||||
|
||||
# Create a WebClient
|
||||
Function CreateWebClient {
|
||||
$proxy = [System.Net.WebRequest]::GetSystemWebProxy()
|
||||
$proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials
|
||||
|
||||
$wc = new-object system.net.WebClient
|
||||
$wc.proxy = $proxy
|
||||
return $wc
|
||||
}
|
||||
|
||||
# Create releasenotes for the commits
|
||||
Function ReleaseNotes {
|
||||
# Get the git-log from tag to now
|
||||
$gitlog = (git shortlog "$gittag..HEAD")
|
||||
|
||||
# The webclient can be used to get information from the internet, like a JIRA description.
|
||||
$wc = CreateWebClient
|
||||
|
||||
# Array to store the descriptions
|
||||
$releaseNotes = @()
|
||||
|
||||
# Find the jira's that are in the commits and place them in the release notes
|
||||
$jiras = $gitlog | foreach { [regex]::match($_,'[a-zA-Z0-9]+-[0-9]{1,5}').value -replace " ",""} | Where {$_ -match '\S'} | sort-object| select-object $_ -unique
|
||||
if ($null -ne $jiras) {
|
||||
$jiras | foreach {
|
||||
$jira = $_
|
||||
|
||||
Write-Host "Checking JIRA for [$jira]"
|
||||
try {
|
||||
$jiraJson = $wc.DownloadString("https://greenshot.atlassian.net/rest/api/2/issue/$jira")
|
||||
$xml = Convert-JsonToXml $jiraJson
|
||||
$summary = $xml.root.fields.summary."#text"
|
||||
$releaseNotes += "* Bug $jira : $summary"
|
||||
} catch {
|
||||
Write-Host "Error reading JIRA [$jira] : $_"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Find the sourceforge bugs's that are in the commits and place them in the release notes
|
||||
$bugs = $gitlog | foreach { [regex]::match($_,'\#[0-9]+').value -replace "\#","" -replace "\^","" -replace " ",""} | Where {$_ -match '\S'} | sort-object | select-object $_ -unique
|
||||
if ($null -ne $bugs) {
|
||||
$bugs | foreach {
|
||||
$bug = $_
|
||||
if ($bug -eq "") {
|
||||
continue
|
||||
}
|
||||
Write-Host "Checking Sourceforge for [#$bug]"
|
||||
try {
|
||||
$bugJson = $wc.DownloadString("https://sourceforge.net/rest/p/greenshot/bugs/$bug")
|
||||
$xml = Convert-JsonToXml $bugJson
|
||||
$summary = $xml.root.ticket.summary."#text"
|
||||
$releaseNotes +="* Bug #$bug : $summary"
|
||||
} catch {
|
||||
Write-Host "Error reading Bug [#$bug] : $_"
|
||||
}
|
||||
}
|
||||
}
|
||||
return $releaseNotes
|
||||
}
|
||||
|
||||
# Set the assembly versions
|
||||
Function ReplaceAssemblyVersion {
|
||||
echo "Setting the assembly verions to the Git version $readableversion`n`n"
|
||||
Get-ChildItem . -recurse AssemblyInfo.cs |
|
||||
foreach {
|
||||
$content = Get-Content $_.FullName
|
||||
$newcontent = @()
|
||||
foreach ($line in $content) {
|
||||
# Special case, if we find "@RELEASENOTES@" we replace that line with the release notes
|
||||
if ($line -match "\[assembly: AssemblyInformationalVersion.*") {
|
||||
# skip, it will be added automatically
|
||||
} elseif ($line -match "\[assembly: AssemblyVersion.*") {
|
||||
$newcontent += "[assembly: AssemblyVersion(""$version"")]"
|
||||
$newcontent += "[assembly: AssemblyInformationalVersion(""$detailversion"")]"
|
||||
} else {
|
||||
$newcontent += $line
|
||||
}
|
||||
}
|
||||
# Write the new information back the file
|
||||
$newcontent | Set-Content $_.FullName -encoding UTF8
|
||||
}
|
||||
}
|
||||
|
||||
# Fill the templates
|
||||
Function FillTemplates {
|
||||
echo "Filling templates for Git version $readableversion`n`n"
|
||||
Write-Host "Filling templates for Git version $detailversion`n`n"
|
||||
|
||||
$releaseNotes = ReleaseNotes
|
||||
Get-ChildItem . -recurse *.template |
|
||||
foreach {
|
||||
$oldfile = $_.FullName
|
||||
$newfile = $_.FullName -replace '\.template',''
|
||||
echo "Modifying file : $oldfile to $newfile"
|
||||
Write-Host "Modifying file : $oldfile to $newfile"
|
||||
# Read the file
|
||||
$template = Get-Content $oldfile
|
||||
# Create an empty array, this will contain the replaced lines
|
||||
$newtext = @()
|
||||
foreach ($line in $template) {
|
||||
# Special case, if we find "@RELEASENOTES@" we replace that line with the release notes
|
||||
if ($line -match "\@RELEASENOTES\@") {
|
||||
$newtext += $releaseNotes
|
||||
} else {
|
||||
$newtext += $line -replace "\@GITVERSION\@", $version -replace "\@GITDETAILVERSION\@", $detailversion -replace "\@READABLEVERSION\@", $readableversion
|
||||
}
|
||||
$newtext += $line -replace "\@VERSION\@", $version -replace "\@DETAILVERSION\@", $detailversion
|
||||
}
|
||||
# Write the new information to the file
|
||||
$newtext | Set-Content $newfile -encoding UTF8
|
||||
}
|
||||
}
|
||||
|
||||
# This function calls the Greenshot build
|
||||
Function Build {
|
||||
$msBuild = "C:\Windows\Microsoft.NET\Framework64\v3.5\MSBuild"
|
||||
if (-not (Test-Path("$msBuild"))) {
|
||||
$msBuild = "C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild"
|
||||
}
|
||||
$parameters = @('Greenshot\Greenshot.sln', '/t:Clean;Build', '/p:Configuration="Release"', '/p:Platform="Any CPU"')
|
||||
$buildOutput = "$(get-location)\build.log"
|
||||
echo "Calling: $msBuild $parameters"
|
||||
$buildResult = Start-Process -wait -PassThru "$msBuild" -ArgumentList $parameters -NoNewWindow -RedirectStandardOutput $buildOutput
|
||||
if ($buildResult.ExitCode -ne 0) {
|
||||
echo "An error occured, please check $BuildOutput for errors!"
|
||||
exit -1
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
# Create the MD5 checksum file
|
||||
Function MD5Checksums {
|
||||
echo "MD5 Checksums:"
|
||||
|
@ -244,10 +113,13 @@ Function PackagePortable {
|
|||
$portableOutput = "$(get-location)\portable"
|
||||
$portableInstaller = "$(get-location)\greenshot\tools\PortableApps.comInstaller\PortableApps.comInstaller.exe"
|
||||
$arguments = @("$destbase\portabletmp")
|
||||
echo "Starting $portableInstaller $arguments"
|
||||
Write-Hos "Starting $portableInstaller $arguments"
|
||||
$portableResult = Start-Process -wait -PassThru "$portableInstaller" -ArgumentList $arguments -NoNewWindow -RedirectStandardOutput "$portableOutput.log" -RedirectStandardError "$portableOutput.error"
|
||||
Write-Host "Log output:"
|
||||
Get-Content "$portableOutput.log"| Write-Host
|
||||
if ($portableResult.ExitCode -ne 0) {
|
||||
echo "An error occured, please check $portableOutput.log and $portableOutput.error for errors!"
|
||||
Write-Host "Error output:"
|
||||
Get-Content "$portableOutput.error"| Write-Host
|
||||
exit -1
|
||||
}
|
||||
Start-Sleep -m 1500
|
||||
|
@ -262,8 +134,8 @@ Function PackageZip {
|
|||
$destinstaller = "$destbase\NO-INSTALLER"
|
||||
|
||||
# Only remove the zip we are going to create, to prevent adding but keeping the history
|
||||
if (Test-Path ("$destbase\Greenshot-NO-INSTALLER-$fileversion.zip")) {
|
||||
Remove-Item "$destbase\Greenshot-NO-INSTALLER-$fileversion.zip" -Confirm:$false
|
||||
if (Test-Path ("$destbase\Greenshot-NO-INSTALLER-$version.zip")) {
|
||||
Remove-Item "$destbase\Greenshot-NO-INSTALLER-$version.zip" -Confirm:$false
|
||||
}
|
||||
# Remove the directory to create the files in
|
||||
if (Test-Path ("$destinstaller")) {
|
||||
|
@ -300,11 +172,14 @@ Function PackageZip {
|
|||
|
||||
$zipOutput = "$(get-location)\zip"
|
||||
$zip7 = "$(get-location)\greenshot\tools\7zip\7za.exe"
|
||||
$arguments = @('a', '-mx9', '-tzip', '-r', "$destbase\Greenshot-NO-INSTALLER-$fileversion.zip", "$destinstaller\*")
|
||||
echo "Starting $zip7 $arguments"
|
||||
$arguments = @('a', '-mx9', '-tzip', '-r', "$destbase\Greenshot-NO-INSTALLER-$version.zip", "$destinstaller\*")
|
||||
Write-Host "Starting $zip7 $arguments"
|
||||
$zipResult = Start-Process -wait -PassThru "$zip7" -ArgumentList $arguments -NoNewWindow -RedirectStandardOutput "$zipOutput.log" -RedirectStandardError "$zipOutput.error"
|
||||
Write-Host "Log output:"
|
||||
Get-Content "$zipOutput.log"| Write-Host
|
||||
if ($zipResult.ExitCode -ne 0) {
|
||||
echo "An error occured, please check $zipOutput.log and $zipOutput.error for errors!"
|
||||
Write-Host "Error output:"
|
||||
Get-Content "$zipOutput.error"| Write-Host
|
||||
exit -1
|
||||
}
|
||||
Start-Sleep -m 1500
|
||||
|
@ -317,27 +192,20 @@ Function PackageInstaller {
|
|||
$setupOutput = "$(get-location)\setup"
|
||||
$innoSetup = "$(get-location)\greenshot\tools\innosetup\ISCC.exe"
|
||||
$innoSetupFile = "$(get-location)\greenshot\releases\innosetup\setup.iss"
|
||||
echo "Starting $innoSetup $innoSetupFile"
|
||||
Write-Host "Starting $innoSetup $innoSetupFile"
|
||||
$setupResult = Start-Process -wait -PassThru "$innoSetup" -ArgumentList "$innoSetupFile" -NoNewWindow -RedirectStandardOutput "$setupOutput.log" -RedirectStandardError "$setupOutput.error"
|
||||
Write-Host "Log output:"
|
||||
Get-Content "$setupOutput.log"| Write-Host
|
||||
if ($setupResult.ExitCode -ne 0) {
|
||||
echo "An error occured, please check $setupOutput.log and $setupOutput.error for errors!"
|
||||
Write-Host "Error output:"
|
||||
Get-Content "$setupOutput.error"| Write-Host
|
||||
exit -1
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
ReplaceAssemblyVersion
|
||||
|
||||
FillTemplates
|
||||
|
||||
$continue = Read-Host "`n`nPreperations are ready.`nIf you are generating a release you can now change the readme.txt to your desire and use 'y' afterwards to continue building.`nContinue with the build? (y/n)"
|
||||
|
||||
if ($continue -ne "y") {
|
||||
echo "skipped build."
|
||||
exit 0
|
||||
}
|
||||
Build
|
||||
|
||||
echo "Generating MD5"
|
||||
|
||||
MD5Checksums | Set-Content "$(get-location)\Greenshot\bin\Release\checksum.MD5" -encoding UTF8
|
||||
|
@ -354,31 +222,3 @@ PackagePortable
|
|||
echo "Ready, press any key to continue!"
|
||||
|
||||
WaitForKey
|
||||
# SIG # Begin signature block
|
||||
# MIIEtAYJKoZIhvcNAQcCoIIEpTCCBKECAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB
|
||||
# gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR
|
||||
# AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQU5pAQ9lTsZuk+TP6fsiKo8Bmi
|
||||
# UkagggK+MIICujCCAaagAwIBAgIQyoRJHMJDVbNFmmfObt+Y4DAJBgUrDgMCHQUA
|
||||
# MCwxKjAoBgNVBAMTIVBvd2VyU2hlbGwgTG9jYWwgQ2VydGlmaWNhdGUgUm9vdDAe
|
||||
# Fw0xMzExMjYxOTMxMTVaFw0zOTEyMzEyMzU5NTlaMBoxGDAWBgNVBAMTD1Bvd2Vy
|
||||
# U2hlbGwgVXNlcjCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA0SEsL7kNLoYA
|
||||
# rMLe99Tf1SF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b3DQEBAQUABIGAExnJmCpla7w3rW1NNN9WxlCkVe+Ih0cb
|
||||
# 5tdaGVD7bXasTOYLbRjkoUgwpBa5DCB28XOdC+UF28uWEeH84rwrxP6IuSYCTdf/
|
||||
# A7eH21lsXw2gQ4Cf8MVY7rxFylb2sL6RmhcWBtVKhIT6a3ZDsOGhsq+bQaHlwr8f
|
||||
# cRQdg84VVCo=
|
||||
# SIG # End signature block
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue