Skip to content

Commit

Permalink
Update build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
xatupal committed Apr 6, 2021
1 parent e08664b commit ec6d2c0
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -328,3 +328,11 @@ ASALocalRun/

# MFractors (Xamarin productivity tool) working folder
.mfractor/

# Build artifacts
/build/KeeTheme.dll
/build/KeeTheme.plgx

# Chocolatey artifacts
/choco/choco.key
/choco/KeeTheme.plgx
30 changes: 30 additions & 0 deletions build/build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
rem Build dll
echo Loading Visual Studio Tools
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools\VsDevCmd.bat"

echo Compiling Dll
msbuild ..\KeeTheme.sln /p:Configuration=Release /p:LangVersion=3

echo Releasing Dll
copy ..\KeeTheme\bin\Release\KeeTheme.dll .\KeeTheme.dll

rem Build plgx
echo Deleting existing PlgX folder
rmdir /s /q "PlgX"

echo Creating PlgX folder
mkdir "PlgX"

echo Copying files
xcopy "..\KeeTheme\*" "PlgX" /s /e /exclude:PlgXExclude.txt

echo Compiling PlgX
"C:\Program Files (x86)\KeePass Password Safe 2\KeePass.exe" /plgx-create "%cd%\PlgX" --debug --plgx-prereq-net:3.5

echo Releasing PlgX
move /y "PlgX.plgx" "KeeTheme.plgx"

echo Cleaning up
rmdir /s /q "PlgX"

pause
13 changes: 13 additions & 0 deletions build/plgxexclude.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
bin\
obj\
.idea\
.vs
.git
.user
.sln
.suo
.pdb
build.cmd
plgxexclude.txt
KeeTheme.dll
KeeTheme.plgx
65 changes: 65 additions & 0 deletions choco/publish.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
param (
[string]$apiKey = ""
)

If ($apiKey -eq "")
{
Write-Host "Choco API key was not provided. Trying to read from choco.key file."
$apiKey = Get-Content choco.key
}

If ($apiKey -eq "")
{
Write-Host "Choco API key not found!"
Break
}

Write-Host "Getting latest KeeTheme version..."
$AllProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12'
[System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols

$latestUrl = "https://github.com/xatupal/KeeTheme/releases/latest"
$request = [System.Net.WebRequest]::Create($latestUrl)
$request.AllowAutoRedirect=$false
$response=$request.GetResponse()

If ($response.StatusCode -ne "Found")
{
Write-Host "Unable to find latest version!"
Break
}

$latestTagUrl = $response.GetResponseHeader("Location")
$latestTag = $latestTagUrl -Split "/" | Select-Object -Last 1
$version = $latestTag.TrimStart("v")
Write-Host "Latest version: " $version

Write-Host "Downloading KeeTheme.plgx..."
$downloadUrl = "https://github.com/xatupal/KeeTheme/releases/download/$latestTag/KeeTheme.plgx"
Invoke-WebRequest -Uri $downloadUrl -OutFile "KeeTheme.plgx"
Write-Host "KeeTheme plugin downloaded"

Write-Host "Updating Choco files..."
$content = Get-Content -path "keetheme.nuspec"
$content -Replace '\<version\>(.+)\</version\>', "<version>$version</version>" | Out-File -Encoding "UTF8" "keetheme.nuspec"

$content = Get-Content -path "tools\common.ps1"
$content -Replace '\$url = ''(.+)''', "`$url = '$downloadUrl'" | Out-File -Encoding "UTF8" "tools\common.ps1"

$checksum = (Get-FileHash -algorithm sha256 "KeeTheme.plgx").Hash
$content = Get-Content -path "tools\common.ps1"
$content -Replace '\$checksum = ''(.+)''', "`$checksum = '$checksum'" | Out-File -Encoding "UTF8" "tools\common.ps1"
Write-Host "Choco files updated"

Write-Host "Creating Choco package..."
choco pack
Write-Host "Choco package keepass-plugin-keetheme.$version.nupkg created!"

$reply = Read-Host -Prompt "Ready to push?[y/n]"
If ($reply -match "[yY]")
{
Write-Host "Pushing Choco package..."
choco push keepass-plugin-keetheme.$version.nupkg -s https://chocolatey.org --api-key=$apiKey
Write-Host "Choco package pushed!"
}
pause

0 comments on commit ec6d2c0

Please sign in to comment.