From e2319d60a872be8f2bd1941c77e15a1f1fbef275 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Heiko=20Sch=C3=BCtt?= Date: Mon, 12 Sep 2022 17:31:10 -0400 Subject: [PATCH 01/30] Create python-publish.yml This seems to be the basic workflow file for publishing a package to pypi . Starting pull request for discussion. --- .github/workflows/python-publish.yml | 39 ++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/python-publish.yml diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml new file mode 100644 index 00000000..ec703542 --- /dev/null +++ b/.github/workflows/python-publish.yml @@ -0,0 +1,39 @@ +# This workflow will upload a Python Package using Twine when a release is created +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries + +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. + +name: Upload Python Package + +on: + release: + types: [published] + +permissions: + contents: read + +jobs: + deploy: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: '3.x' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install build + - name: Build package + run: python -m build + - name: Publish package + uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} From fc42e2d996ead9bd32b13aa1aa22b0c21de8d720 Mon Sep 17 00:00:00 2001 From: Jasper van den Bosch Date: Sat, 5 Nov 2022 09:13:21 +0100 Subject: [PATCH 02/30] using git derived dirty versions --- pyproject.toml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 52ff084d..59b75013 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [build-system] requires = [ "setuptools~=65.3", - "setuptools-scm", + "setuptools-scm[toml]~=7.0.0", "wheel", "numpy>=1.21.2", "scipy", @@ -13,7 +13,6 @@ build-backend = "setuptools.build_meta" name = "rsatoolbox" description = "Representational Similarity Analysis (RSA) in Python" requires-python = ">=3.7,<3.11" -version = "0.0.5" authors = [ {name="rsatoolbox authors"}, ] @@ -31,7 +30,10 @@ classifiers = [ 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', ] -dynamic = ["readme", "dependencies"] +dynamic = ["readme", "dependencies", "version"] + +[tool.setuptools_scm] +local_scheme = "node-and-timestamp" [tool.setuptools] packages = ["rsatoolbox"] From 32fff21dc1b177d0f2790ac7eeffef89d6e66208 Mon Sep 17 00:00:00 2001 From: Jasper van den Bosch Date: Sat, 5 Nov 2022 09:24:47 +0100 Subject: [PATCH 03/30] github actions get tags --- .github/workflows/pull_request.yml | 2 ++ .github/workflows/python-publish.yml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 46516d3c..ab7306c4 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -10,6 +10,8 @@ jobs: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 - uses: actions/setup-python@v4 with: python-version: '3.10' diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index ec703542..3ba1960e 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -22,6 +22,8 @@ jobs: steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v3 with: From 52bd617b518eaee9f5d03cd96d042bdec9cd3e3c Mon Sep 17 00:00:00 2001 From: Jasper van den Bosch Date: Sat, 5 Nov 2022 09:25:25 +0100 Subject: [PATCH 04/30] setup.py imports setuptools_scm as a skeleton test to avoid deprecated use --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 3bd25133..febfe69d 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,5 @@ from setuptools import setup, Extension +import setuptools_scm # noqa: F401 from Cython.Build import build_ext ## missing dev time req from os.path import isfile From 8f271094ab9db1fb08b2d08cbd0f44ab96148314 Mon Sep 17 00:00:00 2001 From: Jasper van den Bosch Date: Sat, 5 Nov 2022 09:41:37 +0100 Subject: [PATCH 05/30] further consolidated build options in pyproject.toml --- pyproject.toml | 9 ++++++--- setup.py | 14 +++++--------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 59b75013..11116fb6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,7 @@ requires-python = ">=3.7,<3.11" authors = [ {name="rsatoolbox authors"}, ] -keywords = ["neuroscience "] +keywords = ["neuroscience"] license = {file = "LICENSE"} classifiers = [ 'Programming Language :: Python', @@ -32,12 +32,15 @@ classifiers = [ ] dynamic = ["readme", "dependencies", "version"] +[project.urls] +homepage = "https://github.com/rsagroup/rsatoolbox" +documentation = "https://rsatoolbox.readthedocs.io/" + [tool.setuptools_scm] local_scheme = "node-and-timestamp" [tool.setuptools] -packages = ["rsatoolbox"] -package-dir = {"" = "src"} +where = "src" [tool.setuptools.dynamic] readme = {file = "README.md"} diff --git a/setup.py b/setup.py index febfe69d..2d576784 100644 --- a/setup.py +++ b/setup.py @@ -1,18 +1,14 @@ +"""Setup.py now only remains as a build script for the cython extensions. +Using setup.py for other things is now deprecated and may have unexpected results: + setup.py test -> pytest + setup.py develop -> pip install -e +""" from setuptools import setup, Extension import setuptools_scm # noqa: F401 from Cython.Build import build_ext ## missing dev time req -from os.path import isfile -test_requires = [] -if isfile('tests/requirements.txt'): - with open('tests/requirements.txt') as reqfile: - test_requires = reqfile.read().splitlines() setup( - tests_require=test_requires, - test_suite='tests', - url = "https://github.com/rsagroup/rsatoolbox", - zip_safe = False, ext_modules = [ Extension( "rsatoolbox.cengine.similarity", From 8e3bbded064e1a38fda0312a2d7804b8a4e0105c Mon Sep 17 00:00:00 2001 From: Jasper van den Bosch Date: Sat, 5 Nov 2022 09:54:29 +0100 Subject: [PATCH 06/30] fixed syntax of pyproject where directive --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 11116fb6..9490e155 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,8 +39,8 @@ documentation = "https://rsatoolbox.readthedocs.io/" [tool.setuptools_scm] local_scheme = "node-and-timestamp" -[tool.setuptools] -where = "src" +[tool.setuptools.packages.find] +where = ["src"] [tool.setuptools.dynamic] readme = {file = "README.md"} From dd61addf299b270acdd149cfe4fbb7749f93439c Mon Sep 17 00:00:00 2001 From: Jasper van den Bosch Date: Sat, 5 Nov 2022 09:59:45 +0100 Subject: [PATCH 07/30] getting tags on all builds --- .github/workflows/pull_request.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index ab7306c4..26541274 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -37,6 +37,8 @@ jobs: os: [ubuntu-latest, macos-latest, windows-latest] steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} @@ -76,6 +78,8 @@ jobs: os: [ubuntu-latest, macos-latest, windows-latest] steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 - uses: actions/setup-python@v4 with: python-version: '3.10' From a3431f7ecd02dc7584dd044c5ff89b81a223fa76 Mon Sep 17 00:00:00 2001 From: Jasper van den Bosch Date: Sat, 5 Nov 2022 10:08:05 +0100 Subject: [PATCH 08/30] [style] setup.py: marked unused import for pylint as well --- setup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 2d576784..7c49b28a 100644 --- a/setup.py +++ b/setup.py @@ -1,11 +1,11 @@ """Setup.py now only remains as a build script for the cython extensions. -Using setup.py for other things is now deprecated and may have unexpected results: +Using setup.py for other things is now deprecated and may have unexpected results: setup.py test -> pytest setup.py develop -> pip install -e """ from setuptools import setup, Extension -import setuptools_scm # noqa: F401 -from Cython.Build import build_ext ## missing dev time req +import setuptools_scm # noqa # pylint: disable=unused-import +from Cython.Build import build_ext setup( From 3f909db3bacc0f1764a80bbe0eba00b529b413f7 Mon Sep 17 00:00:00 2001 From: Jasper van den Bosch Date: Sat, 5 Nov 2022 10:26:56 +0100 Subject: [PATCH 09/30] small updates to docs on installation --- README.md | 3 ++- docs/source/getting_started.rst | 10 +++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7374e4e9..2b61dd87 100644 --- a/README.md +++ b/README.md @@ -14,12 +14,13 @@ Conceived during the RSA retreat 2019 in Blue Mountains. #### Getting Started -The easiest way to install rsatoolbox is with pip: +To install the latest stable version of rsatoolbox with pip: ```sh pip install rsatoolbox ``` + here is a simple code sample: ```python diff --git a/docs/source/getting_started.rst b/docs/source/getting_started.rst index 9a99cc55..6513d4e9 100644 --- a/docs/source/getting_started.rst +++ b/docs/source/getting_started.rst @@ -3,12 +3,20 @@ Getting started =============== -The easiest way to install rsatoolbox is with pip: +To install the latest release of rsatoolbox: .. code-block:: sh pip install rsatoolbox + +To get the bleeding edge or "pre-release" version: + +.. code-block:: sh + + pip install --pre rsatoolbox + + To use rsatoolbox: .. code-block:: python From c6d7e44e98bc61e0604b2840fb6fa63eb67d4f57 Mon Sep 17 00:00:00 2001 From: Jasper van den Bosch Date: Sat, 5 Nov 2022 10:28:13 +0100 Subject: [PATCH 10/30] [style] shorter docstring line --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 7c49b28a..873737d6 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,5 @@ """Setup.py now only remains as a build script for the cython extensions. -Using setup.py for other things is now deprecated and may have unexpected results: +Using setup.py for other things is now deprecated: setup.py test -> pytest setup.py develop -> pip install -e """ From beaa01b38c4effaa011c337f0161a08b378654a7 Mon Sep 17 00:00:00 2001 From: Jasper van den Bosch Date: Sat, 5 Nov 2022 12:46:23 +0100 Subject: [PATCH 11/30] testing passing artifacts between workflows --- .github/workflows/create_artifacts.yml | 57 +++++++++++++++++++ .github/workflows/publish.yml | 47 +++++++++++++++ .github/workflows/python-publish.yml | 41 ------------- .../{pull_request.yml => test_build.yml} | 10 +++- 4 files changed, 111 insertions(+), 44 deletions(-) create mode 100644 .github/workflows/create_artifacts.yml create mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/python-publish.yml rename .github/workflows/{pull_request.yml => test_build.yml} (95%) diff --git a/.github/workflows/create_artifacts.yml b/.github/workflows/create_artifacts.yml new file mode 100644 index 00000000..c97ad960 --- /dev/null +++ b/.github/workflows/create_artifacts.yml @@ -0,0 +1,57 @@ +name: Create Artifacts + +on: + workflow_call: + +permissions: + contents: read + +jobs: + + group1: + needs: tests + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.7', '3.8', '3.9', '3.10'] + os: [ubuntu-latest, macos-latest, windows-latest] + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Create Files + run: | + mkdir dist + touch dist/test1.txt + touch dist/test2.txt + - name: Store artifact + uses: actions/upload-artifact@v3 + with: + name: group1 + path: dist/* + if-no-files-found: error + retention-days: 1 + + group2: + needs: tests + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.7', '3.8', '3.9', '3.10'] + os: [ubuntu-latest, macos-latest, windows-latest] + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Create Files + run: | + mkdir dist + touch dist/test3.txt + touch dist/test4.txt + - name: Store artifact + uses: actions/upload-artifact@v3 + with: + name: group2 + path: dist/* + if-no-files-found: error + retention-days: 1 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..029a5ca0 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,47 @@ + + +name: Publish + +on: + pull_request: + types: [opened, synchronize, reopened] + # release: + # types: [published] + +permissions: + contents: read + +jobs: + call-test-build: + uses: ./.github/workflows/create_artifacts.yml + + check-artifacts: + steps: + - name: Download all artifacts + uses: actions/download-artifact@v3 + - name: List files + run: ls -R + + # deploy: + + # runs-on: ubuntu-latest + + # steps: + # - uses: actions/checkout@v3 + # with: + # fetch-depth: 0 + # - name: Set up Python + # uses: actions/setup-python@v3 + # with: + # python-version: '3.x' + # - name: Install dependencies + # run: | + # python -m pip install --upgrade pip + # pip install build + # - name: Build package + # run: python -m build + # - name: Publish package + # uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 + # with: + # user: __token__ + # password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml deleted file mode 100644 index 3ba1960e..00000000 --- a/.github/workflows/python-publish.yml +++ /dev/null @@ -1,41 +0,0 @@ -# This workflow will upload a Python Package using Twine when a release is created -# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries - -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -name: Upload Python Package - -on: - release: - types: [published] - -permissions: - contents: read - -jobs: - deploy: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Set up Python - uses: actions/setup-python@v3 - with: - python-version: '3.x' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install build - - name: Build package - run: python -m build - - name: Publish package - uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 - with: - user: __token__ - password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.github/workflows/pull_request.yml b/.github/workflows/test_build.yml similarity index 95% rename from .github/workflows/pull_request.yml rename to .github/workflows/test_build.yml index 26541274..dc7f8531 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/test_build.yml @@ -1,8 +1,12 @@ -name: pull_request_builds +name: Test and Build on: - pull_request: - types: [opened, synchronize, reopened] + # pull_request: + # types: [opened, synchronize, reopened] + workflow_call: + +permissions: + contents: read jobs: From bd7f7354f6ff314ce774ac456031c9d0023430a7 Mon Sep 17 00:00:00 2001 From: Jasper van den Bosch Date: Sat, 5 Nov 2022 12:51:51 +0100 Subject: [PATCH 12/30] fixed syntax of temporary github actions --- .github/workflows/create_artifacts.yml | 10 ---------- .github/workflows/publish.yml | 1 + 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/.github/workflows/create_artifacts.yml b/.github/workflows/create_artifacts.yml index c97ad960..25989ac6 100644 --- a/.github/workflows/create_artifacts.yml +++ b/.github/workflows/create_artifacts.yml @@ -9,12 +9,7 @@ permissions: jobs: group1: - needs: tests runs-on: ubuntu-latest - strategy: - matrix: - python-version: ['3.7', '3.8', '3.9', '3.10'] - os: [ubuntu-latest, macos-latest, windows-latest] steps: - uses: actions/checkout@v3 with: @@ -33,12 +28,7 @@ jobs: retention-days: 1 group2: - needs: tests runs-on: ubuntu-latest - strategy: - matrix: - python-version: ['3.7', '3.8', '3.9', '3.10'] - os: [ubuntu-latest, macos-latest, windows-latest] steps: - uses: actions/checkout@v3 with: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 029a5ca0..dd648a23 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -16,6 +16,7 @@ jobs: uses: ./.github/workflows/create_artifacts.yml check-artifacts: + runs-on: ubuntu-latest steps: - name: Download all artifacts uses: actions/download-artifact@v3 From 65536aebc98ba35e8194a0d6bd3232ced3b05877 Mon Sep 17 00:00:00 2001 From: Jasper van den Bosch Date: Sat, 5 Nov 2022 12:53:50 +0100 Subject: [PATCH 13/30] checking artifacts after creation --- .github/workflows/publish.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index dd648a23..aac2dd11 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -16,6 +16,7 @@ jobs: uses: ./.github/workflows/create_artifacts.yml check-artifacts: + needs: call-test-build runs-on: ubuntu-latest steps: - name: Download all artifacts From 681596f440c91f6cf37b4be35dd93df3b0933a3f Mon Sep 17 00:00:00 2001 From: Jasper van den Bosch Date: Sat, 5 Nov 2022 13:06:51 +0100 Subject: [PATCH 14/30] testing sub folder for artifacts --- .github/workflows/publish.yml | 11 +++++++---- .github/workflows/{test_build.yml => testbuild.yml} | 0 2 files changed, 7 insertions(+), 4 deletions(-) rename .github/workflows/{test_build.yml => testbuild.yml} (100%) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index aac2dd11..425455f1 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -3,17 +3,18 @@ name: Publish on: - pull_request: + pull_request: ## temporary for testing, tb removed types: [opened, synchronize, reopened] - # release: - # types: [published] + push: + branches: + - main permissions: contents: read jobs: call-test-build: - uses: ./.github/workflows/create_artifacts.yml + uses: ./.github/workflows/test_build.yml check-artifacts: needs: call-test-build @@ -21,6 +22,8 @@ jobs: steps: - name: Download all artifacts uses: actions/download-artifact@v3 + with: + path: artifacts - name: List files run: ls -R diff --git a/.github/workflows/test_build.yml b/.github/workflows/testbuild.yml similarity index 100% rename from .github/workflows/test_build.yml rename to .github/workflows/testbuild.yml From f38bb833b9edcd619770894560b3744b90d7c056 Mon Sep 17 00:00:00 2001 From: Jasper van den Bosch Date: Sat, 5 Nov 2022 13:17:50 +0100 Subject: [PATCH 15/30] fixed reference to renamed workflow --- .github/workflows/publish.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 425455f1..b1fac072 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -14,7 +14,7 @@ permissions: jobs: call-test-build: - uses: ./.github/workflows/test_build.yml + uses: ./.github/workflows/testbuild.yml check-artifacts: needs: call-test-build @@ -27,9 +27,6 @@ jobs: - name: List files run: ls -R - # deploy: - - # runs-on: ubuntu-latest # steps: # - uses: actions/checkout@v3 From 46112a44cf864e00318028edaa8446e6bedd5dfa Mon Sep 17 00:00:00 2001 From: Jasper van den Bosch Date: Sat, 5 Nov 2022 13:19:53 +0100 Subject: [PATCH 16/30] reference test workflow --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index b1fac072..f55c62a4 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -14,7 +14,7 @@ permissions: jobs: call-test-build: - uses: ./.github/workflows/testbuild.yml + uses: ./.github/workflows/create_artifacts.yml # testbuild.yml check-artifacts: needs: call-test-build From 15c1e48448836edfcf98b85619ff3810c5a9bc2c Mon Sep 17 00:00:00 2001 From: Jasper van den Bosch Date: Sun, 6 Nov 2022 11:52:55 +0100 Subject: [PATCH 17/30] test.pypi token --- .github/workflows/publish.yml | 38 ++++++++++++++--------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f55c62a4..cde4e12f 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -14,7 +14,7 @@ permissions: jobs: call-test-build: - uses: ./.github/workflows/create_artifacts.yml # testbuild.yml + uses: ./.github/workflows/testbuild.yml check-artifacts: needs: call-test-build @@ -25,25 +25,17 @@ jobs: with: path: artifacts - name: List files - run: ls -R - - - # steps: - # - uses: actions/checkout@v3 - # with: - # fetch-depth: 0 - # - name: Set up Python - # uses: actions/setup-python@v3 - # with: - # python-version: '3.x' - # - name: Install dependencies - # run: | - # python -m pip install --upgrade pip - # pip install build - # - name: Build package - # run: python -m build - # - name: Publish package - # uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 - # with: - # user: __token__ - # password: ${{ secrets.PYPI_API_TOKEN }} + run: ls -R artifacts + - name: Gather artifacts + run: | + mkdir dist + mv artifacts/source/*.tar.gz dist/ + mv artifacts/wheels-macos-latest/*.whl dist/ + mv artifacts/wheels-ubuntu-latest/*.whl dist/ + mv artifacts/wheels-windows-latest/*.whl dist/ + - name: Publish package + uses: pypa/gh-action-pypi-publish@release/v1.5.1 + with: + verbose: true + password: ${{ secrets.API_TOKEN_TEST_PYPI }} + repository_url: https://test.pypi.org/legacy/ From 70eec831b9b8e1a063dffcb6a6560cb39d85b66e Mon Sep 17 00:00:00 2001 From: Jasper van den Bosch Date: Sun, 6 Nov 2022 11:55:28 +0100 Subject: [PATCH 18/30] removed temp workflow --- .github/workflows/create_artifacts.yml | 47 -------------------------- .github/workflows/publish.yml | 2 +- 2 files changed, 1 insertion(+), 48 deletions(-) delete mode 100644 .github/workflows/create_artifacts.yml diff --git a/.github/workflows/create_artifacts.yml b/.github/workflows/create_artifacts.yml deleted file mode 100644 index 25989ac6..00000000 --- a/.github/workflows/create_artifacts.yml +++ /dev/null @@ -1,47 +0,0 @@ -name: Create Artifacts - -on: - workflow_call: - -permissions: - contents: read - -jobs: - - group1: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Create Files - run: | - mkdir dist - touch dist/test1.txt - touch dist/test2.txt - - name: Store artifact - uses: actions/upload-artifact@v3 - with: - name: group1 - path: dist/* - if-no-files-found: error - retention-days: 1 - - group2: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - name: Create Files - run: | - mkdir dist - touch dist/test3.txt - touch dist/test4.txt - - name: Store artifact - uses: actions/upload-artifact@v3 - with: - name: group2 - path: dist/* - if-no-files-found: error - retention-days: 1 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index cde4e12f..efdba266 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -16,7 +16,7 @@ jobs: call-test-build: uses: ./.github/workflows/testbuild.yml - check-artifacts: + publish-artifacts: needs: call-test-build runs-on: ubuntu-latest steps: From 2f4b5571072a3873a02f83fc05986fd8514184c5 Mon Sep 17 00:00:00 2001 From: Jasper van den Bosch Date: Sun, 6 Nov 2022 16:44:18 +0100 Subject: [PATCH 19/30] different way to fix gha version for pypi --- .github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index efdba266..35d0d93f 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -34,7 +34,7 @@ jobs: mv artifacts/wheels-ubuntu-latest/*.whl dist/ mv artifacts/wheels-windows-latest/*.whl dist/ - name: Publish package - uses: pypa/gh-action-pypi-publish@release/v1.5.1 + uses: pypa/gh-action-pypi-publish@v1.5.1 with: verbose: true password: ${{ secrets.API_TOKEN_TEST_PYPI }} From dbb547812a5c0629c3cf2b0e9ce1374c1b5ec3f3 Mon Sep 17 00:00:00 2001 From: Jasper van den Bosch Date: Sun, 6 Nov 2022 17:22:19 +0100 Subject: [PATCH 20/30] publish workflow requires maintainer permission --- .github/workflows/publish.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 35d0d93f..d2085d18 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -17,6 +17,7 @@ jobs: uses: ./.github/workflows/testbuild.yml publish-artifacts: + environment: production ## maybe only apply this to the release jobs needs: call-test-build runs-on: ubuntu-latest steps: From 7bbde344f0031dc14d88eb7be438bb43c086a859 Mon Sep 17 00:00:00 2001 From: Jasper van den Bosch Date: Sun, 6 Nov 2022 17:23:35 +0100 Subject: [PATCH 21/30] disabled local version as pypi does not support it --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 9490e155..d4ea6891 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,7 +37,7 @@ homepage = "https://github.com/rsagroup/rsatoolbox" documentation = "https://rsatoolbox.readthedocs.io/" [tool.setuptools_scm] -local_scheme = "node-and-timestamp" +local_scheme = "no-local-version" [tool.setuptools.packages.find] where = ["src"] From 2e0870a3c23ce8e78c80835a4f64ab5d718c6ac2 Mon Sep 17 00:00:00 2001 From: Jasper van den Bosch Date: Sun, 6 Nov 2022 17:23:53 +0100 Subject: [PATCH 22/30] clarified environment use --- .github/workflows/publish.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index d2085d18..f4dd5f88 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -17,6 +17,7 @@ jobs: uses: ./.github/workflows/testbuild.yml publish-artifacts: + ## requires maintainer permission as otherwise secrets would be accesible to all writers environment: production ## maybe only apply this to the release jobs needs: call-test-build runs-on: ubuntu-latest From df3a559858de582316fb32bd4f515b89ff319e67 Mon Sep 17 00:00:00 2001 From: Jasper van den Bosch Date: Sun, 6 Nov 2022 17:54:10 +0100 Subject: [PATCH 23/30] run twine check after builds --- .github/workflows/publish.yml | 3 +-- .github/workflows/testbuild.yml | 6 ++++-- pyproject.toml | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f4dd5f88..1be45012 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -17,8 +17,7 @@ jobs: uses: ./.github/workflows/testbuild.yml publish-artifacts: - ## requires maintainer permission as otherwise secrets would be accesible to all writers - environment: production ## maybe only apply this to the release jobs + environment: production ## can only run on main branch (only admins can see secrets) needs: call-test-build runs-on: ubuntu-latest steps: diff --git a/.github/workflows/testbuild.yml b/.github/workflows/testbuild.yml index dc7f8531..b81dd6e8 100644 --- a/.github/workflows/testbuild.yml +++ b/.github/workflows/testbuild.yml @@ -54,6 +54,8 @@ jobs: run: pip install build - name: Build package run: python -m build --sdist + - name: Check package compliance + run: twine check dist/* - name: Install rsatoolbox (Linux, Mac) run: pip install dist/* if: matrix.os != 'windows-latest' @@ -95,8 +97,8 @@ jobs: uses: pypa/cibuildwheel@v2.11.1 with: output-dir: dist - - name: Install test dependencies - run: pip install -r tests/requirements.txt + - name: Check package compliance + run: twine check dist/* - name: Store artifact uses: actions/upload-artifact@v3 with: diff --git a/pyproject.toml b/pyproject.toml index d4ea6891..7e72c643 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,8 @@ requires = [ "wheel", "numpy>=1.21.2", "scipy", - "cython~=3.0.0a11" + "cython~=3.0.0a11", + "twine~=4.0.1" ] build-backend = "setuptools.build_meta" From 302090eaa40a7c13e93b55b5e397188f6ae684e0 Mon Sep 17 00:00:00 2001 From: Jasper van den Bosch Date: Sun, 6 Nov 2022 18:10:45 +0100 Subject: [PATCH 24/30] install twine before build compliance check --- .github/workflows/publish.yml | 7 +++++-- .github/workflows/testbuild.yml | 12 ++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 1be45012..b340dcf7 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -3,11 +3,13 @@ name: Publish on: - pull_request: ## temporary for testing, tb removed + pull_request: ## MERGE: remove types: [opened, synchronize, reopened] push: branches: - main + release: + types: [published] permissions: contents: read @@ -17,7 +19,8 @@ jobs: uses: ./.github/workflows/testbuild.yml publish-artifacts: - environment: production ## can only run on main branch (only admins can see secrets) + ## MERGE + # environment: production ## can only run on main branch (only admins can see secrets) needs: call-test-build runs-on: ubuntu-latest steps: diff --git a/.github/workflows/testbuild.yml b/.github/workflows/testbuild.yml index b81dd6e8..65d7cdb4 100644 --- a/.github/workflows/testbuild.yml +++ b/.github/workflows/testbuild.yml @@ -1,7 +1,7 @@ name: Test and Build on: - # pull_request: + # pull_request: ## MERGE # types: [opened, synchronize, reopened] workflow_call: @@ -54,8 +54,6 @@ jobs: run: pip install build - name: Build package run: python -m build --sdist - - name: Check package compliance - run: twine check dist/* - name: Install rsatoolbox (Linux, Mac) run: pip install dist/* if: matrix.os != 'windows-latest' @@ -68,6 +66,10 @@ jobs: run: pip install -r tests/requirements.txt - name: Unit tests run: pytest + - name: Check package compliance + run: | + pip install twine + twine check dist/* - name: Store artifact uses: actions/upload-artifact@v3 with: @@ -98,7 +100,9 @@ jobs: with: output-dir: dist - name: Check package compliance - run: twine check dist/* + run: | + pip install twine + twine check dist/* - name: Store artifact uses: actions/upload-artifact@v3 with: From 67fea388ae2c92a9c88b0402c9df16933ce13e32 Mon Sep 17 00:00:00 2001 From: Jasper van den Bosch Date: Sun, 6 Nov 2022 18:12:18 +0100 Subject: [PATCH 25/30] pip quieter when installing twine --- .github/workflows/testbuild.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/testbuild.yml b/.github/workflows/testbuild.yml index 65d7cdb4..6e455367 100644 --- a/.github/workflows/testbuild.yml +++ b/.github/workflows/testbuild.yml @@ -68,7 +68,7 @@ jobs: run: pytest - name: Check package compliance run: | - pip install twine + pip install -q twine twine check dist/* - name: Store artifact uses: actions/upload-artifact@v3 @@ -101,7 +101,7 @@ jobs: output-dir: dist - name: Check package compliance run: | - pip install twine + pip install -q twine twine check dist/* - name: Store artifact uses: actions/upload-artifact@v3 From 36d29b966111c9bdc050eb9ae80ce3df123b505a Mon Sep 17 00:00:00 2001 From: Jasper van den Bosch Date: Sun, 6 Nov 2022 18:26:04 +0100 Subject: [PATCH 26/30] some hints on deployment process in contribution guide --- CONTRIBUTING.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 142f7dd9..73bb6adf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -8,6 +8,12 @@ Your cycle 5. When you're done with the feature, ask for reviews from two team members or ask the maintainers for help. 6. When the reviewers have approved the Pull Request, they will merge it into the master branch. At this point you want to checkout the master branch again and pull so that you have your latest changes, and can open a new branch for a new feature. +Here is an example shell command to build rsatoolbox, install it in your environment, and run the unit tests on it, in one go: + +```sh +python -m build && sleep 1 && pip install --pre --force-reinstall dist/*.whl && pytest +``` + Rules ===== @@ -22,6 +28,14 @@ Rules or alternatively, ping @ilogue or @HeikoSchuett and we will assign reviewers. +Deployment +========== + + +- when a PR is merged into the branch main, it is build as a pre-release (or "development") package and uploaded to pypi. The latest pre-release version can be installed using `pip install --pre rsatoolbox` +- when a release tag is added to the branch main, the package is instead marked as a released (or "stable") version. + + Naming scheme ============= From dbe0d9c5222a0b73e3fa1e18ab96ae8f54eb9488 Mon Sep 17 00:00:00 2001 From: Jasper van den Bosch Date: Sun, 6 Nov 2022 18:49:20 +0100 Subject: [PATCH 27/30] workflows configured for actual scenarios --- .github/workflows/publish.yml | 8 ++------ .github/workflows/testbuild.yml | 4 ++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index b340dcf7..e163e529 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -3,8 +3,6 @@ name: Publish on: - pull_request: ## MERGE: remove - types: [opened, synchronize, reopened] push: branches: - main @@ -19,8 +17,7 @@ jobs: uses: ./.github/workflows/testbuild.yml publish-artifacts: - ## MERGE - # environment: production ## can only run on main branch (only admins can see secrets) + environment: production needs: call-test-build runs-on: ubuntu-latest steps: @@ -41,5 +38,4 @@ jobs: uses: pypa/gh-action-pypi-publish@v1.5.1 with: verbose: true - password: ${{ secrets.API_TOKEN_TEST_PYPI }} - repository_url: https://test.pypi.org/legacy/ + password: ${{ secrets.API_TOKEN_PYPI }} diff --git a/.github/workflows/testbuild.yml b/.github/workflows/testbuild.yml index 6e455367..232f6dce 100644 --- a/.github/workflows/testbuild.yml +++ b/.github/workflows/testbuild.yml @@ -1,8 +1,8 @@ name: Test and Build on: - # pull_request: ## MERGE - # types: [opened, synchronize, reopened] + pull_request: + types: [opened, synchronize, reopened] workflow_call: permissions: From beb48330132d8ab3dd2c83df8ce97f566966bc70 Mon Sep 17 00:00:00 2001 From: Jasper van den Bosch Date: Sun, 6 Nov 2022 18:56:38 +0100 Subject: [PATCH 28/30] Tell sphinx the package version dynamically --- docs/source/conf.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 0b7fda19..1ae20481 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -14,6 +14,7 @@ # import os import sys +from importlib.metadata import version as identify_version sys.path.insert(0, os.path.abspath('.')) sys.path.insert(0, os.path.abspath('../')) @@ -23,10 +24,11 @@ copyright = '2021, rsatoolbox authors' author = 'rsatoolbox authors' +# The full version +release = identify_version('myproject') + # The short X.Y version -version = '0.0' -# The full version, including alpha/beta/rc tags -release = '0.0.5' +version = '.'.join(release.split('.')[:2]) # -- General configuration --------------------------------------------------- From 3dda8b86469fda7397a71c11608eb488997cdb53 Mon Sep 17 00:00:00 2001 From: Jasper van den Bosch Date: Sun, 6 Nov 2022 19:05:57 +0100 Subject: [PATCH 29/30] docs requirements: importlib backport for python 3.7 --- docs/requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/requirements.txt b/docs/requirements.txt index 2eb5b20d..d5e24cc4 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -2,3 +2,4 @@ sphinx nbsphinx nbsphinx-link ipykernel +importlib_metadata;python_version<'3.8' From c4da9901d21281d627cc04efb75a7fac0ee4428b Mon Sep 17 00:00:00 2001 From: Jasper van den Bosch Date: Sun, 6 Nov 2022 19:15:07 +0100 Subject: [PATCH 30/30] try to get sphinx pkg version with pkg_resources --- docs/requirements.txt | 1 - docs/source/conf.py | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/requirements.txt b/docs/requirements.txt index d5e24cc4..2eb5b20d 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -2,4 +2,3 @@ sphinx nbsphinx nbsphinx-link ipykernel -importlib_metadata;python_version<'3.8' diff --git a/docs/source/conf.py b/docs/source/conf.py index 1ae20481..f171a7c1 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -14,7 +14,7 @@ # import os import sys -from importlib.metadata import version as identify_version +from pkg_resources import get_distribution sys.path.insert(0, os.path.abspath('.')) sys.path.insert(0, os.path.abspath('../')) @@ -25,7 +25,7 @@ author = 'rsatoolbox authors' # The full version -release = identify_version('myproject') +release = get_distribution('rsatoolbox').version # The short X.Y version version = '.'.join(release.split('.')[:2])