diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..4a66196 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,50 @@ +name: Release + +on: + push: + tags: ["*"] + +jobs: + build: + name: Build distribution + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/project/flashmd + permissions: + id-token: write + contents: write + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + - run: python -m pip install tox tox-uv + - name: Check tag matches package version + if: startsWith(github.ref, 'refs/tags/v') + run: | + tag="${GITHUB_REF_NAME#v}" + version=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])") + if [ "$tag" != "$version" ]; then + echo "tag $GITHUB_REF_NAME does not match pyproject.toml version $version" + exit 1 + fi + - name: Build package + run: tox -e build + - name: Publish distribution to PyPI + if: startsWith(github.ref, 'refs/tags/v') + uses: pypa/gh-action-pypi-publish@release/v1 + - name: Publish to GitHub release + if: startsWith(github.ref, 'refs/tags/v') + uses: softprops/action-gh-release@v2 + with: + files: | + dist/*.tar.gz + dist/*.whl + prerelease: ${{ contains(github.ref, '-rc') }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 9505e1b..d2eeaa8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,10 @@ [project] name = "flashmd" -version = "0.2.9" +version = "0.3.0" requires-python = ">=3.11" readme = "README.md" -license = {text = "Apache-2.0"} +license = "Apache-2.0" description = "Accelerated molecular dynamics with large-time-step predictions" authors = [{name = "flashmd developers"}] @@ -20,7 +20,6 @@ keywords = ["machine learning", "molecular modeling", "molecular dynamics"] classifiers = [ "Development Status :: 4 - Beta", "Intended Audience :: Science/Research", - "License :: OSI Approved :: Apache Software License", "Operating System :: POSIX", "Operating System :: MacOS :: MacOS X", "Operating System :: Microsoft :: Windows", diff --git a/tox.ini b/tox.ini index 2970287..f84bbcd 100644 --- a/tox.ini +++ b/tox.ini @@ -51,3 +51,16 @@ commands = pytest \ --import-mode=append \ {posargs} + +[testenv:build] +description = Build the package and check its integrity +package = skip +deps = + build + twine +allowlist_externals = rm +commands_pre = + rm -rf {toxinidir}/dist +commands = + python -m build + twine check dist/*.tar.gz dist/*.whl