Skip to content

Commit

Permalink
First version
Browse files Browse the repository at this point in the history
  • Loading branch information
vgeneves committed Apr 8, 2021
1 parent b03434c commit e9074da
Show file tree
Hide file tree
Showing 17 changed files with 1,664 additions and 4 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: build and push docker service

on:
push:
branches:
- master

workflow_dispatch:
inputs:
tag:
description: 'Tag to push on docker hub'
required: true

release:
types: [created]

env:
IMAGE_NAME: 'wirepas/provisioning_server'

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v2

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Set tag for push
if: github.event_name == 'push'
run: echo "TAG1=$IMAGE_NAME:edge" >> $GITHUB_ENV

- name: Set tag for manually triggered
if: github.event_name == 'workflow_dispatch'
run: echo "TAG1=$IMAGE_NAME:${{ github.event.inputs.tag }}" >> $GITHUB_ENV

- name: Set tag for release version
if: github.event_name == 'release'
run: echo "TAG1=$IMAGE_NAME:${{ github.event.release.tag_name }}" >> $GITHUB_ENV

- name: Set additionnal latest tag also for official release
if: github.event_name == 'release' && !contains(github.event.release.tag_name, 'rc')
run: echo "TAG2=$IMAGE_NAME:latest" >> $GITHUB_ENV

- name: Login to docker hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push
uses: docker/build-push-action@v2
with:
context: .
file: docker/Dockerfile
platforms: linux/amd64
push: true
tags: |
${{ env.TAG1 }}
${{ env.TAG2 }}
106 changes: 106 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Create Python package and publish it

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
release:
types: [created]
workflow_dispatch:
inputs:
version_name:
description: 'Version used on testPypi'
required: true

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: "3.8"

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 setuptools wheel
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
#- name: Install wheel locally
# run: pip install .

- name: Get short sha
uses: benjlevesque/[email protected]
id: short-sha
with:
length: 6

- name: Set Version for master push
if: ${{ github.event_name == 'push' }}
run: echo "VERSION=${{ steps.short-sha.outputs.sha }}" >> $GITHUB_ENV

- name: Set Version for release
if: ${{ github.event_name == 'release' }}
run: echo "VERSION=${{ github.event.release.tag_name }}" >> $GITHUB_ENV

- name: Set Version for PR
if: ${{ github.event_name == 'pull_request' }}
run: echo "VERSION=PR_${{ github.event.pull_request.number }}" >> $GITHUB_ENV

- name: Set Version for manual triggering
if: ${{ github.event_name == 'workflow_dispatch' }}
run: echo "VERSION=${{ github.event.inputs.version_name }}" >> $GITHUB_ENV

- name: Set the version
run: |
sed -i '/__version__ = /c\__version__ = "${{ env.VERSION }}"' wirepas_provisioning_server/__about__.py
- name: Build the wheel
run: python setup.py sdist bdist_wheel

- name: Save produced wheel name and path
run: echo "WHEEL_FILE=$(ls dist/*-py3-none-any.whl)" >> $GITHUB_ENV

- name: Store artifacts
uses: actions/upload-artifact@v2
with:
path: ${{ env.WHEEL_FILE }}

- name: Upload Wheel for releases
if: ${{ github.event_name == 'release' }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ env.WHEEL_FILE }}
asset_content_type: application/zip
asset_name: wirepas_provisioning-${{ env.VERSION }}-py3-none-any.whl

- name: Publish package to TestPyPI for manual build
if: ${{ github.event_name == 'workflow_dispatch' }}
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_TEST_PWD }}
repository_url: https://test.pypi.org/legacy/

- name: Publish package to PyPI for release
if: ${{ github.event_name == 'release' }}
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_PWD }}
129 changes: 129 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Apache License
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/

Expand Down Expand Up @@ -198,4 +198,4 @@ Apache License
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
Loading

0 comments on commit e9074da

Please sign in to comment.