Skip to content

Commit

Permalink
- WIP: automate version increment
Browse files Browse the repository at this point in the history
- automate testing
- virtual environment setup
  • Loading branch information
MikeBusuttil committed Dec 14, 2023
1 parent 5a83ed4 commit 6557d5e
Show file tree
Hide file tree
Showing 12 changed files with 519 additions and 24 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/increment_and_publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: version auto-incrementing & package publishing
on:
workflow_dispatch:
pull_request:
types:
- closed
branches: ["master"]

jobs:
build:
if: github.event.pull_request.merged || github.event_name == 'workflow_dispatch'

runs-on: ubuntu-latest

steps:
- name: Checking out v3
uses: actions/checkout@v3

- name: Install Python and dependencies
uses: actions/setup-python@v3
with:
python-version: '3.12'

- name: Install dependencies
run: |
python -m
pip install wheel pyyaml sortedcontainers requests semver
- name: Increment version
run: python ./.github/workflows/version.py --increment

- name: Commit and push changes
run: |
git add .
git commit -m "increment to v$(python ./.github/workflows/version.py --get)"
git push --force
26 changes: 26 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: version auto-incrementing & package publishing
on:
pull_request:

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checking out v3
uses: actions/checkout@v3

- name: Install Python and dependencies
uses: actions/setup-python@v3
with:
python-version: '3.12'

- name: Install dependencies
run: |
python -m
pip install sortedcontainers
- name: Run tests
run: |
coverage run test/test.py
coverage report -m sigfig/sigfig.py
41 changes: 41 additions & 0 deletions .github/workflows/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
from pathlib import Path
from datetime import datetime
from sys import path
from yaml import safe_load, safe_dump
import toml
from requests import get
from semver import Version

path.insert(0, str(Path(__file__).parent / "../.."))
from setup import version as local_version
local_version = Version.parse(local_version)

def apply_citation_version(version):
citation_path = Path(__file__).parent / "../../CITATION.cff"
with open(citation_path, "r") as f:
citation = safe_load(f)
citation["version"] = str(version)
citation["date-released"] = datetime.now().strftime("%Y-%m-%d")
with open(citation_path, "w") as f:
f.write(safe_dump(citation, sort_keys=False))

def apply_pyproject_version(version):
pyproject_path = Path(__file__).parent / "../../pyproject.toml"
with open(pyproject_path, "r") as f:
pyproject = toml.load(f)
pyproject["tool"]["poetry"]["version"] = str(version)
with open(pyproject_path, "w") as f:
f.write(toml.dumps(pyproject))

def get_version():
print(local_version)

def increment():
published_version = Version.parse(get('https://pypi.org/pypi/sigfig/json').json()['info']['version'])
if local_version > published_version:
return
new_version = published_version.bump_patch()
# apply_citation_version(new_version)
apply_pyproject_version(new_version)

increment()
11 changes: 3 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
################################################################################
# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
################################################################################

/.vs
/test/.coverage
/test/coverage.xml
/sigfig/__pycache__
.coverage
coverage.xml
__pycache__
/dist
/sigfig.egg-info
/build
Expand Down
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ abstract: >-
sigfig is a Python package used for rounding numbers (with
expected results).
license: MIT
version: 1.3.2
version: 1.3.3
date-released: '2022-04-23'
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ Useful links:
* Python Package Index entry: https://pypi.org/project/sigfig/
* Source Code: https://github.com/drakegroup/sigfig/

Please direct any comments/suggestions/feedback/bugs to mike.busuttil@gmail.com and valdezt@gmail.com
Please direct any comments/suggestions/feedback/bugs to [the issues page](https://github.com/drakegroup/sigfig/issues)

Thanks for downloading :)
Thanks for downloading :)
9 changes: 5 additions & 4 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,17 @@
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys
sys.path.insert(0, os.path.abspath('..'))
from pathlib import Path
from sys import path
path.insert(0, str(Path(__file__).parent / '..'))
from setup import version

# -- Project information -----------------------------------------------------

from datetime import datetime
project = 'sigfig'
copyright = '2022, Michael Busuttil, Travis Valdez'
author = 'Michael Busuttil, Travis Valdez'
copyright = f'{datetime.now().strftime("%Y")}, {author}'

# The full version, including alpha/beta/rc tags
release = version
Expand Down
4 changes: 2 additions & 2 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ Useful links:
* Python Package Index entry: https://pypi.org/project/sigfig/
* Source Code: https://github.com/drakegroup/sigfig/

Please direct any comments/suggestions/feedback/bugs to mike.busuttil@gmail.com and valdezt@gmail.com
Please direct any comments/suggestions/feedback/bugs to [the issues page](https://github.com/drakegroup/sigfig/issues)

Thanks for downloading :)
Thanks for downloading :)
Loading

0 comments on commit 6557d5e

Please sign in to comment.