Skip to content

Commit

Permalink
FEAT: Automated PYPI publication
Browse files Browse the repository at this point in the history
  • Loading branch information
daquintero committed Jun 11, 2023
1 parent 67393b6 commit df9f097
Show file tree
Hide file tree
Showing 10 changed files with 242 additions and 42 deletions.
12 changes: 12 additions & 0 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[bumpversion]
current_version = 0.0.11
commit = True
tag = True

[bumpversion:file:setup.py]
search = version='{current_version}'
replace = version='{new_version}'

[bumpversion:file:piel/__init__.py]
search = __version__ = '{current_version}'
replace = __version__ = '{new_version}'
15 changes: 15 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
* piel version:
* Python version:
* Operating System:

### Description

Describe what you were trying to get done.
Tell us what happened, what went wrong, and what you expected to happen.

### What I Did

```
Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.
```
142 changes: 142 additions & 0 deletions .github/workflows/create_release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
name: Create Release

permissions:
contents: write

on:
push:
branches:
- master

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.x

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install bump2version bumpversion # Install bump2version if not already installed
- name: Bump version
env:
GITHUB_USERNAME: daquintero
GITHUB_EMAIL: [email protected]
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Use the appropriate bumpversion command for your project
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
bump2version patch # Minor increase
export VERSION=$(bumpversion --dry-run --list setup.py | grep '^new_version=' | sed -r 's/^new_version=//')
echo "VERSION=$VERSION" >> $GITHUB_ENV
git tag -d v$VERSION
git tag v$VERSION
# - name: Bump version and push tag
# uses: jaumann/[email protected]
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# - name: Set version as environment variable
# run: |
# export VERSION=$(bumpversion --list setup.py | grep '^new_version=' | sed -r 's/^new_version=//')
# echo $VERSION

# - name: Commit files
# env:
# GITHUB_USERNAME: daquintero
# GITHUB_EMAIL: [email protected]
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# run: |
# git config --local user.email "[email protected]"
# git config --local user.name "daquintero"
# git commit -am "UP: BumpVersion v${{ env.VERSION }}"
#
# - name: Commit files
# run: |
# git tag v$VERSION
# git commit -a -m "PYPI: v$VERSION"
# git config --local user.email "github-actions[bot]@users.noreply.github.com"
# git config --local user.name "github-actions[bot]"

- name: Push changes
env:
GITHUB_USERNAME: daquintero
GITHUB_EMAIL: [email protected]
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tags: true

- name: Create release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ env.VERSION }} # Use the incremented version as the tag name
release_name: ${{ env.VERSION }} # Customize the release name
body: |
Update PYPI ${{ env.VERSION }}
draft: false
release: true

#name: Create Release
#
#on:
# push:
# branches:
# - master
#
#permissions:
# contents: write
#
#jobs:
# create_release:
# runs-on: ubuntu-latest
#
# steps:
# - name: Checkout code
# uses: actions/checkout@v2
#
# - name: Set up Python
# uses: actions/setup-python@v2
# with:
# python-version: 3.x
#
# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip
# pip install bumpversion # Install bumpversion if not already installed
#
# - name: Bump version
# env:
# GITHUB_USERNAME: daquintero
# GITHUB_EMAIL: [email protected]
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# run: |
# # Use the appropriate bumpversion command for your project
# bumpversion patch # Minor increase
#
# - name: Set version as environment variable
# run: |
# export VERSION=$(bumpversion --dry-run --list | grep '^new_version=' | sed -r 's/^new_version=//')
#
# - name: Create release
# uses: actions/create-release@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# tag_name: v${{ env.VERSION }} # Use the incremented version as the tag name
# release_name: Release ${{ env.VERSION }} # Customize the release name
# body: |
# Update PYPI v${{ env.VERSION }}
# draft: false
# prerelease: false
13 changes: 8 additions & 5 deletions .github/workflows/python_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,34 @@
# documentation.

