Skip to content

Commit

Permalink
CI: automatic releases via Github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurentRDC committed Jun 6, 2021
1 parent c8945f3 commit 4549aae
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 52 deletions.
101 changes: 100 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,103 @@ jobs:
- name: Doctests
run: |
python -m sphinx -b doctest docs build
python -m sphinx -b doctest docs build
- 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

win-installer:
# To prevent this job from running, have "[skip ci]" or "[ci skip]" in the commit message
if: contains(toJson(github.event.commits), '[ci skip]') == false && contains(toJson(github.event.commits), '[skip ci]') == false

env:
EXE_NAME: 'iris-win-installer-x64.exe'

runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest]
python-version: [3.9]

steps:
- uses: actions/checkout@v2

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

- uses: actions/cache@v2
if: startsWith(runner.os, 'Windows')
with:
path: ~\AppData\Local\pip\Cache
key: ${{ runner.os }}-py${{ matrix.python-version }}-pip-${{ hashFiles('**/*requirements.txt') }}

- name: Build installer
run: |
python installer/build.py ${{ env.EXE_NAME }}
- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
path: dist/${{ env.EXE_NAME }}
name: ${{ env.EXE_NAME }}
retention-days: 7

release:
needs: [build, win-installer]
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-installer
mv artifacts/*/**.exe dist-installer
mkdir dist
mv --backup=numbered artifacts/*/** dist
rm -f dist/*~
echo "To be uploaded:"
ls dist
echo "Installers:"
ls dist-installer
- 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/*
dist-installer/*.exe
- 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 }}
45 changes: 0 additions & 45 deletions .github/workflows/win-installer.yml

This file was deleted.

11 changes: 6 additions & 5 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
5.3.1
-----
Release 5.3.1
-------------

* Fixed an issue where `iris` would use up all available memory for datasets with a large number of time-delays (>500)

5.3.0
-----
* Releases are now automatically performed using Github Actions

Release 5.3.0
-------------

* Added the :meth:`DiffractionDataset.mask_apply` to modify the diffraction pattern mask.
* The center of diffraction is now calculated and updated as needed automatically.
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. 'v6.0.0')::

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

The package will be automatically tested, released on GitHub and uploaded to PyPI.
3 changes: 2 additions & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Sphinx >= 3
sphinx_rtd_theme >= 0.4
pytest >= 6
black
black
wheel
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 4549aae

Please sign in to comment.