Skip to content

Commit

Permalink
Merge pull request #522 from joergsteffens/dev/joergs/bareos-19.2/git…
Browse files Browse the repository at this point in the history
…hub-action-publish-to-pypi

 python-bareos: publish to PyPI.org by using Github Actions (bareos-19.2)
  • Loading branch information
joergsteffens committed May 15, 2020
2 parents 020676b + f94cca2 commit 2c49b5a
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 4 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/publish-release-to-pypi.yml
@@ -0,0 +1,50 @@
name: "[Release] python-bareos -> https://pypi.org/"

on:
push:
tags:
- Release/*

jobs:
build-and-publish:
name: "Build python-bareos and publish it to https://pypi.org/"
runs-on: ubuntu-18.04

steps:
- name: "Checkout source"
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: "Checkout tags"
# for get-version.sh, an unshallow git checkout with tags is needed.
run: git fetch --tag

- name: "Set up Python"
uses: actions/setup-python@v1
with:
python-version: 3.7

- name: "Build python package"
run: |
pip install --user wheel
cd python-bareos
# sdist mangles around with version information.
# We replace ~pre with dev, as this will not be modified.
# (pre will be replaced with rc).
../docs/manuals/source/get-version.sh > bareos/VERSION.txt
printf "Version: %s\n" $(cat bareos/VERSION.txt)
python setup.py sdist bdist_wheel
- name: "Create artifact"
# creating an artifact is not required for publishing to pypi.
uses: actions/upload-artifact@v2
with:
path: python-bareos/dist/

- name: "Publish to pypi.org"
uses: pypa/gh-action-pypi-publish@v1.1.0
with:
repository_url: https://pypi.org/legacy/
password: ${{ secrets.pypi_password }}
packages_dir: python-bareos/dist/
59 changes: 59 additions & 0 deletions .github/workflows/publish-to-test-pypi.yml
@@ -0,0 +1,59 @@
name: "python-bareos -> https://test.pypi.org/"

#
# build a python-bareos dev package
# for every change in master,
# affecting python-bareos.
#

on:
push:
branches:
- master
paths:
- python-bareos/**
- .github/workflows/publish-to-test-pypi.yml

jobs:
build-and-publish:
name: "Build python-bareos and publish it to https://test.pypi.org/"
runs-on: ubuntu-18.04

steps:
- name: "Checkout source"
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: "Checkout tags"
# for get-version.sh, an unshallow git checkout with tags is needed.
run: git fetch --tag

- name: "Set up Python"
uses: actions/setup-python@v1
with:
python-version: 3.7

- name: "Build python package"
run: |
pip install --user wheel
cd python-bareos
# sdist mangles around with version information.
# We replace ~pre with dev, as this will not be modified.
# (pre will be replaced with rc).
../docs/manuals/source/get-version.sh > bareos/VERSION.txt
printf "Version: %s\n" $(cat bareos/VERSION.txt)
python setup.py sdist bdist_wheel
- name: "Create artifact"
# creating an artifact is not required for publishing to pypi.
uses: actions/upload-artifact@v2
with:
path: python-bareos/dist/

- name: "Publish to test.pypi.org"
uses: pypa/gh-action-pypi-publish@v1.1.0
with:
repository_url: https://test.pypi.org/legacy/
password: ${{ secrets.test_pypi_password }}
packages_dir: python-bareos/dist/
7 changes: 6 additions & 1 deletion python-bareos/setup.py
@@ -1,6 +1,7 @@
#!/usr/bin/python

import os
import re
from setuptools import find_packages, setup


Expand All @@ -11,7 +12,11 @@ def get_version():
with open(
os.path.join(base_dir, "bareos", "VERSION.txt")
) as version_file:
__version__ = version_file.read().strip()
# read version
# and adapt it according to
# https://www.python.org/dev/peps/pep-0440/.
fullversion = version_file.read().strip()
__version__ = re.compile(r'~pre([0-9]+).*').sub(r'.dev\1', fullversion)
except IOError:
# Fallback version.
# First protocol implemented
Expand Down
1 change: 0 additions & 1 deletion systemtests/CMakeLists.txt
Expand Up @@ -606,7 +606,6 @@ endif()

# python-bareos-test does not work on installed files
if(PYTHON AND NOT RUN_SYSTEMTESTS_ON_INSTALLED_FILES)

list(APPEND SYSTEM_TESTS "python-bareos-test")
else()
list(APPEND SYSTEM_TESTS_DISABLED "python-bareos-test")
Expand Down
Expand Up @@ -71,8 +71,9 @@ def get_operator_password(self, username=None):


class PythonBareosModuleTest(PythonBareosBase):
def versiontuple(self, v):
return tuple(map(int, (v.split("."))))
def versiontuple(self, versionstring):
version, separator, suffix = versionstring.partition('~')
return tuple(map(int, (version.split("."))))

def test_exception_connection_error(self):
"""
Expand Down

0 comments on commit 2c49b5a

Please sign in to comment.