From e4417fa4fd374e754e99d6b67eb181e4f90f671c Mon Sep 17 00:00:00 2001 From: Dmitri Gavrilov Date: Wed, 15 Oct 2025 19:40:44 -0400 Subject: [PATCH 01/10] CI: build wheels --- .github/workflows/publish-pypi.yml | 35 +++++++++++++++++++----------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml index c7ca989..646153f 100644 --- a/.github/workflows/publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -1,10 +1,12 @@ name: Publish to PyPI -on: - release: - types: [created] - branches: - - main +on: [push, pull_request] + +#on: +# release: +# types: [created] +# branches: +# - main jobs: upload: @@ -12,13 +14,20 @@ jobs: environment: release steps: - - name: Download dist artifact - uses: actions/download-artifact@v4 - with: - name: dist - path: dist - - name: Publish to PyPI using trusted publishing - uses: pypa/gh-action-pypi-publish@release/v1 + - name: Checkout + uses: actions/checkout@v4 with: - attestations: false + # Need this to get version number from last tag + fetch-depth: 0 + + - name: Build sdist and wheel + run: > + export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) && + pipx run build + + + #- name: Publish to PyPI using trusted publishing + # uses: pypa/gh-action-pypi-publish@release/v1 + # with: + # attestations: false From 580661a63bbab785650ed1b30b5818c7ab517f83 Mon Sep 17 00:00:00 2001 From: Dmitri Gavrilov Date: Wed, 15 Oct 2025 19:44:57 -0400 Subject: [PATCH 02/10] CI: test the wheels --- .github/workflows/publish-pypi.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml index 646153f..0926768 100644 --- a/.github/workflows/publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -26,6 +26,18 @@ jobs: export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) && pipx run build + - name: Check for packaging errors + run: pipx run twine check --strict dist/* + + - name: Install produced wheel + uses: ./.github/actions/install_requirements + with: + pip-install: dist/*.whl + + - name: Test module is importable using the installed wheel + # If more than one module in src/ replace with module name to test + run: python -c "import $(ls --hide='*.egg-info' src | head -1)" + #- name: Publish to PyPI using trusted publishing # uses: pypa/gh-action-pypi-publish@release/v1 From f0344ad9cb9d4b7fd9256d46dc8d4bcb0eb190e9 Mon Sep 17 00:00:00 2001 From: Dmitri Gavrilov Date: Wed, 15 Oct 2025 19:50:55 -0400 Subject: [PATCH 03/10] CI: add install requirements --- .../actions/install_requirements/actions.yml | 34 +++++++++++++++++++ .github/workflows/publish-pypi.yml | 3 ++ 2 files changed, 37 insertions(+) create mode 100644 .github/actions/install_requirements/actions.yml diff --git a/.github/actions/install_requirements/actions.yml b/.github/actions/install_requirements/actions.yml new file mode 100644 index 0000000..d33e080 --- /dev/null +++ b/.github/actions/install_requirements/actions.yml @@ -0,0 +1,34 @@ +name: Install requirements +description: Install a version of python then call pip install and report what was installed +inputs: + python-version: + description: Python version to install, default is from Dockerfile + default: "dev" + pip-install: + description: Parameters to pass to pip install + default: "$([ -f dev-requirements.txt ] && echo '-c dev-requirements.txt') -e .[dev]" + +runs: + using: composite + steps: + - name: Get version of python + run: | + PYTHON_VERSION="${{ inputs.python-version }}" + if [ $PYTHON_VERSION == "dev" ]; then + PYTHON_VERSION=$(sed -n "s/ARG PYTHON_VERSION=//p" Dockerfile) + fi + echo "PYTHON_VERSION=$PYTHON_VERSION" >> "$GITHUB_ENV" + shell: bash + + - name: Setup python + uses: actions/setup-python@v5 + with: + python-version: ${{ env.PYTHON_VERSION }} + + - name: Install packages + run: pip install ${{ inputs.pip-install }} + shell: bash + + - name: Report what was installed + run: pip freeze + shell: bash diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml index 0926768..10459ef 100644 --- a/.github/workflows/publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -12,6 +12,9 @@ jobs: upload: runs-on: ubuntu-latest environment: release + strategy: + matrix: + python-version: ["3.12"] steps: From 5a3d315a082b0f71a3e745c0ac705952fcdedf67 Mon Sep 17 00:00:00 2001 From: Dmitri Gavrilov Date: Wed, 15 Oct 2025 19:52:36 -0400 Subject: [PATCH 04/10] CI: fixed file name --- .github/actions/install_requirements/{actions.yml => action.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/actions/install_requirements/{actions.yml => action.yml} (100%) diff --git a/.github/actions/install_requirements/actions.yml b/.github/actions/install_requirements/action.yml similarity index 100% rename from .github/actions/install_requirements/actions.yml rename to .github/actions/install_requirements/action.yml From e119d618ea8c73c906e2088c823a35d3ac24e8bc Mon Sep 17 00:00:00 2001 From: Dmitri Gavrilov Date: Wed, 15 Oct 2025 21:32:44 -0400 Subject: [PATCH 05/10] CI: try different way to install and test the package --- .github/workflows/publish-pypi.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml index 10459ef..93967be 100644 --- a/.github/workflows/publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -33,13 +33,11 @@ jobs: run: pipx run twine check --strict dist/* - name: Install produced wheel - uses: ./.github/actions/install_requirements - with: - pip-install: dist/*.whl + run: pip install dist/*.whl - name: Test module is importable using the installed wheel # If more than one module in src/ replace with module name to test - run: python -c "import $(ls --hide='*.egg-info' src | head -1)" + run: python -c "import save_and_restore_api" #- name: Publish to PyPI using trusted publishing From c65e578bac9af9e0d18b9305283b190dda2fd68b Mon Sep 17 00:00:00 2001 From: Dmitri Gavrilov Date: Wed, 15 Oct 2025 21:36:02 -0400 Subject: [PATCH 06/10] CI: more testing for the wheels --- .github/workflows/publish-pypi.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml index 93967be..e9eb7c6 100644 --- a/.github/workflows/publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -35,10 +35,18 @@ jobs: - name: Install produced wheel run: pip install dist/*.whl - - name: Test module is importable using the installed wheel - # If more than one module in src/ replace with module name to test + - name: Test module is importable using the installed wheel - 1 run: python -c "import save_and_restore_api" + - name: Test module is importable using the installed wheel - 2 + run: python -c "from save_and_restore_api import SaveRestoreAPI" + + - name: Test module is importable using the installed wheel - 3 + run: python -c "from save_and_restore_api.aio import SaveRestoreAPI" + + - name: Test module is importable using the installed wheel - 4 + run: save-and-restore-api -h + #- name: Publish to PyPI using trusted publishing # uses: pypa/gh-action-pypi-publish@release/v1 From 33fdb6103400ce2953cd0599ab46002a2b8c2cea Mon Sep 17 00:00:00 2001 From: Dmitri Gavrilov Date: Wed, 15 Oct 2025 21:37:39 -0400 Subject: [PATCH 07/10] CI: fixed the name of the CLI tool --- .github/workflows/publish-pypi.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml index e9eb7c6..6a4693a 100644 --- a/.github/workflows/publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -44,8 +44,8 @@ jobs: - name: Test module is importable using the installed wheel - 3 run: python -c "from save_and_restore_api.aio import SaveRestoreAPI" - - name: Test module is importable using the installed wheel - 4 - run: save-and-restore-api -h + - name: Test if save-and-restore tools can be started + run: save-and-restore -h #- name: Publish to PyPI using trusted publishing From 51ac2c2be2971ec12285b5ab99698aa9daa44610 Mon Sep 17 00:00:00 2001 From: Dmitri Gavrilov Date: Wed, 15 Oct 2025 21:42:56 -0400 Subject: [PATCH 08/10] CI: separate actions for publishing and testing the wheels --- .../actions/install_requirements/action.yml | 34 -------------- .github/workflows/publish-pypi-test.yml | 47 +++++++++++++++++++ .github/workflows/publish-pypi.yml | 38 ++++++--------- 3 files changed, 61 insertions(+), 58 deletions(-) delete mode 100644 .github/actions/install_requirements/action.yml create mode 100644 .github/workflows/publish-pypi-test.yml diff --git a/.github/actions/install_requirements/action.yml b/.github/actions/install_requirements/action.yml deleted file mode 100644 index d33e080..0000000 --- a/.github/actions/install_requirements/action.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: Install requirements -description: Install a version of python then call pip install and report what was installed -inputs: - python-version: - description: Python version to install, default is from Dockerfile - default: "dev" - pip-install: - description: Parameters to pass to pip install - default: "$([ -f dev-requirements.txt ] && echo '-c dev-requirements.txt') -e .[dev]" - -runs: - using: composite - steps: - - name: Get version of python - run: | - PYTHON_VERSION="${{ inputs.python-version }}" - if [ $PYTHON_VERSION == "dev" ]; then - PYTHON_VERSION=$(sed -n "s/ARG PYTHON_VERSION=//p" Dockerfile) - fi - echo "PYTHON_VERSION=$PYTHON_VERSION" >> "$GITHUB_ENV" - shell: bash - - - name: Setup python - uses: actions/setup-python@v5 - with: - python-version: ${{ env.PYTHON_VERSION }} - - - name: Install packages - run: pip install ${{ inputs.pip-install }} - shell: bash - - - name: Report what was installed - run: pip freeze - shell: bash diff --git a/.github/workflows/publish-pypi-test.yml b/.github/workflows/publish-pypi-test.yml new file mode 100644 index 0000000..a0deb53 --- /dev/null +++ b/.github/workflows/publish-pypi-test.yml @@ -0,0 +1,47 @@ +name: Publish to PyPI + +on: [push, pull_request] + +jobs: + upload: + runs-on: ubuntu-latest + environment: release + strategy: + matrix: + python-version: ["3.12"] + + steps: + + - name: Checkout + uses: actions/checkout@v4 + with: + # Need this to get version number from last tag + fetch-depth: 0 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v6 + with: + python-version: ${{ matrix.python-version }} + + - name: Build sdist and wheel + run: > + export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) && + pipx run build + + - name: Check for packaging errors + run: pipx run twine check --strict dist/* + + - name: Install produced wheel + run: pip install dist/*.whl + + - name: Test module is importable using the installed wheel - 1 + run: python -c "import save_and_restore_api" + + - name: Test module is importable using the installed wheel - 2 + run: python -c "from save_and_restore_api import SaveRestoreAPI" + + - name: Test module is importable using the installed wheel - 3 + run: python -c "from save_and_restore_api.aio import SaveRestoreAPI" + + - name: Test if save-and-restore tools can be started + run: save-and-restore -h diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml index 6a4693a..cddb80a 100644 --- a/.github/workflows/publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -1,12 +1,10 @@ name: Publish to PyPI -on: [push, pull_request] - -#on: -# release: -# types: [created] -# branches: -# - main +on: + release: + types: [created] + branches: + - main jobs: upload: @@ -24,6 +22,11 @@ jobs: # Need this to get version number from last tag fetch-depth: 0 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v6 + with: + python-version: ${{ matrix.python-version }} + - name: Build sdist and wheel run: > export SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) && @@ -35,20 +38,7 @@ jobs: - name: Install produced wheel run: pip install dist/*.whl - - name: Test module is importable using the installed wheel - 1 - run: python -c "import save_and_restore_api" - - - name: Test module is importable using the installed wheel - 2 - run: python -c "from save_and_restore_api import SaveRestoreAPI" - - - name: Test module is importable using the installed wheel - 3 - run: python -c "from save_and_restore_api.aio import SaveRestoreAPI" - - - name: Test if save-and-restore tools can be started - run: save-and-restore -h - - - #- name: Publish to PyPI using trusted publishing - # uses: pypa/gh-action-pypi-publish@release/v1 - # with: - # attestations: false + - name: Publish to PyPI using trusted publishing + uses: pypa/gh-action-pypi-publish@release/v1 + with: + attestations: false From 168b3232204c38ca8a9897910098f5193aa17bbb Mon Sep 17 00:00:00 2001 From: Dmitri Gavrilov Date: Wed, 15 Oct 2025 21:48:47 -0400 Subject: [PATCH 09/10] CI: renamed the wheel testing workflow --- .github/workflows/publish-pypi-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-pypi-test.yml b/.github/workflows/publish-pypi-test.yml index a0deb53..2e9d359 100644 --- a/.github/workflows/publish-pypi-test.yml +++ b/.github/workflows/publish-pypi-test.yml @@ -1,4 +1,4 @@ -name: Publish to PyPI +name: Publish to PyPI - Test Wheels on: [push, pull_request] From 7bd75391f30724f0c4e08e5d8fb2ac352ed54fec Mon Sep 17 00:00:00 2001 From: Dmitri Gavrilov Date: Wed, 15 Oct 2025 21:59:50 -0400 Subject: [PATCH 10/10] CI: renamed the jobs --- .github/workflows/publish-pypi-test.yml | 2 +- .github/workflows/publish-pypi.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-pypi-test.yml b/.github/workflows/publish-pypi-test.yml index 2e9d359..0c81326 100644 --- a/.github/workflows/publish-pypi-test.yml +++ b/.github/workflows/publish-pypi-test.yml @@ -3,7 +3,7 @@ name: Publish to PyPI - Test Wheels on: [push, pull_request] jobs: - upload: + build_and_test_wheels: runs-on: ubuntu-latest environment: release strategy: diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml index cddb80a..271e969 100644 --- a/.github/workflows/publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -7,7 +7,7 @@ on: - main jobs: - upload: + build_and_upload_to_pypi: runs-on: ubuntu-latest environment: release strategy: