Skip to content

Commit

Permalink
Merge pull request #140 from priyanshuone6/release
Browse files Browse the repository at this point in the history
Add release workflow
  • Loading branch information
TomTranter authored Feb 17, 2022
2 parents 9131cee + 6f79d78 commit 9c3fcc1
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 1 deletion.
64 changes: 64 additions & 0 deletions .github/workflows/publish_pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Build and publish package to PyPI

on:
workflow_dispatch:
inputs:
target:
description: 'Deployment target. Can be "pypi" or "testpypi"'
default: 'pypi'

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8]

steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: pip install wheel

- name: Build package
run: python setup.py sdist --formats=gztar bdist_wheel

- name: Upload package
uses: actions/upload-artifact@v2
with:
name: files
path: ./dist/
if-no-files-found: error


publish:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download package
uses: actions/download-artifact@v2
with:
name: files
path: dist

- name: Publish on PyPI
if: github.event.inputs.target == 'pypi'
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
packages_dir: dist/

- name: Publish on TestPyPI
if: github.event.inputs.target == 'testpypi'
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.TESTPYPI_TOKEN }}
packages_dir: dist/
repository_url: https://test.pypi.org/legacy/
2 changes: 1 addition & 1 deletion liionpack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@
from .solvers import generic_actor
from .solvers import ray_actor

__version__ = "0.2.1"
__version__ = "0.3"
7 changes: 7 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,24 @@
except ImportError:
from distutils.core import setup

# Load version
main_ = {}
ver_path = convert_path("liionpack/__init__.py")
with open(ver_path) as f:
for line in f:
if line.startswith("__version__"):
exec(line, main_)

# Load readme for description
with open("README.md", encoding="utf-8") as f:
readme = f.read()

setup(
name="liionpack",
description="A battery pack simulator for PyBaMM",
version=main_["__version__"],
long_description=readme,
long_description_content_type="text/markdown",
classifiers=[
"Development Status :: 4 - Beta",
"License :: OSI Approved :: MIT License",
Expand Down

0 comments on commit 9c3fcc1

Please sign in to comment.