name: Upload Python Package

on:
release:
types: [published]
workflow_run:
workflows: ["create_release"]
types:
- completed

permissions:
contents: read

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

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

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build

- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
Expand Down
38 changes: 38 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: ca84e500209b3757213759d4d522f8ed307cd638
hooks:
- id: check-yaml
exclude: ^(conda\.recipe/meta\.yaml|conda_build/templates/.*\.yaml|docs/click/meta\.yaml|conda/meta\.yaml|conda/construct.yaml|.*\.pic\.yml|conda/constructor/Miniforge3/construct.yaml)
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black

- repo: https://github.com/asottile/blacken-docs
rev: 7b71075ceb458be255e24da587c0275818b51faa
hooks:
- id: blacken-docs
additional_dependencies: [black==23.3.0]

- repo: https://github.com/codespell-project/codespell
rev: ad3ff374e97e29ca87c94b5dc7eccdd29adc6296
hooks:
- id: codespell
args: ["-L TE,TE/TM,te,ba,FPR,fpr_spacing,ro,nd,donot,schem"]
additional_dependencies:
- tomli

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: "7c149cf0b9d2c4f7558de1ea5d2c137ca074d9d0"
hooks:
- id: ruff

- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: d2425a62376c2197448cce2f825d5a0c3926b862
hooks:
- id: pretty-format-toml
args: [--autofix]
41 changes: 22 additions & 19 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Config file for automatic testing at travis-ci.com

language: python
python:
- 3.8
- 3.7
- 3.6
#language: python
#python:
# - 3.8
# - 3.7
# - 3.6

env:
- MY_SECRET=$TRAVIS_KEY
Expand All @@ -15,17 +15,20 @@ install: pip install -U tox-travis
# Command to run tests, e.g. python setup.py test
script: tox

# Assuming you have installed the travis-ci CLI tool, after you
# create the Github repo and add it to Travis, run the
# following command to finish PyPI deployment setup:
# $ travis encrypt --add deploy.password
deploy:
provider: pypi
distributions: sdist bdist_wheel
user: ${{ secrets.PYPI_USERNAME }}"
password:
secure: ${{ secrets.PYPI_PASSWORD }}"
on:
tags: true
repo: daquintero/piel
python: 3.8
## Assuming you have installed the travis-ci CLI tool, after you
## create the Github repo and add it to Travis, run the
## following command to finish PyPI deployment setup:
## $ travis encrypt --add deploy.password



#deploy:
# provider: pypi
# distributions: sdist bdist_wheel
# user: ${{ secrets.PYPI_USERNAME }}"
# password:
# secure: ${{ secrets.PYPI_PASSWORD }}"
# on:
# tags: true
# repo: daquintero/piel
# python: 3.8
2 changes: 1 addition & 1 deletion piel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

__author__ = """Dario Quintero"""
__email__ = '[email protected]'
__version__ = '0.0.1'
__version__ = '0.0.11'
6 changes: 3 additions & 3 deletions .readthedocs.yaml → readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# .readthedocs.yaml
# readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

Expand Down Expand Up @@ -27,6 +27,6 @@ sphinx:
# Optional but recommended, declare the Python requirements required
# to build your documentation
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
install:
python:
install:
- requirements: requirements_dev.txt
13 changes: 0 additions & 13 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
[bumpversion]
current_version = 0.0.1
commit = True
tag = True

[bumpversion:file:setup.py]
search = version='{current_version}'
replace = version='{new_version}'

[bumpversion:file:piel/__init__.py]
search = __version__ = '{current_version}'
replace = __version__ = '{new_version}'

[bdist_wheel]
universal = 1

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@
test_suite='tests',
tests_require=test_requirements,
url='https://github.com/daquintero/piel',
version='0.0.2',
version='0.0.11',
zip_safe=False,
)

0 comments on commit df9f097

Please sign in to comment.