diff --git a/.github/workflows/test-and-release.yml b/.github/workflows/test-and-release.yml new file mode 100644 index 0000000..bd893cb --- /dev/null +++ b/.github/workflows/test-and-release.yml @@ -0,0 +1,97 @@ +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/v') # only build on tag pushes + needs: + - test + + steps: + - 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: Check version + run: | + 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." + exit 1 + fi + + - 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/ + + release: + name: >- + 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 + + 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 + with: + password: ${{ secrets.DF3D_PYPI_API_TOKEN }} + + - name: Make Github release + uses: softprops/action-gh-release@v2 \ 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 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. diff --git a/setup.py b/setup.py index f1dfa4d..c955d84 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setup( name="nely-df3d", - version="1.0.0", + version="1.0.1.dev4", description="GUI and 3D pose estimation pipeline for tethered Drosophila.", author="Semih Gunel", author_email="gunelsemih@gmail.com",