Skip to content

Commit

Permalink
Feature: Autopublish artifacts (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcrada authored Jan 5, 2024
1 parent 4ee9d13 commit 9bc0aa1
Show file tree
Hide file tree
Showing 10 changed files with 986 additions and 834 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Python package
name: Build

on:
push:
Expand All @@ -15,7 +15,7 @@ jobs:
python-version: ["3.9"] #, "3.7", "3.8", "3.9", "3.10"]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Publish

on:
release:
types:
- created

#pull_request: # test-only
#branches: [ main, development, feature/* ] # test-only

jobs:
publish:
runs-on: ubuntu-latest
environment:
name: release
#name: test-release # test-only
url: https://pypi.org/p/pyfuzzylite

permissions:
contents: write
id-token: write

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.9"

- name: Install requirements
run: pip install -r requirements.txt

- name: Build
run: poetry build

- name: Publish
uses: pypa/gh-action-pypi-publish@v1.8.10
#with:
# repository-url: https://test.pypi.org/legacy/ # test-only

- name: Install development dependencies for documentation
run: poetry install --only dev

- name: Publish documentation
run: nox -e docs -- publish
2 changes: 1 addition & 1 deletion AUTHOR
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Juan Rada-Vilela, Ph.D.
Juan Rada-Vilela, PhD
jcrada@fuzzylite.com
https://fuzzylite.com/jcrada
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pyfuzzylite™
# pyfuzzylite 8.0.0

***

Expand Down
4 changes: 2 additions & 2 deletions fuzzylite/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def __repr__(self) -> str:
return representation.as_constructor(self)

@abstractmethod
def to_string(self, instance: object) -> str:
def to_string(self, instance: Any, /) -> str:
"""Return string representation of the instance.
Args:
Expand All @@ -81,7 +81,7 @@ def to_string(self, instance: object) -> str:
string representation of the object
"""

def to_file(self, path: str | Path, instance: object) -> None:
def to_file(self, path: str | Path, instance: Any) -> None:
"""Write the string representation of the instance into the file.
Args:
Expand Down
2 changes: 1 addition & 1 deletion fuzzylite/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ class Information:
name: Final[str] = "fuzzylite"
description: Final[str] = "a fuzzy logic control library in Python"
license: Final[str] = "FuzzyLite License"
author: Final[str] = "Juan Rada-Vilela, Ph.D."
author: Final[str] = "Juan Rada-Vilela, PhD"
author_email: Final[str] = "jcrada@fuzzylite.com"
company: Final[str] = "FuzzyLite Limited"
website: Final[str] = "https://fuzzylite.com/"
Expand Down
5 changes: 5 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ theme:
- toc.integrate # TOC integrated in left panel
- content.action.edit # Edit documentation

validation:
omitted_files: warn
absolute_links: warn
unrecognized_links: warn

extra:
social:
- icon: fontawesome/brands/github
Expand Down
28 changes: 7 additions & 21 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,35 +134,21 @@ def benchmark(session: nox.Session) -> None:

@nox.session(python=False)
def docs(session: nox.Session) -> None:
"""Build the documentation."""
session.run(*"mkdocs build --strict".split(), external=True)


@nox.session(python=False)
def docs_deploy(session: nox.Session) -> None:
"""Deploy the documentation in Github Pages."""
session.run(*"mkdocs gh-deploy".split(), external=True)


@nox.session
def test_publish(session: nox.Session) -> None:
"""Build the distributable and upload it to testpypi."""
session.run(*"rm -rf dist/".split(), external=True)
session.run(*"poetry build".split(), external=True)
session.run(*"twine check --strict dist/*".split(), external=True)
session.run(
*"twine upload --repository testpypi dist/* --config-file .pypirc --verbose".split(),
external=True,
)
"""Build the documentation and deploy if passed `publish` in arguments."""
if "publish" in session.posargs:
session.run(*"mkdocs gh-deploy --strict --clean --force".split(), external=True)
else:
session.run(*"mkdocs build --strict --clean".split(), external=True)


@nox.session
def publish(session: nox.Session) -> None:
"""Build the distributable and upload it to pypi."""
repository = "testpypi" if "test" in session.posargs else "pypi"
session.run(*"rm -rf dist/".split(), external=True)
session.run(*"poetry build".split(), external=True)
session.run(*"twine check --strict dist/*".split(), external=True)
session.run(
*"twine upload --repository pypi dist/* --config-file .pypirc --verbose".split(),
*f"twine upload --repository {repository} dist/* --config-file .pypirc --verbose".split(),
external=True,
)
Loading

0 comments on commit 9bc0aa1

Please sign in to comment.