From f34367be676c6107e511b4a39d9d48f7325a9b73 Mon Sep 17 00:00:00 2001 From: Adrien Ferrand Date: Thu, 13 Aug 2020 18:13:22 +0200 Subject: [PATCH 1/3] Start work --- .azure-pipelines/main.yml | 5 ++ .azure-pipelines/release.yml | 18 +++++++ .../templates/integration-jobs.yml | 48 +++++++++++++++++++ .azure-pipelines/templates/release-jobs.yml | 0 4 files changed, 71 insertions(+) create mode 100644 .azure-pipelines/main.yml create mode 100644 .azure-pipelines/release.yml create mode 100644 .azure-pipelines/templates/integration-jobs.yml create mode 100644 .azure-pipelines/templates/release-jobs.yml diff --git a/.azure-pipelines/main.yml b/.azure-pipelines/main.yml new file mode 100644 index 0000000..d3427ed --- /dev/null +++ b/.azure-pipelines/main.yml @@ -0,0 +1,5 @@ +trigger: + - master + +jobs: + - template: templates/integration-jobs.yml diff --git a/.azure-pipelines/release.yml b/.azure-pipelines/release.yml new file mode 100644 index 0000000..68445da --- /dev/null +++ b/.azure-pipelines/release.yml @@ -0,0 +1,18 @@ +trigger: + branches: + exclude: + - "*" + tags: + include: + - "3.*" + - "4.*" + +pr: none + +stages: + - stage: Test + jobs: + - template: templates/integration-jobs.yml + - stage: Release + jobs: + - template: templates/release-jobs.yml diff --git a/.azure-pipelines/templates/integration-jobs.yml b/.azure-pipelines/templates/integration-jobs.yml new file mode 100644 index 0000000..c0f46e4 --- /dev/null +++ b/.azure-pipelines/templates/integration-jobs.yml @@ -0,0 +1,48 @@ +jobs: + - job: build + pool: + vmImage: ubuntu-18.04 + steps: + - script: | + docker pull adferrand/backuppc || true + docker build --pull --cache-from adferrand/backuppc -t adferrand/backuppc . + docker save adferrand/backuppc | gzip -c -1 > $(Build.ArtifactStagingDirectory)/docker-backuppc.tar.gz + displayName: Build container + - task: PublishPipelineArtifact@1 + inputs: + path: $(Build.ArtifactStagingDirectory) + artifact: docker + displayName: Store Docker artifact + - job: unit-tests + dependsOn: build + pool: + vmImage: ubuntu-18.04 + steps: + - task: DownloadPipelineArtifact@2 + inputs: + artifact: docker + path: $(Build.SourcesDirectory) + displayName: Retrieve Docker artifact + - script: | + docker load < docker-backuppc.tar.gz + mkdir -p ./bin + curl -fsSL https://goss.rocks/install | GOSS_DST=./bin sh + GOSS_PATH=./bin/goss GOSS_SLEEP=2 GOSS_FILES_PATH=./tests ./bin/dgoss run adferrand/backuppc + - job: integration-tests + dependsOn: build + pool: + vmImage: ubuntu-18.04 + steps: + - task: DownloadPipelineArtifact@2 + inputs: + artifact: docker + path: $(Build.SourcesDirectory) + displayName: Retrieve Docker artifact + - script: | + docker load < docker-backuppc.tar.gz + docker run --name backuppc-integration --detach -p 8080:8080 adferrand/backuppc + sleep 5 + output=`curl http://backuppc:password@localhost:8080/BackupPC_Admin` + echo "Expect the backupp configuration page without errors" + grep "The servers PID is" <(echo $output) + docker rm -f backuppc-integration diff --git a/.azure-pipelines/templates/release-jobs.yml b/.azure-pipelines/templates/release-jobs.yml new file mode 100644 index 0000000..e69de29 From 448b0eecfbd613b1f92efca3c2448a9c9f9dafe5 Mon Sep 17 00:00:00 2001 From: Adrien Ferrand Date: Thu, 13 Aug 2020 18:37:02 +0200 Subject: [PATCH 2/3] Finish logic --- .azure-pipelines/release.yml | 3 +- .azure-pipelines/templates/release-jobs.yml | 45 +++++++++++ CHANGELOG.md | 90 ++++++++++----------- utils/create_release.py | 68 ++++++++++++++++ utils/extract_changelog.py | 46 +++++++++++ 5 files changed, 205 insertions(+), 47 deletions(-) create mode 100644 utils/create_release.py create mode 100644 utils/extract_changelog.py diff --git a/.azure-pipelines/release.yml b/.azure-pipelines/release.yml index 68445da..9345f23 100644 --- a/.azure-pipelines/release.yml +++ b/.azure-pipelines/release.yml @@ -4,13 +4,12 @@ trigger: - "*" tags: include: - - "3.*" - "4.*" pr: none stages: - - stage: Test + - stage: Build-And-Test jobs: - template: templates/integration-jobs.yml - stage: Release diff --git a/.azure-pipelines/templates/release-jobs.yml b/.azure-pipelines/templates/release-jobs.yml index e69de29..0bb4602 100644 --- a/.azure-pipelines/templates/release-jobs.yml +++ b/.azure-pipelines/templates/release-jobs.yml @@ -0,0 +1,45 @@ +jobs: + - job: docker + pool: + vmImage: ubuntu-18.04 + steps: + - task: DownloadPipelineArtifact@2 + inputs: + artifact: docker + path: $(Build.SourcesDirectory) + displayName: Retrieve Docker artifact + - task: Docker@2 + inputs: + command: login + containerRegistry: docker-hub + displayName: Login to DockerHub + - script: | + docker load < docker-backuppc.tar.gz + VERSION=`cat VERSION` + echo "Docker tag is: ${VERSION}" + docker tag adferrand/backuppc adferrand/backuppc:4 + docker tag adferrand/backuppc "adferrand/backuppc:${VERSION}" + displayName: Tag and push Docker images to DockerHub + - job: github + pool: + vmImage: ubuntu-18.04 + steps: + - task: UsePythonVersion@0 + inputs: + versionSpec: 3.8 + addToPath: true + displayName: Install Python + - script: | + VERSION=`cat VERSION` + echo "Version is: $version" + echo "##vso[task.setvariable variable=ReleaseVersion;]${VERSION}" + displayVersion: Get version + - script: | + python utils/extract_changelog.py $(ReleaseVersion) > release_$(ReleaseVersion).md + - task: GithubRelease@0 + inputs: + gitHubConnection: github.com_adferrand + title: Docker BackupPC $(ReleaseVersion) + releaseNotesFile: $(Build.SourcesDirectory)/release_$(ReleaseVersion).md + addChangeLog: false + displayName: Create GitHub Release diff --git a/CHANGELOG.md b/CHANGELOG.md index 45e5b4f..f204681 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,16 +1,16 @@ # Changelog -## Unreleased +## master - CURRENT -## [4.4.2 - 13/08/2020] +## 4.4.0-2 - 13/08/2020 # Modified * Fixed an error about docker instance failing to restart after first run (thanks @tadr0 and @csibbitt with #40) -## [4.4.1 - 24/07/2020] +## 4.4.0-1 - 24/07/2020 # Modified * Conditionnally create the symlink /bin/bzip2 to prevent regressions -## [4.4.0 - 21/06/2020] +## 4.4.0 - 21/06/2020 # Added * Add JSON::RS perl dependency to allow BackupPC metrics in JSON format * Update documentation about metrics @@ -20,53 +20,53 @@ * Update perl lib BackupPC::XS to 0.62 * Update rsync-bpc to 3.1.2.2 -## [4.3.2-6 - 01/06/2020] +## 4.3.2-6 - 01/06/2020 ### Changed * Update base docker to Alpine 3.12 * Update perl lib BackupPC::XS to 0.60 -## [4.3.2-5 - 12/04/2020] +## 4.3.2-5 - 12/04/2020 ### Added * Introduce the Active Directory / LDAP authentication for the BackupPC Web UI. Authentication method is controlled with the `AUTHENTICATION_METHOD` environment variable, that can be `file` or `ldap` (@christianuhlmann #23). -## [4.3.2-4 - 01/03/2020] +## 4.3.2-4 - 01/03/2020 ### Added * Store mails generated by backuppc in /var/log/msmtp.log, and to supervisor stdout ### Changed * Do not override `EMailFromUserName` parameter in BackupPC when `SMTP_MAIL_DOMAIN` is not set -## [4.3.2-3 - 01/03/2020] +## 4.3.2-3 - 01/03/2020 ### Added * Provide GNU tar ### Removed * Remove BusyBox tar -## [4.3.2-2 - 01/03/2020] +## 4.3.2-2 - 01/03/2020 ### Changed * Switch from circus to supervisor to handle the container processes * Install par2cmdline from Alpine packages * Clean build dependencies * Align tests -## [4.3.2-1 - 24/02/2020] +## 4.3.2-1 - 24/02/2020 ### Changed * Fallback to circus 0.15.0 since 0.16.x is consuming 100% of a CPU in current environment -## [4.3.2] - 18/02/2020 +## 4.3.2 - 18/02/2020 ### Changed * Update to BackupPC 4.3.2 * Update base image to Alpine 3.11.3 * Update Par2Cmdline to 0.8.1 -## [4.3.1-1] - 07/12/2019 +## 4.3.1-1 - 07/12/2019 ### Changed * Update base image to Alpine 3.10.3 -## [4.3.1] - 17/07/2019 +## 4.3.1 - 17/07/2019 ### Added * Proper Docker signal handling (eg. SIGINT) by making Circus be the PID 1 * Support TLS in msmtp (thanks to @belaytzev in adferrand/docker-backuppc#22) @@ -76,19 +76,19 @@ * Update to rsync-bpc 3.1.2.1 * Update perl lib BackupPC::XS to 0.59 -## [4.3.0-6] - 18/03/2019 +## 4.3.0-6 - 18/03/2019 ### Added * Install DejaVu font for a better look and readability of generated RRD graphs in BackupPC UI (#21 from @jkroepke) -## [4.3.0-5] - 10/03/2019 +## 4.3.0-5 - 10/03/2019 ### Changed * Use a passphrase of 4 characters (instead of 1) when generating self-signed certificates (`USE_SSL=true`) to be accepted by newest versions of OpenSSL. -## [4.3.0-4] - 09/03/2019 +## 4.3.0-4 - 09/03/2019 ### Changed * Update Alpine base image to 3.9 -## [4.3.0-3] - 06/12/2018 +## 4.3.0-3 - 06/12/2018 ### Added * Hostname in BackupPC instance is now in sync with the container hostname, and can be set using `--hostname` at container start (#12 @Alveel) * Add basic integration tests during the CI @@ -97,33 +97,33 @@ * Update perl lib BackupPC::XS to 0.58 * Update rsync-bpc to 3.1.2.0 -## [4.3.0-2] - 27/11/2018 +## 4.3.0-2 - 27/11/2018 ### Changed * Bugfix: fallback to rsync-bpc to 3.0.9.12 and BackupPC::XS 0.57 because upstream is broken * Versions 4.3.0-1 and 4.3.0 are also patched with this bugfix -## [4.3.0-1] - 26/11/2018 +## 4.3.0-1 - 26/11/2018 ### Added * Allow to use a pre-existing `server.pem` file mounted into the container to serve the BackupPC UI over https -## [4.3.0] - 26/11/2018 +## 4.3.0 - 26/11/2018 ### Changed * Update BackupPC to 4.2.0 * Update perl lib BackupPC::XS to 0.58 * Update rsync-bpc to 3.0.9.13 -## [4.2.1-3] - 26/11/2018 +## 4.2.1-3 - 26/11/2018 ### Added * Add support for ACL to rsync-bpc (from @JoelLinn in #9) -## [4.2.1-2] - 09/10/2018 +## 4.2.1-2 - 09/10/2018 ### Added * Set up a complete CI/CD system for this Docker, using CircleCI: docker is now automatically packaged, tested and deployed to Docker Hub ### Changed * Hotfix for BZIP2 binary, due to latest Alpine layout modifications, is now applied when the container is created, removing the error `n: /bin/bzip2: File exists` when container is restarted. -## [4.2.1-1] - 12/09/2018 +## 4.2.1-1 - 12/09/2018 ### Added * Add and configure circus, an alternative to supervisor, compatible with Python 3, with better control over environment variables propagation, and network sockets supervision (not used yet here) * Mandatory perl modules for Backuppc are now installed as pre-compiled binaries from Alpine repos @@ -138,104 +138,104 @@ * Remove supervisor and its configuration * Remove build logic used to compile the mandatory perl modules -## [4.2.1] - 14/05/2018 +## 4.2.1 - 14/05/2018 ### Changed * Update BackupPC to 4.2.1 -## [4.2.0] - 22/04/2018 +## 4.2.0 - 22/04/2018 ### Changed * Update BackupPC to 4.2.0 -## [4.1.5-2] - 02/02/2018 +## 4.1.5-2 - 02/02/2018 ### Changed * Update Alpine base image to 3.7 * Update rsync-bpc to 3.0.9.12 -## [4.1.5-1] - 28/12/2017 +## 4.1.5-1 - 28/12/2017 ### Changed * Update rsync-bpc to 3.0.9.11 * Update par2cmdline to 0.8.0 -## [4.1.5] - 04/12/2017 +## 4.1.5 - 04/12/2017 ### Changed * Update BackupPC to 4.1.5 * Update perl lib BackupPC::XS to 0.57 * Update rsync-bpc to 3.0.9.9 -## [4.1.4] - 29/11/2017 +## 4.1.4 - 29/11/2017 ### Changed * Update BackupPC to 4.1.4 -## [4.1.3-10] - 15/11/2017 +## 4.1.3-10 - 15/11/2017 ### Added * Extends possibilities of `BACKUPPC_UUID`/`BACKUPPC_GUID`: previously existing `UUID`/`GUID` (like 100) in container could not be reused without error. This version now handles it: any `UUID`/`GUID` can be used. * Extended supervisord logging capabilities over backuppc and lighttpd instances. -## [4.1.3-9] - 01/10/2017 +## 4.1.3-9 - 01/10/2017 ### Added * Add missing runtime libraries mandatory for par2 ### Changed * Update par2cmdline to 0.7.4 -## [4.1.3-8] - 02/09/2017 +## 4.1.3-8 - 02/09/2017 ### Changed * TimeZone: fix inverted check of TZ, from PR #5 of @merikz -## [4.1.3-7] - 13/08/2017 +## 4.1.3-7 - 13/08/2017 ### Changed * Correct MIME types provided by the lighttpd server (issue #4 by @vb4life) * Update par2cmdline to 0.7.3 -## [4.1.3-6] - 02/08/2017 +## 4.1.3-6 - 02/08/2017 ### Changed * Add env variable driven timezone -## [4.1.3-5] - 23/07/2017 +## 4.1.3-5 - 23/07/2017 ### Changed * Disabling strict hostkey checking. As per the comment this should be the intended behavior. -## [4.1.3-4] - 26/06/2017 +## 4.1.3-4 - 26/06/2017 ### Added * Persist log dirs files in /data/backuppc -## [4.1.3-3] - 12/06/2017 +## 4.1.3-3 - 12/06/2017 ### Changed * Update perl lib BackupPC::XS to 0.56 * Update rsync-bpc to 3.0.9.8 -## [4.1.3-2] - 08/06/2017 +## 4.1.3-2 - 08/06/2017 ### Added * Persist htpasswd config for admin access -## [4.1.3-1] - 07/06/2017 +## 4.1.3-1 - 07/06/2017 ### Changed * Update Alpine base image to 3.6 -## [4.1.3] - 06/06/2017 +## 4.1.3 - 06/06/2017 ### Changed * Update BackupPC to 4.1.3 * Update perl lib BackupPC::XS to 0.55 * Update par2cmdline to 0.7.2 -## [4.1.2-1] - 26/05/2017 +## 4.1.2-1 - 26/05/2017 ### Changed * Update perl lib BackupPC::XS to 0.54 * Update rsync-bpc to 3.0.9.7 * Disable strict host key checking -## [4.1.2] - 21/05/2017 +## 4.1.2 - 21/05/2017 ### Changed * Update BackupPC to 4.1.2 -## [4.1.1] - 22/04/2017 +## 4.1.1 - 22/04/2017 ### Changed * Update BackupPC to 4.1.1 -## [4.1.0] - 22/04/2017 +## 4.1.0 - 22/04/2017 ### Changed * Update BackupPC to 4.1.0 -## [4.0.0] - 22/04/2017 +## 4.0.0 - 22/04/2017 ### Added * Create this docker and its core principles. \ No newline at end of file diff --git a/utils/create_release.py b/utils/create_release.py new file mode 100644 index 0000000..dde2998 --- /dev/null +++ b/utils/create_release.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python3 +import datetime +import os +import subprocess +import sys +from distutils.version import StrictVersion + +PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) + + +def main(): + git_clean = subprocess.check_output( + "git status --porcelain", shell=True, universal_newlines=True, + ).strip() + if git_clean: + raise RuntimeError("Error, git workspace is not clean: \n{0}".format(git_clean)) + + with open(os.path.join(PROJECT_ROOT, "VERSION")) as file_h: + current_version = file_h.read().strip() + + print("Current version is: {0}".format(current_version)) + print("Please insert new version:") + new_version = str(input()) + + if StrictVersion(new_version) <= StrictVersion(current_version): + raise RuntimeError( + "Error new version is below current version: {0} < {1}".format( + new_version, current_version + ) + ) + + try: + with open(os.path.join(PROJECT_ROOT, "CHANGELOG.md")) as file_h: + changelog = file_h.read() + + today = datetime.datetime.today() + changelog = changelog.replace( + "## master - CURRENT\n", + """\ +## master - CURRENT +## {0} - {1} +""".format( + new_version, today.strftime("%d/%m/%Y") + ), + ) + + with open(os.path.join(PROJECT_ROOT, "CHANGELOG.md"), "w") as file_h: + file_h.write(changelog) + + with open(os.path.join(PROJECT_ROOT, "VERSION"), "w") as file_h: + file_h.write(new_version) + + subprocess.check_call( + 'git commit -a -m "Version {0}"'.format(new_version), shell=True + ) + subprocess.check_call("git tag v{0}".format(new_version), shell=True) + subprocess.check_call("git push --tags", shell=True) + subprocess.check_call("git push", shell=True) + + except subprocess.CalledProcessError as e: + print("Error detected, cleaning state.") + subprocess.call("git tag -d v{0}".format(new_version), shell=True) + subprocess.check_call("git reset --hard", shell=True) + raise e + + +if __name__ == "__main__": + main() diff --git a/utils/extract_changelog.py b/utils/extract_changelog.py new file mode 100644 index 0000000..1da963a --- /dev/null +++ b/utils/extract_changelog.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python3 +from __future__ import print_function + +import os +import re +import sys + +ROOT = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) + +NEW_SECTION_PATTERN = re.compile(r"^\s*##\s*[\d.-]+\s*-\s*[\d/]+\s*$") + + +def main(): + version = sys.argv[1] + + if version == "latest": + section_pattern = NEW_SECTION_PATTERN + else: + section_pattern = re.compile( + r"^\s*##\s*{0}\s*-\s*[\d/]+\s*$".format(version.replace(".", "\\.")) + ) + + with open(os.path.join(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 + break + i = i + 1 + + changelog = [entry for entry in changelog if entry] + + print("\n".join(changelog)) + + +if __name__ == "__main__": + main() From 1122c0149f8975aa385f990f3b3726ed54f8e490 Mon Sep 17 00:00:00 2001 From: Adrien Ferrand Date: Thu, 13 Aug 2020 18:43:27 +0200 Subject: [PATCH 3/3] Remove relation to version in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6ae5b2c..7d6f113 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ #  ![](https://raw.githubusercontent.com/adferrand/docker-backuppc/master/images/logo_200px.png) adferrand/backuppc -![](https://img.shields.io/badge/tags-4%20latest-lightgrey.svg) [![](https://images.microbadger.com/badges/version/adferrand/backuppc:4.4.0-2.svg) ![](https://images.microbadger.com/badges/image/adferrand/backuppc:4.4.0-2.svg)](https://microbadger.com/images/adferrand/backuppc:4.4.0-2) [![CircleCI](https://circleci.com/gh/adferrand/docker-backuppc/tree/master.svg?style=shield)](https://circleci.com/gh/adferrand/docker-backuppc/tree/master) +![](https://img.shields.io/badge/tags-4%20latest-lightgrey.svg) [![](https://img.shields.io/github/v/release/adferrand/docker-backuppc) ![](https://images.microbadger.com/badges/image/adferrand/backuppc.svg)](https://microbadger.com/images/adferrand/backuppc) [![CircleCI](https://circleci.com/gh/adferrand/docker-backuppc/tree/master.svg?style=shield)](https://circleci.com/gh/adferrand/docker-backuppc/tree/master) * [Container functionalities](#container-functionalities) * [About BackupPC](#about-backuppc)