From a419cf26beaf057adf97d970b5c78e35d4528fdb Mon Sep 17 00:00:00 2001 From: Dom Date: Fri, 13 Jun 2025 17:33:18 +0200 Subject: [PATCH 01/11] Add github action to build and publish package to pypi when a new tag is pushed --- .github/workflows/test-and-release.yml | 82 ++++++++++++++++++++++++++ .github/workflows/test.yml | 30 ---------- 2 files changed, 82 insertions(+), 30 deletions(-) create mode 100644 .github/workflows/test-and-release.yml delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test-and-release.yml b/.github/workflows/test-and-release.yml new file mode 100644 index 0000000..cdfd9c5 --- /dev/null +++ b/.github/workflows/test-and-release.yml @@ -0,0 +1,82 @@ +name: test + +on: [push] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + fail-fast: false + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install python v${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + cache: pip + + - name: Install dependencies + run: | + python -m pip install -r tests/requirements.txt + sudo apt update && sudo apt install ffmpeg -y + + - name: Run Tests + run: | + python -m unittest discover + +# see https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ + build: + name: Build distribution 📦 + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') # only build on tag pushes + needs: + - test + + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.x" + - name: Install pypa/build + run: >- + python3 -m + pip install + build + --user + - name: Build a binary wheel and a source tarball + run: python3 -m build + - name: Store the distribution packages + uses: actions/upload-artifact@v4 + with: + name: python-package-distributions + path: dist/ + + publish-to-pypi: + name: >- + Publish Python 🐍 distribution 📦 to PyPI + if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes + needs: + - build + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/nely-df3d + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + + steps: + - name: Download all the dists + uses: actions/download-artifact@v4 + with: + name: python-package-distributions + path: dist/ + - name: Publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 5758a00..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: test - -on: [push] - -jobs: - build-linux: - runs-on: ubuntu-latest - strategy: - matrix: - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] - fail-fast: false - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Install python v${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - cache: pip - - - name: Install dependencies - run: | - python -m pip install -r tests/requirements.txt - sudo apt update && sudo apt install ffmpeg -y - - - name: Run Tests - run: | - python -m unittest discover \ No newline at end of file From 6fa550feec0e42b08f3c747f6131b37e44ec0ae6 Mon Sep 17 00:00:00 2001 From: Dom Date: Fri, 13 Jun 2025 17:48:15 +0200 Subject: [PATCH 02/11] Only publish builds for tags that start with v --- .github/workflows/test-and-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-and-release.yml b/.github/workflows/test-and-release.yml index cdfd9c5..ed2aebb 100644 --- a/.github/workflows/test-and-release.yml +++ b/.github/workflows/test-and-release.yml @@ -33,7 +33,7 @@ jobs: build: name: Build distribution 📦 runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/') # only build on tag pushes + if: startsWith(github.ref, 'refs/tags/v') # only build on tag pushes needs: - test @@ -62,7 +62,7 @@ jobs: publish-to-pypi: name: >- Publish Python 🐍 distribution 📦 to PyPI - if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes + if: startsWith(github.ref, 'refs/tags/v') # only publish to PyPI on tag pushes needs: - build runs-on: ubuntu-latest From fe5c93e897adfe89031c8e4d62152501b1617cdf Mon Sep 17 00:00:00 2001 From: Dom Date: Sun, 15 Jun 2025 17:16:25 +0200 Subject: [PATCH 03/11] Automatically create new github release after publishing to pypi --- .github/workflows/test-and-release.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-and-release.yml b/.github/workflows/test-and-release.yml index ed2aebb..0cfecce 100644 --- a/.github/workflows/test-and-release.yml +++ b/.github/workflows/test-and-release.yml @@ -59,10 +59,10 @@ jobs: name: python-package-distributions path: dist/ - publish-to-pypi: + release: name: >- - Publish Python 🐍 distribution 📦 to PyPI - if: startsWith(github.ref, 'refs/tags/v') # only publish to PyPI on tag pushes + Publish Python 🐍 distribution 📦 to PyPI and Github + if: startsWith(github.ref, 'refs/tags/v') # only publish on version tag pushes needs: - build runs-on: ubuntu-latest @@ -79,4 +79,6 @@ jobs: name: python-package-distributions path: dist/ - name: Publish distribution 📦 to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file + uses: pypa/gh-action-pypi-publish@release/v1 + - name: Make Github release + uses: softprops/action-gh-release@v2 \ No newline at end of file From f4b8474646fb81bd6d1036a31d2deab204a95083 Mon Sep 17 00:00:00 2001 From: Dom Date: Fri, 4 Jul 2025 11:39:50 +0200 Subject: [PATCH 04/11] Update release script to use pypi token --- .github/workflows/test-and-release.yml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test-and-release.yml b/.github/workflows/test-and-release.yml index 0cfecce..7945af4 100644 --- a/.github/workflows/test-and-release.yml +++ b/.github/workflows/test-and-release.yml @@ -38,21 +38,26 @@ jobs: - test steps: - - uses: actions/checkout@v4 + - name: Checkout + uses: actions/checkout@v4 with: persist-credentials: false + - name: Set up Python uses: actions/setup-python@v5 with: python-version: "3.x" + - name: Install pypa/build run: >- python3 -m pip install build --user + - name: Build a binary wheel and a source tarball run: python3 -m build + - name: Store the distribution packages uses: actions/upload-artifact@v4 with: @@ -66,11 +71,6 @@ jobs: needs: - build runs-on: ubuntu-latest - environment: - name: pypi - url: https://pypi.org/p/nely-df3d - permissions: - id-token: write # IMPORTANT: mandatory for trusted publishing steps: - name: Download all the dists @@ -78,7 +78,11 @@ jobs: with: name: python-package-distributions path: dist/ + - name: Publish distribution 📦 to PyPI uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{ secrets.DF3D_PYPI_API_TOKEN }} + - name: Make Github release uses: softprops/action-gh-release@v2 \ No newline at end of file From 61ea3a2aa8153e8c3bb46f0095e3b022ce27e17c Mon Sep 17 00:00:00 2001 From: Dom Date: Fri, 4 Jul 2025 14:54:52 +0200 Subject: [PATCH 05/11] Make sure tagged version matches setup.py version --- .github/workflows/test-and-release.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/test-and-release.yml b/.github/workflows/test-and-release.yml index 7945af4..41b6281 100644 --- a/.github/workflows/test-and-release.yml +++ b/.github/workflows/test-and-release.yml @@ -48,6 +48,15 @@ jobs: with: python-version: "3.x" + - name: Check version + run: | + TAG_VERSION = ${{ github.ref_name }} + PACKAGE_VERSION = $(grep -Po 'version\s*=\s*["\x27]\K[^"\x27]+' setup.py) + if [ "$TAG_VERSION" != "$PACKAGE_VERSION" ]; then + echo "Version mismatch! GitHub tag is $TAG_VERSION but package version is $PACKAGE_VERSION." + exit 1 + fi + - name: Install pypa/build run: >- python3 -m From b02284b9a0e9fa754b62342bbe7e10e0267bb74b Mon Sep 17 00:00:00 2001 From: Dom Date: Fri, 4 Jul 2025 15:17:57 +0200 Subject: [PATCH 06/11] Bump version to test auto release --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index f1dfa4d..47cba46 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( name="nely-df3d", - version="1.0.0", + version="1.0.1.dev2", description="GUI and 3D pose estimation pipeline for tethered Drosophila.", author="Semih Gunel", author_email="gunelsemih@gmail.com", From 7ecbc3cf1e4e2a52591bfd7d0b92b7372294b95c Mon Sep 17 00:00:00 2001 From: Dom Date: Fri, 4 Jul 2025 16:15:06 +0200 Subject: [PATCH 07/11] Fix version check --- .github/workflows/test-and-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-and-release.yml b/.github/workflows/test-and-release.yml index 41b6281..961b2e8 100644 --- a/.github/workflows/test-and-release.yml +++ b/.github/workflows/test-and-release.yml @@ -50,8 +50,8 @@ jobs: - name: Check version run: | - TAG_VERSION = ${{ github.ref_name }} - PACKAGE_VERSION = $(grep -Po 'version\s*=\s*["\x27]\K[^"\x27]+' setup.py) + TAG_VERSION=${{ github.ref_name }} + PACKAGE_VERSION=$(grep -Po 'version\s*=\s*["\x27]\K[^"\x27]+' setup.py) if [ "$TAG_VERSION" != "$PACKAGE_VERSION" ]; then echo "Version mismatch! GitHub tag is $TAG_VERSION but package version is $PACKAGE_VERSION." exit 1 From e82145234ab14734ef9cfa6e2865b32503e4c378 Mon Sep 17 00:00:00 2001 From: Dom Date: Fri, 4 Jul 2025 16:15:20 +0200 Subject: [PATCH 08/11] Bump version for testing --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 47cba46..0ebfab3 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( name="nely-df3d", - version="1.0.1.dev2", + version="1.0.1.dev3", description="GUI and 3D pose estimation pipeline for tethered Drosophila.", author="Semih Gunel", author_email="gunelsemih@gmail.com", From 083f2d21153c60fabc9eb726bc9a5c6065c10db5 Mon Sep 17 00:00:00 2001 From: Dom Date: Fri, 4 Jul 2025 16:25:55 +0200 Subject: [PATCH 09/11] Get tag version with leading v --- .github/workflows/test-and-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-and-release.yml b/.github/workflows/test-and-release.yml index 961b2e8..bd893cb 100644 --- a/.github/workflows/test-and-release.yml +++ b/.github/workflows/test-and-release.yml @@ -50,7 +50,7 @@ jobs: - name: Check version run: | - TAG_VERSION=${{ github.ref_name }} + TAG_VERSION=${GITHUB_REF#refs/tags/v} PACKAGE_VERSION=$(grep -Po 'version\s*=\s*["\x27]\K[^"\x27]+' setup.py) if [ "$TAG_VERSION" != "$PACKAGE_VERSION" ]; then echo "Version mismatch! GitHub tag is $TAG_VERSION but package version is $PACKAGE_VERSION." From e896365d811b4b39b5f87a33977d4bb71df7a5b9 Mon Sep 17 00:00:00 2001 From: Dom Date: Fri, 4 Jul 2025 16:26:07 +0200 Subject: [PATCH 10/11] Bump version to test --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 0ebfab3..c955d84 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( name="nely-df3d", - version="1.0.1.dev3", + version="1.0.1.dev4", description="GUI and 3D pose estimation pipeline for tethered Drosophila.", author="Semih Gunel", author_email="gunelsemih@gmail.com", From 2505e6a17169cdf2828b17320f153bd9ba6d631c Mon Sep 17 00:00:00 2001 From: Dom Date: Sat, 5 Jul 2025 00:00:51 +0200 Subject: [PATCH 11/11] Add information about how to make a new release --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 291ab2a..7b98c29 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ We previously published our DeepFly3D work on eLife journal. You can read the pu - [Calibration](#calibration) - [Running GUI](#running-gui) - [Development](#development) +- [Releasing a new version](#releasing-a-new-version) - [References](#references) - [Version History](#version-history) - [Changes in 0.5](#changes-in-05) @@ -465,6 +466,12 @@ DeepFly3D consists of 3 pip packages: The master branch of the DeepFly3D package is kept up-to-date with the last version of the pip package. Development is done under dev branch. Before pushing changes to the master branch, make sure all test cases are passing. You can run the tests using `python -m unittest discover`. Unittests make sure several scenarios can be processed using cli without failing. +# Releasing a new version + +1. Update the version in `setup.py` (eg. 1.0.1) +2. Create a tag for the release that matches the new version (eg. v1.0.1) +3. Push the latest commit and tag - this will trigger a github action to make a new release for DeepFly3D on pypi and github +4. Edit the github release https://github.com/NeLy-EPFL/DeepFly3D/releases to add information about the latest changes # References You can cite our paper in case you find it useful.