diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index a28b45b..f74792b 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -1,18 +1,24 @@ -# This workflow will install Python dependencies and run tests with a variety of Python versions -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python +# This workflow will do Continous Integration (CI) and Continous Deployment (CD). +# It will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: +# https://py-pkgs.org/08-ci-cd +# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python -name: nvector-test +name: ci-cd +# Controls when the workflow will run on: [push, pull_request] +# A workflow run is made up of one or more jobs that can run +# sequentially or in parallel jobs: - test: - + ci: + # Set up operating system runs-on: ${{ matrix.os }} strategy: matrix: - python-version: ["3.9", "3.10", "3.11", "3.12"] - os: [ubuntu-latest, macOS-latest, windows-latest] + python-version: ["3.12"] #, "3.11", "3.10", "3.9"] + os: [ubuntu-latest] #, macOS-latest, windows-latest] fail-fast: false steps: @@ -27,3 +33,105 @@ jobs: - name: Run Tests run: | pdm run pytest + + release1: + concurrency: release1 + permissions: + contents: write + # Only run this job if the "ci" job passes + needs: ci + + # Only run this job if new work is pushed to the "master" branch + if: github.event_name == 'push' && github.ref == 'refs/heads/master' + + # Set up operating system + runs-on: ubuntu-latest + outputs: + tag: ${{ steps.release.outputs.tag }} + released: ${{ steps.release.outputs.released }} + + # Define job steps + steps: + - name: Set up Python 3.12 + uses: actions/setup-python@main + with: + python-version: 3.12 + - name: Check-out repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: master + submodules: recursive + + - name: Use Python Semantic Release to prepare release + id: release + uses: python-semantic-release/python-semantic-release@v9.9.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + + - name: Publish package distributions to GitHub Releases + uses: python-semantic-release/publish-action@main + if: steps.release.outputs.released == 'true' + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + - name: Store the distribution packages + uses: actions/upload-artifact@v4 + if: steps.release.outputs.released == 'true' + with: + name: python-package-distributions + path: dist/ + +# testpypi-publish: +# needs: release1 +# if: needs.release1.outputs.released == 'true' +# runs-on: ubuntu-latest +# permissions: +# # IMPORTANT: this permission is mandatory for trusted publishing +# id-token: write +# # Dedicated environments with protections for publishing are strongly recommended. +# environment: +# name: pypi +# # OPTIONAL: uncomment and update to include your PyPI project URL in the deployment status: +# url: https://test.pypi.org/p/nvector +# +# steps: +# - name: Retrieve release distributions +# uses: actions/download-artifact@v4 +# with: +# name: python-package-distributions +# path: dist/ +# +# - name: Publish release distributions to PyPI +# uses: pypa/gh-action-pypi-publish@release/v1 +# - name: Test install from TestPyPI +# run: | +# pip install \ +# --index-url https://test.pypi.org/simple/ \ +# --extra-index-url https://pypi.org/simple/ \ +# nvector + + pypi-publish: + runs-on: ubuntu-latest + needs: release1 + if: needs.release1.outputs.released == 'true' +# needs: testpypi-publish + + permissions: + # IMPORTANT: this permission is mandatory for trusted publishing + id-token: write + + # Dedicated environments with protections for publishing are strongly recommended. + environment: + name: pypi + # OPTIONAL: uncomment and update to include your PyPI project URL in the deployment status: + url: https://pypi.org/p/nvector + + steps: + - name: Retrieve release distributions + uses: actions/download-artifact@v4 + with: + name: python-package-distributions + path: dist/ + + - name: Publish release distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 7547b57..9826e87 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -7,14 +7,14 @@ Short version ------------- * Submit bug reports and feature requests at - [GitHub](https://github.com/pbrod/nvector/issues) + `GitHub `_ * Make pull requests to the ``develop`` branch. Bug reports ----------- -When [reporting a bug](https://github.com/pbrod/nvector/issues) please +When `reporting a bug `_ please include: * Your operating system name and version @@ -28,7 +28,7 @@ Feature requests and feedback ----------------------------- The best way to send feedback is to file an issue at -[GitHub](https://github.com/pbrod/nvector/issues). +`GitHub. `_ If you are proposing a feature: @@ -50,27 +50,28 @@ The following are optional, but recommended. * The CPython interpreter version 3.12 * You can install it using official binaries, pyenv, or any Anaconda-like distribution -* The [PDM](https://pdm-project.org/latest/) application for locking, building, and testing. -* Dedicated IDE like PyCharm, Spyder, or [VSCodium](https://vscodium.com/) to name a few. These allow more flexible git +* The `PDM `_ application for locking, building, and testing. +* Dedicated IDE like PyCharm, Spyder, or `VSCodium `_ to name a few. These allow more flexible git control. Development Steps ----------------- -1. [Fork nvector on GitHub](https://github.com/pbrod/nvector) +1. `Fork nvector on GitHub `_ 2. Clone your fork locally. Using the command line would be: ```shell git clone git@github.com//nvector.git ``` - + 3. Create a branch for local development. Using the command line would be: ```shell git checkout -b name-of-your-bugfix-or-feature ``` + Now you can make changes and commit them. 4. When you're done making changes, run all the checks to ensure that nothing @@ -95,7 +96,7 @@ Development Steps pdm run nox ``` -5. For linting the source code you can use `ruff `_ +5. For linting the source code you can use `ruff `_: ```shell ruff format ./src @@ -109,11 +110,11 @@ Development Steps ```shell git add ... - git commit -m "TAG: Brief description. Longer description later." + git commit -m "():