Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
alessiovierti committed Jan 31, 2021
0 parents commit c7bba63
Show file tree
Hide file tree
Showing 10 changed files with 792 additions and 0 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Update version and create release

on:
pull_request:
types: [closed]
branches:
- master

jobs:

fetch-version:
if: github.event.pull_request.merged
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Fetch latest release version
id: fetch-latest-release
uses: reloc8/[email protected]
- uses: actions/setup-python@v2
with:
python-version: 3.7
- name: Choose new release version
id: choose-release-version
uses: reloc8/[email protected]
with:
source-branch: ${{ github.event.pull_request.head.ref }}
latest-version: ${{ steps.fetch-latest-release.outputs.latest-release }}
outputs:
new-version: ${{ steps.choose-release-version.outputs.new-version }}

update-version:
needs: fetch-version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: git pull --ff-only
- name: Update version file
run: echo ${{ needs.fetch-version.outputs.new-version }} > version
- name: Push local repository changes
id: push-local-repository-changes
uses: reloc8/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
commit-message: "Version ${{ needs.fetch-version.outputs.new-version }}"
outputs:
commit-hash: ${{ steps.push-local-repository-changes.outputs.commit-hash }}

create-release:
needs: [fetch-version, update-version]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: git pull --ff-only
- name: Create new release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ needs.fetch-version.outputs.new-version }}
release_name: ${{ needs.fetch-version.outputs.new-version }}
draft: false
prerelease: false
commitish: ${{ needs.update-version.outputs.commit-hash }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.DS_Store
.idea
.venv
*.egg-info
661 changes: 661 additions & 0 deletions LICENSE.txt

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Python Package Template

A template for Python packages with Continuous Integration capabilities.

When a pull request is merged into master a new version is released based on the name of the merged branch.
For example, feature branches trigger new minor releases while bugfix branches trigger new patch releases ([more info here](https://github.com/reloc8/action-choose-release-version)).

## Development

1. Create a virtual environment:

`$ python3 -m venv .venv`

2. Activate the created environment:

`$ source .venv/bin/activate`

3. Upgrade `pip`:

`$ python3 -m pip install --upgrade pip`

4. Install the requirements:

`$ pip install --upgrade -r requirements.txt`
Empty file.
Empty file.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-e .
37 changes: 37 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import os
import setuptools

from typing import AnyStr


GITHUB_PERSONAL_ACCESS_TOKEN = os.getenv('GITHUB_PERSONAL_ACCESS_TOKEN')


def private_dependency(personal_access_token: AnyStr,
repo_user: AnyStr, repo_name: AnyStr,
package_name: AnyStr, package_version: AnyStr):
"""Defines a dependency from a private Github repository
:param personal_access_token: Github Personal Access Token
:param repo_user: Dependency repository user
:param repo_name: Dependency repository name
:param package_name: Dependency package name
:param package_version: Dependency repository release (tag)
:return: The dependency specification for the install_requires field
"""

return f'{package_name} @ ' \
f'git+https://{personal_access_token}@github.com/' \
f'{repo_user}/{repo_name}.git/@{package_version}#egg={package_name}-0'


with open('version', 'r') as version:

setuptools.setup(
name='python_package_template',
version=version.readline(),
author='Alessio Vierti',
packages=setuptools.find_packages(exclude=['tests']),
install_requires=[],
python_requires='>=3.6'
)
Empty file added tests/__init__.py
Empty file.
1 change: 1 addition & 0 deletions version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0.0

0 comments on commit c7bba63

Please sign in to comment.