diff --git a/.flake8 b/.flake8 new file mode 100644 index 00000000..4cb5ba43 --- /dev/null +++ b/.flake8 @@ -0,0 +1,21 @@ +[flake8] +exclude = + .eggs, + .git, + build, + docs, + tests/mini-esgf-data +max-line-length = 88 +max-complexity = 12 +ignore = + C901 + E203 + E231 + E266 + E402 + E501 + F401 + F403 + F405 + W503 + W504 diff --git a/.github/disabled/tag-testpypi-staging.yml b/.github/disabled/tag-testpypi-staging.yml new file mode 100644 index 00000000..a7663224 --- /dev/null +++ b/.github/disabled/tag-testpypi-staging.yml @@ -0,0 +1,32 @@ +name: Publish Python 🐍 distributions 📦 to TestPyPI + +on: + push: + tags: + - 'v*.*' # Push events to matching v*, i.e. v1.0, v20.15.10 + +jobs: + deploy-testpypi: + name: Build and publish Python 🐍 distributions 📦 to TestPyPI + runs-on: ubuntu-latest + environment: staging + permissions: + # IMPORTANT: this permission is mandatory for trusted publishing + id-token: write + steps: + - uses: actions/checkout@v4 + - name: Set up Python3 + uses: actions/setup-python@v4 + with: + python-version: "3.9" + - name: Install packaging libraries + run: | + python -m pip install flit + - name: Build a binary wheel and a source tarball + run: | + python -m flit build + - name: Publish distribution 📦 to Test PyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ + skip-existing: true diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml new file mode 100644 index 00000000..28f60923 --- /dev/null +++ b/.github/workflows/prepare-release.yml @@ -0,0 +1,25 @@ +name: Prepare Release + +on: + push: + tags: + - 'v*.*' # Push events to matching v*, i.e. v1.0, v20.15.10 + +jobs: + release: + name: Create Release from tag + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/v') && endsWith(github.ref, '.0') + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Create Release + uses: softprops/action-gh-release@v1 + env: + # This token is provided by Actions, you do not need to create your own token + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + name: Release ${{ github.ref }} + draft: true + prerelease: false diff --git a/.github/workflows/publish-pypi-production.yml b/.github/workflows/publish-pypi-production.yml new file mode 100644 index 00000000..04e42d9d --- /dev/null +++ b/.github/workflows/publish-pypi-production.yml @@ -0,0 +1,29 @@ +name: Publish Python 🐍 distributions 📦 to PyPI + +on: + release: + types: + - published + +jobs: + build-n-publish-pypi: + name: Build and publish Python 🐍 distributions 📦 to PyPI + runs-on: ubuntu-latest + environment: production + permissions: + # IMPORTANT: this permission is mandatory for trusted publishing + id-token: write + steps: + - uses: actions/checkout@v4 + - name: Set up Python3 + uses: actions/setup-python@v4 + with: + python-version: "3.9" + - name: Install packaging libraries + run: | + python -m pip install flit + - name: Build a binary wheel and a source tarball + run: | + python -m flit build + - name: Publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a61584c8..b612fe60 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,13 +11,15 @@ repos: rev: v4.5.0 hooks: - id: trailing-whitespace - exclude: setup.cfg - id: end-of-file-fixer - exclude: setup.cfg - id: check-toml - id: check-yaml - id: debug-statements - id: mixed-line-ending + - repo: https://github.com/pappasam/toml-sort + rev: v0.23.1 + hooks: + - id: toml-sort-fix - repo: https://github.com/psf/black-pre-commit-mirror rev: 23.11.0 hooks: @@ -26,7 +28,7 @@ repos: rev: 6.1.0 hooks: - id: flake8 - args: [ '--config=setup.cfg' ] + args: [ '--config=.flake8' ] - repo: https://github.com/PyCQA/isort rev: 5.12.0 hooks: @@ -41,6 +43,11 @@ repos: hooks: - id: nbstripout files: ".ipynb" + - repo: https://github.com/keewis/blackdoc + rev: v0.3.9 + hooks: + - id: blackdoc + additional_dependencies: [ 'black==23.11.0' ] - repo: https://github.com/python-jsonschema/check-jsonschema rev: 0.27.1 hooks: diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 737d023b..62810853 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -145,6 +145,7 @@ Logging .. code-block:: python from loguru import logger + logger.warning("This a warning message!") The mechanism for enabling log reporting in scripts/notebooks using ``loguru`` is as follows: @@ -226,10 +227,13 @@ To run a subset of tests: Versioning ---------- +A reminder for the maintainers on how to bump the version. + In order to update and release the library to PyPI, it's good to use a semantic versioning scheme. + The method we use is as follows:: - major.minor.patch-release + major.minor.patch **Major** releases denote major changes resulting in a stable API; @@ -237,25 +241,25 @@ The method we use is as follows:: **Patch** should be used for bug fixes and optimizations; -**Release** is a keyword used to specify the degree of production readiness (`beta` [, and optionally, `gamma`]) +Packaging/Deploying +------------------- - An increment to the Major or Minor will reset the Release to `beta`. When a build is promoted above `beta` (ie: release-ready), it's a good idea to push this version towards PyPi. +A reminder for the maintainers on how to deploy. This section is only relevant for maintainers when they are producing a new point release for the package. -Deploying ---------- +#. Create a new branch from `master` (e.g. `prepare-release-v1.2.3`). +#. Update the `HISTORY.rst` file to change the `unreleased` section to the current date. +#. Create a pull request from your branch to `master`. +#. Once the pull request is merged, create a new release on GitHub. On the main branch, run: -A reminder for the maintainers on how to deploy. -Make sure all your changes are committed (**including an entry in HISTORY.rst**). -Then run: + .. code-block:: shell -.. code-block:: shell + $ bump-my-version bump minor # In most cases, we will be releasing a minor version + $ git push + $ git push --tags - $ bumpversion