From 2dbe47f3a726f4c43b0d747193ed207999dc8ea8 Mon Sep 17 00:00:00 2001 From: Adrien Ferrand Date: Wed, 30 Oct 2019 18:19:10 +0100 Subject: [PATCH] Create a release pipeline on Azure for Windows installer (#7441) This PR creates a pipeline triggered on tag push matching v0.* (eg. v0.40.0). Once triggered, this pipeline will build the windows installer, and run integration tests on it, like for the pipeline run nightly. I also add a simple script to extract from CHANGELOG.md file to extract the relevant part to put it in the body of the GitHub release. I believe it makes things nicer. * Create release pipeline * Relax condition on tags * Put beta keyword * Update job name * Fix release pipeline --- .azure-pipelines/advanced.yml | 2 + .azure-pipelines/release.yml | 13 ++++++ .azure-pipelines/templates/changelog.yml | 14 +++++++ .../templates/installer-tests.yml | 5 ++- tools/extract_changelog.py | 41 +++++++++++++++++++ windows-installer/construct.py | 2 +- windows-installer/template.nsi | 5 ++- 7 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 .azure-pipelines/release.yml create mode 100644 .azure-pipelines/templates/changelog.yml create mode 100755 tools/extract_changelog.py diff --git a/.azure-pipelines/advanced.yml b/.azure-pipelines/advanced.yml index 9832c0684..fe24a9ecb 100644 --- a/.azure-pipelines/advanced.yml +++ b/.azure-pipelines/advanced.yml @@ -15,5 +15,7 @@ schedules: always: true jobs: + # Any addition here should be reflected in the release pipeline. + # It is advised to declare all jobs here as templates to improve maintainability. - template: templates/tests-suite.yml - template: templates/installer-tests.yml diff --git a/.azure-pipelines/release.yml b/.azure-pipelines/release.yml new file mode 100644 index 000000000..aeb5ee327 --- /dev/null +++ b/.azure-pipelines/release.yml @@ -0,0 +1,13 @@ +# Release pipeline to build and deploy Certbot for Windows for GitHub release tags +trigger: + tags: + include: + - v* +pr: none + +jobs: + # Any addition here should be reflected in the advanced pipeline. + # It is advised to declare all jobs here as templates to improve maintainability. + - template: templates/tests-suite.yml + - template: templates/installer-tests.yml + - template: templates/changelog.yml diff --git a/.azure-pipelines/templates/changelog.yml b/.azure-pipelines/templates/changelog.yml new file mode 100644 index 000000000..7619858a9 --- /dev/null +++ b/.azure-pipelines/templates/changelog.yml @@ -0,0 +1,14 @@ +jobs: + - job: changelog + pool: + vmImage: vs2017-win2016 + steps: + - bash: | + CERTBOT_VERSION="$(python -c "import certbot; print(certbot.__version__)")" + "${BUILD_REPOSITORY_LOCALPATH}\tools\extract_changelog.py" "${CERTBOT_VERSION}" >> "${BUILD_ARTIFACTSTAGINGDIRECTORY}/release_notes.md" + displayName: Prepare changelog + - task: PublishPipelineArtifact@1 + inputs: + path: $(Build.ArtifactStagingDirectory) + artifact: changelog + displayName: Publish changelog diff --git a/.azure-pipelines/templates/installer-tests.yml b/.azure-pipelines/templates/installer-tests.yml index f0e151439..b1c5ea6b1 100644 --- a/.azure-pipelines/templates/installer-tests.yml +++ b/.azure-pipelines/templates/installer-tests.yml @@ -18,8 +18,9 @@ jobs: - task: PublishPipelineArtifact@1 inputs: path: $(Build.ArtifactStagingDirectory) - artifact: WindowsInstaller - - script: $(Build.ArtifactStagingDirectory)\certbot-installer-win32.exe /S + artifact: windows-installer + displayName: Publish Windows installer + - script: $(Build.ArtifactStagingDirectory)\certbot-beta-installer-win32.exe /S displayName: Install Certbot - script: | python -m venv venv diff --git a/tools/extract_changelog.py b/tools/extract_changelog.py new file mode 100755 index 000000000..d3bd2aa44 --- /dev/null +++ b/tools/extract_changelog.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python +from __future__ import print_function +import sys +import os +import re + + +CERTBOT_ROOT = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) + +NEW_SECTION_PATTERN = re.compile(r'^##\s*[\d.]+\s*-\s*[\d-]+$') + + +def main(): + version = sys.argv[1] + + section_pattern = re.compile(r'^##\s*{0}\s*-\s*[\d-]+$' + .format(version.replace('.', '\\.'))) + + with open(os.path.join(CERTBOT_ROOT, 'CHANGELOG.md')) as file_h: + lines = file_h.read().splitlines() + + changelog = [] + + i = 0 + while i < len(lines): + if section_pattern.match(lines[i]): + i = i + 1 + while i < len(lines): + if NEW_SECTION_PATTERN.match(lines[i]): + break + changelog.append(lines[i]) + i = i + 1 + i = i + 1 + + changelog = [entry for entry in changelog if entry] + + print('\n'.join(changelog)) + + +if __name__ == '__main__': + main() diff --git a/windows-installer/construct.py b/windows-installer/construct.py index 8de9da87c..7fd3039f9 100644 --- a/windows-installer/construct.py +++ b/windows-installer/construct.py @@ -113,7 +113,7 @@ target=$INSTDIR\\run.bat [Build] directory=nsis nsi_template=template.nsi -installer_name=certbot-installer-{installer_suffix}.exe +installer_name=certbot-beta-installer-{installer_suffix}.exe [Python] version={python_version} diff --git a/windows-installer/template.nsi b/windows-installer/template.nsi index 0f366c22a..50a03865f 100644 --- a/windows-installer/template.nsi +++ b/windows-installer/template.nsi @@ -60,7 +60,10 @@ SetCompressor lzma !insertmacro MUI_LANGUAGE "English" [% endblock modernui %] -Name "${PRODUCT_NAME} ${PRODUCT_VERSION}" +; CERTBOT CUSTOM BEGIN +Name "${PRODUCT_NAME} (beta) ${PRODUCT_VERSION}" +;Name "${PRODUCT_NAME} ${PRODUCT_VERSION}" +; CERTBOT CUSTOM END OutFile "${INSTALLER_NAME}" ShowInstDetails show