Skip to content

Commit c7bba63

Browse files
committed
Initial commit
0 parents  commit c7bba63

10 files changed

Lines changed: 792 additions & 0 deletions

File tree

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Update version and create release
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches:
7+
- master
8+
9+
jobs:
10+
11+
fetch-version:
12+
if: github.event.pull_request.merged
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
- name: Fetch latest release version
17+
id: fetch-latest-release
18+
uses: reloc8/action-latest-release-version@1.0.0
19+
- uses: actions/setup-python@v2
20+
with:
21+
python-version: 3.7
22+
- name: Choose new release version
23+
id: choose-release-version
24+
uses: reloc8/action-choose-release-version@1.0.0
25+
with:
26+
source-branch: ${{ github.event.pull_request.head.ref }}
27+
latest-version: ${{ steps.fetch-latest-release.outputs.latest-release }}
28+
outputs:
29+
new-version: ${{ steps.choose-release-version.outputs.new-version }}
30+
31+
update-version:
32+
needs: fetch-version
33+
runs-on: ubuntu-latest
34+
steps:
35+
- uses: actions/checkout@v2
36+
- run: git pull --ff-only
37+
- name: Update version file
38+
run: echo ${{ needs.fetch-version.outputs.new-version }} > version
39+
- name: Push local repository changes
40+
id: push-local-repository-changes
41+
uses: reloc8/action-push-local-changes@1.0.0
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
with:
45+
commit-message: "Version ${{ needs.fetch-version.outputs.new-version }}"
46+
outputs:
47+
commit-hash: ${{ steps.push-local-repository-changes.outputs.commit-hash }}
48+
49+
create-release:
50+
needs: [fetch-version, update-version]
51+
runs-on: ubuntu-latest
52+
steps:
53+
- uses: actions/checkout@v2
54+
- run: git pull --ff-only
55+
- name: Create new release
56+
uses: actions/create-release@v1
57+
env:
58+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
with:
60+
tag_name: ${{ needs.fetch-version.outputs.new-version }}
61+
release_name: ${{ needs.fetch-version.outputs.new-version }}
62+
draft: false
63+
prerelease: false
64+
commitish: ${{ needs.update-version.outputs.commit-hash }}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.DS_Store
2+
.idea
3+
.venv
4+
*.egg-info

LICENSE.txt

Lines changed: 661 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Python Package Template
2+
3+
A template for Python packages with Continuous Integration capabilities.
4+
5+
When a pull request is merged into master a new version is released based on the name of the merged branch.
6+
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)).
7+
8+
## Development
9+
10+
1. Create a virtual environment:
11+
12+
`$ python3 -m venv .venv`
13+
14+
2. Activate the created environment:
15+
16+
`$ source .venv/bin/activate`
17+
18+
3. Upgrade `pip`:
19+
20+
`$ python3 -m pip install --upgrade pip`
21+
22+
4. Install the requirements:
23+
24+
`$ pip install --upgrade -r requirements.txt`

python_package_template/__init__.py

Whitespace-only changes.

python_package_template/core/__init__.py

Whitespace-only changes.

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-e .

setup.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import os
2+
import setuptools
3+
4+
from typing import AnyStr
5+
6+
7+
GITHUB_PERSONAL_ACCESS_TOKEN = os.getenv('GITHUB_PERSONAL_ACCESS_TOKEN')
8+
9+
10+
def private_dependency(personal_access_token: AnyStr,
11+
repo_user: AnyStr, repo_name: AnyStr,
12+
package_name: AnyStr, package_version: AnyStr):
13+
"""Defines a dependency from a private Github repository
14+
15+
:param personal_access_token: Github Personal Access Token
16+
:param repo_user: Dependency repository user
17+
:param repo_name: Dependency repository name
18+
:param package_name: Dependency package name
19+
:param package_version: Dependency repository release (tag)
20+
:return: The dependency specification for the install_requires field
21+
"""
22+
23+
return f'{package_name} @ ' \
24+
f'git+https://{personal_access_token}@github.com/' \
25+
f'{repo_user}/{repo_name}.git/@{package_version}#egg={package_name}-0'
26+
27+
28+
with open('version', 'r') as version:
29+
30+
setuptools.setup(
31+
name='python_package_template',
32+
version=version.readline(),
33+
author='Alessio Vierti',
34+
packages=setuptools.find_packages(exclude=['tests']),
35+
install_requires=[],
36+
python_requires='>=3.6'
37+
)

tests/__init__.py

Whitespace-only changes.

version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.0.0

0 commit comments

Comments
 (0)