Skip to content

Commit

Permalink
Misc/automate release (#275)
Browse files Browse the repository at this point in the history
* Automate version bump with bumpver.

* Automate release with GA.
  • Loading branch information
csadorf authored Jan 17, 2022
1 parent b9708b3 commit a2c9016
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 28 deletions.
74 changes: 48 additions & 26 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,18 @@ on:

jobs:

build-and-publish-test:

name: Build and publish on TestPyPI
if: startsWith(github.ref, 'refs/heads/release/')
build:

runs-on: ubuntu-latest
environment:
name: Test PyPI
url: https://test.pypi.org/project/aiidalab-widgets-base/

steps:

- uses: actions/checkout@v2

- name: Set up Python 3.8
- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: '3.10'

- name: Install pypa/build
run: python -m pip install build
Expand All @@ -41,44 +36,71 @@ jobs:
--sdist
--wheel
--outdir dist/
.
- name: Upload distribution artifact
uses: actions/upload-artifact@v2
with:
name: release
path: dist/


publish-test:

name: Build and publish on TestPyPI
if: >
startsWith(github.ref, 'refs/heads/release/') ||
startsWith(github.ref, 'refs/tags/')
needs: [build]
runs-on: ubuntu-latest

environment:
name: Test PyPI
url: https://test.pypi.org/project/aiidalab-widgets-base/

steps:
- uses: actions/download-artifact@v2
name: Download distribution artifact
with:
name: release
path: dist/

- name: Publish distribution on Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
if: startsWith(github.ref, 'refs/heads/release/')
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true

build-and-publish:
publish:

name: Build and publish on PyPI
if: startsWith(github.ref, 'refs/tags')

needs: [build]
runs-on: ubuntu-latest

environment:
name: PyPI
url: https://pypi.org/project/aiidalab-widgets-base/

steps:
- uses: actions/checkout@v2

- name: Set up Python 3.8
uses: actions/setup-python@v2
- uses: actions/download-artifact@v2
name: Download distribution artifact
with:
python-version: 3.8

- name: Install pypa/build
run: python -m pip install build
name: release
path: dist/

- name: Build a binary wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
.
- uses: softprops/[email protected]
name: Create release
if: startsWith(github.ref, 'refs/tags/v')
with:
files: |
dist/*
generate_release_notes: true

- name: Publish distribution on PyPI
uses: pypa/gh-action-pypi-publish@release/v1
Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@ The AiiDAlab widgets help with these common tasks.

Hosted on [aiidalab-widgets-base.readthedocs.io](https://aiidalab-widgets-base.readthedocs.io).

## For maintainers

To create a new release, clone the repository, install development dependencies with `pip install -e '.[dev]'`, and then execute `bumpver update [--major|--minor|--patch] [--tag [alpha|beta|rc]]`.
This will:

1. Create a tagged release with bumped version and push it to the repository.
2. Trigger a GitHub actions workflow that creates a GitHub release and publishes it on PyPI.

Additional notes:

- Use the `--dry` option to preview the release change.
- The release tag (e.g. a/b/rc) is determined from the last release.
Use the `--tag` option to switch the release tag.
- This packages follows semantic versioning.

## License

MIT
Expand Down
17 changes: 15 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,15 @@ include_package_data = True
zip_safe = False

[options.extras_require]
dev =
bumpver==2021.1114
pre-commit==2.10.1
docs =
myst-nb
pydata-sphinx-theme
sphinx
sphinxcontrib-contentui
sphinxcontrib-details-directive
pre_commit =
pre-commit==2.10.1

[flake8]
ignore =
Expand All @@ -62,3 +63,15 @@ ignore =
aiidalab_widgets_base/__init__.py E402 # module level import not at top of file
exclude =
docs/

[bumpver]
current_version = "v1.1.1"
version_pattern = "vMAJOR.MINOR.PATCH[PYTAGNUM]"
commit_message = "Bump version {old_version} -> {new_version}"
commit = True
tag = True
push = True

[bumpver:file_patterns]
aiidalab_widgets_base/__init__.py =
__version__ = "{pep440_version}"

0 comments on commit a2c9016

Please sign in to comment.