Skip to content

Commit

Permalink
Add workflows for automated package upload
Browse files Browse the repository at this point in the history
Added workflows that automatically publish the package to the PyPI host.
  • Loading branch information
erlete committed Dec 20, 2022
1 parent dfe22f4 commit 4d409a5
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: PyPI release

on:
workflow_run:
workflows: [Update package version]
types:
- completed

jobs:

deploy-package:

runs-on: ubuntu-latest

steps:

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.9'

- name: Install dependencies
run: python -m pip install --upgrade pip twine setuptools wheel six requests build urllib3

- uses: actions/checkout@v3

- name: Build package
run: python -m build

- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{secrets.PYPI_API_TOKEN}}
47 changes: 47 additions & 0 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---

name: Python Test Execution

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs:

build:

runs-on: ubuntu-latest

steps:

- uses: actions/checkout@v3

- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"

- name: Install and activate virtual environment
run: |
python -m pip install --upgrade pip
python -m pip install virtualenv
python -m virtualenv .venv
source .venv/bin/activate
- name: Install dependencies
run: |
python -m pip install pytest
if [ -f requirements.txt ]; then
python -m pip install -r requirements.txt
fi
- name: Install package from local source
run: python -m pip install -e .

- name: Test with PyTest
run: python -m pytest tests/
37 changes: 37 additions & 0 deletions .github/workflows/update-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Update package version

on:
release:
types: [published]

jobs:

update-package-version:

runs-on: ubuntu-latest

steps:

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.9'

- uses: actions/checkout@v3

- name: Update pyproject.toml version
run: |
git clone https://gist.github.com/a66c601b7ebab8dc9370348697e540d1.git
version=${{github.ref}}
python3 a66c601b7ebab8dc9370348697e540d1/pytoml-version-updater.py ${version#refs/tags/v}
- name: Config git
run: |
git config --global user.email "[email protected]"
git config --global user.name "Paulo Sánchez"
- name: Commit and push pyproject.toml modifications
run: |
version=${{github.ref}}
git commit pyproject.toml -m "Update version to ${version#refs/tags/v}"
git push origin HEAD:main

0 comments on commit 4d409a5

Please sign in to comment.