Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
149 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,36 @@ | ||
# AppVeyor CI pipeline, executed on Windows Server 2016/2012 R2 | ||
image: | ||
# => Windows Server 2012 R2 | ||
- Visual Studio 2015 | ||
# => Windows Server 2016 | ||
- Visual Studio 2017 | ||
|
||
branches: | ||
only: | ||
- master | ||
- /^\d+\.\d+\.x$/ # version branches like X.X.X | ||
- /^\d+\.\d+\.x$/ # Version branches like 0.28.x | ||
- /^v\d+\.\d+\.\d+$/ # Version tags like v0.28.1 | ||
- /^test-.*$/ | ||
|
||
build: off | ||
|
||
test_script: | ||
- ps: Write-Host "Hello, world!" | ||
|
||
|
||
# If deploy is needed, installer executable is constructed and published as artifact | ||
before_deploy: | ||
- ps: .\windows-installer\construct.ps1 | ||
- ps: Get-ChildItem .\windows-installer\build\nsis\*.exe | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name } | ||
|
||
# Deploy the installer to the relevant GitHub release | ||
deploy: | ||
provider: GitHub | ||
tag: $(APPVEYOR_REPO_TAG_NAME) | ||
release: Certbot $(APPVEYOR_REPO_TAG_NAME) | ||
description: Release of Certbot $(APPVEYOR_REPO_TAG_NAME) | ||
auth_token: | ||
secure: wFtJuuyI4gizhyEAWbAFqkj2yivgcSKiMWIdfoPpHWhPktiU5C2I/bH8ZurcsDbn | ||
artifact: /.*\.exe/ | ||
on: | ||
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 | ||
APPVEYOR_REPO_TAG: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
#Requires -RunAsAdministrator | ||
|
||
"### Gather runtime data ###" | ||
|
||
Try { | ||
$chocoExe = Get-Command choco -errorAction Stop | ||
} Catch { | ||
"Error: Chocolatey (https://chocolatey.org/) needs to be installed to run this script." | ||
Exit | ||
} | ||
|
||
Try { | ||
$pythonExe = Get-Command py -errorAction Stop | ||
} Catch { | ||
Try { | ||
$pythonExe = Get-Command python -errorAction Stop | ||
} Catch { | ||
"Error: Could not find the Python executable. Python for Windows is installed ?" | ||
} | ||
} | ||
|
||
$script_path = $PSCommandPath | ||
$repo_path = $script_path -replace "\\windows-installer\\construct\.ps1$" | ||
$build_path = "$repo_path\windows-installer\build" | ||
|
||
$venv_path = "$build_path\venv-config" | ||
$installer_cfg_path = "$build_path\installer.cfg" | ||
$wheels_path = "$build_path\wheels" | ||
|
||
Push-Location $repo_path; $certbot_version = py -c "import certbot; print(certbot.__version__)"; Pop-Location | ||
|
||
$certbot_packages = @("acme", "certbot") | ||
$certbot_packages += Get-ChildItem "$repo_path\certbot-dns-*" | Where-Object { $_.PSIsContainer } | Foreach-Object { $_.Name } | ||
|
||
"### Copy assets ###" | ||
|
||
New-Item $build_path -ItemType directory -ErrorAction Ignore | Out-Null | ||
Copy-Item -Path "$repo_path\windows-installer\certbot.ico" -Destination $build_path -Force | ||
Copy-Item -Path "$repo_path\windows-installer\run_cmd.py" -Destination $build_path -Force | ||
|
||
"### Prepare pynsist config ###" | ||
|
||
" | ||
[Application] | ||
name=Certbot | ||
version=$certbot_version | ||
icon=certbot.ico | ||
script=run_cmd.py | ||
[Build] | ||
directory=nsis | ||
installer_name=certbot-$certbot_version-win32_install.exe | ||
[Python] | ||
version=3.7.0 | ||
[Include] | ||
local_wheels=wheels\*.whl | ||
[Command certbot] | ||
entry_point=certbot.main:main | ||
" | Set-Content -Path $installer_cfg_path | ||
|
||
"### Prepare build environment ###" | ||
|
||
Invoke-Expression "& '$pythonExe' -m venv --clear $venv_path" | ||
Invoke-Expression "& '$chocoExe' upgrade -y nsis" | ||
|
||
Push-Location $venv_path | ||
.\Scripts\Activate.ps1 | ||
python -m pip install --upgrade pip | ||
Pop-Location | ||
|
||
Remove-Item -Recurse -Force -ErrorAction Ignore -Path $wheels_path | ||
New-Item $wheels_path -ItemType directory | Out-Null | ||
pip install wheel | ||
|
||
# This code block can be replaced with 'pip install pynsist' when a new pynsist version | ||
# will be pushed to pypi that integrates the work refered in takluyver/pynsist#166. | ||
pip install flit | ||
git clone https://github.com/takluyver/pynsist.git --branch distlib-launchers "$venv_path\pynsist" | ||
Push-Location "$venv_path\pynsist"; flit install; Pop-Location | ||
|
||
"### Compile wheels ###" | ||
|
||
$wheels_projects = $certbot_packages -replace "^certbot$" | ForEach-Object {"$repo_path\$_"} | ||
pip wheel $wheels_projects -w $wheels_path | ||
|
||
"### Build the installer ###" | ||
|
||
Push-Location $build_path | ||
pynsist $installer_cfg_path | ||
Pop-Location | ||
|
||
"### Clean environment ###" | ||
|
||
deactivate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
"""Start a cmd in a new window, with admin rights (required by Certbot to create symlinks)""" | ||
import subprocess | ||
import ctypes | ||
import sys | ||
|
||
def main(): | ||
if ctypes.windll.shell32.IsUserAnAdmin(): | ||
# Already with admin rights, run directly cmd | ||
subprocess.Popen('start /wait cmd /k "' | ||
' echo +---------------------------------------------------------------+' | ||
'& echo ^# Welcome to Certbot. ^#' | ||
'& echo ^# Please type \'certbot --help\' to find every available actions. ^#' | ||
'& echo +---------------------------------------------------------------+"', | ||
shell=True) | ||
else: | ||
# No admin rights, invoke again this script with an admin rights request | ||
ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, __file__, None, 1) | ||
|
||
if __name__ == '__main__': | ||
main() |