Skip to content

Commit

Permalink
update release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelJennings committed May 4, 2023
1 parent 9cd6592 commit 13a7daf
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 128 deletions.
17 changes: 11 additions & 6 deletions .github/workflows/on-release-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ on:
branches: [main]

jobs:
publish:
publish:
name: Publish on PyPI
runs-on: ubuntu-latest
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
steps:
- name: Check out
uses: actions/checkout@v3
Expand All @@ -22,21 +25,23 @@ jobs:
id: vars
run: echo tag=${GITHUB_REF#refs/*/} >> $GITHUB_OUTPUT

- name: Build and publish
- name: Build source files
run: |
source .venv/bin/activate
poetry config pypi-token.pypi $PYPI_TOKEN
poetry run invoke publish --rule $RELEASE_VERSION
poetry version $RELEASE_VERSION
poetry build
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
RELEASE_VERSION: ${{ steps.vars.outputs.tag }}

- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

- name: Build Changelog
id: github_release
uses: mikepenz/release-changelog-builder-action@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# docker:
# needs: publish
# name: Build container
Expand Down
30 changes: 0 additions & 30 deletions .readthedocs.yml

This file was deleted.

Empty file removed main.js
Empty file.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ python =
passenv = PYTHON_VERSION
allowlist_externals = poetry
commands =
poetry install -v
poetry install --without docs
pytest --doctest-modules tests --cov --cov-config=pyproject.toml --cov-report=xml
mypy
"""
Expand Down
24 changes: 0 additions & 24 deletions runtests.py

This file was deleted.

68 changes: 1 addition & 67 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,44 +34,13 @@ def check(c):
def test(c, tox=False):
"""
Run the test suite
"""
if tox:
print("🚀 Testing code: Running pytest with all tests")
c.run("tox")
else:
print("🚀 Testing code: Running pytest")
c.run("poetry run pytest --cov --cov-config=pyproject.toml --cov-report=xml")


@task
def clean_build(c):
print("🚀 Removing old build artifacts")
c.run("rm -fr build/")
c.run("rm -fr dist/")
c.run("rm -fr *.egg-info")


@task
def clean_pyc(c):
"""
Remove python file artifacts
"""
print("🚀 Removing python file artifacts")
c.run("find . -name '*.pyc' -exec rm -f {} +")
c.run("find . -name '*.pyo' -exec rm -f {} +")
c.run("find . -name '*~' -exec rm -f {} +")


@task
def coverage(c):
"""
check code coverage quickly with the default Python
"""
c.run("coverage run --source literature runtests.py tests")
c.run("coverage report -m")
c.run("coverage html")
c.run("open htmlcov/index.html")
c.run("poetry run pytest --cov --cov-config=pyproject.toml --cov-report=html")


@task
Expand All @@ -84,41 +53,6 @@ def docs(c):
c.run("sphinx-build -E -b html docs docs/_build")


@task
def clean(c):
"""
Remove python file and build artifacts
"""
clean_build(c)
clean_pyc(c)


@task
def publish(c, rule=""):
"""
Publish a new version of the package to PyPI
"""

# 1. Set the current version using the specified rule
# see https://python-poetry.org/docs/cli/#version for rules on bumping version
if rule:
c.run(f"poetry version {rule}")

# 2. Build the source and wheels archive
# https://python-poetry.org/docs/cli/#build
print("🔧 Building: Creating wheel file.")
c.run("poetry build")

# 3. Dry run first to make sure everything is working
print("🚀 Publishing: Dry run.")
c.run("poetry publish --dry-run")

# This command publishes the package, previously built with the build command, to the remote repository. It will automatically register the package before uploading if this is the first time it is submitted.
# https://python-poetry.org/docs/cli/#publish
print("📦 Publishing to PyPI")
c.run("poetry publish")


@task
def tag(c, rule=""):
"""
Expand Down

0 comments on commit 13a7daf

Please sign in to comment.