Skip to content

Commit

Permalink
CI: automatic releases
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurentRDC committed Jun 5, 2021
1 parent 5278f09 commit 832512e
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 3 deletions.
55 changes: 54 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,57 @@ jobs:
- name: Doctests
run: |
python -m sphinx -b doctest docs build
python -m doctest README.md
python -m doctest README.md
- name: Build artifacts
run: |
python setup.py sdist bdist_wheel
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: ${{ runner.os }}-py${{ matrix.python-version }}-artifact
path: dist/*
retention-days: 7


release:
needs: [build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/download-artifact@v2
with:
path: artifacts/

- name: Create release description
run: |
python release-description.py CHANGELOG.rst > description.md
cat description.md
- name: Move artifacts
run: |
ls --recursive artifacts/
mkdir dist
mv --backup=numbered artifacts/*/** dist
rm -f dist/*~
echo "To be uploaded:"
ls dist
- name: Create release
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
body_path: description.md
files: |
dist/*
- name: Upload to PyPI
if: startsWith(github.ref, 'refs/tags/v')
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
9 changes: 7 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ What's new

.. currentmodule:: crystals

1.3.1
-----
Release 1.3.2
-------------

* Releases are now automatically performed using Github Actions

Release 1.3.1
-------------

* The distinction between :class:`Supercell` and :class:`Crystal` no longer exists; :class:`Supercell` objects can be used everywhere a :class:`Crystal` is expected.

Expand Down
9 changes: 9 additions & 0 deletions RELEASE-CHECKLIST.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Release checklist
-----------------

To create a release, simply create a tag that starts with 'v' (e.g. 'v2.0.0')::

git tag -a "v2.0.0"
git push origin "v2.0.0"

The package will be automatically tested, released on GitHub and uploaded to PyPI.
1 change: 1 addition & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
sphinx >= 3
sphinx_rtd_theme >= 0.4
pytest >= 6
wheel
# Optional requirements used for tests
biopython >= 1, <2
ase >= 3, <4
25 changes: 25 additions & 0 deletions release-description.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""
Extract the changes from last release
"""

import sys

if __name__ == "__main__":
filename = sys.argv[1]

with open(filename, mode="r") as f:

# Look for the first second-level title
for line in f:
if line.startswith("Release"):
break

print(line, end="")
for line in f:
if not line.startswith("Release"):
print(line, end="")
else:
# Exit gracefully
sys.exit(0)
# There was a problem: Exit with error
sys.exit(-1)

0 comments on commit 832512e

Please sign in to comment.