diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 7fbbaa709..e3fd2ca50 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -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 @@ -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/action-gh-release@v0.1.14 + 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 diff --git a/README.md b/README.md index f36704294..1b28528f2 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/setup.cfg b/setup.cfg index 7b4d9d774..75bb03d9a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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 = @@ -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}"