-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c7bba63
Showing
10 changed files
with
792 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.DS_Store | ||
.idea | ||
.venv | ||
*.egg-info |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
-e . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.0.0 |