From c8c83b806a8ce125b0f2b43c7366677f8d968555 Mon Sep 17 00:00:00 2001 From: jakevc Date: Mon, 12 Feb 2024 17:53:45 -0500 Subject: [PATCH 1/2] ci: release --- .github/workflows/release-please.yaml | 35 ++++++++++++++------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/.github/workflows/release-please.yaml b/.github/workflows/release-please.yaml index 69fa98e..eed406b 100644 --- a/.github/workflows/release-please.yaml +++ b/.github/workflows/release-please.yaml @@ -1,32 +1,20 @@ name: Release +# release on push version tag, e.g. v0.3.2 on: push: - branches: - - main + tags: + - 'v*.*.*' permissions: contents: write - pull-requests: write env: PYTHON_VERSION: 3.11 jobs: - release-please: - runs-on: ubuntu-latest - outputs: - release_created: ${{ steps.release.outputs.release_created }} - steps: - - uses: GoogleCloudPlatform/release-please-action@v4 - id: release - with: - release-type: python - publish: runs-on: ubuntu-latest - needs: release-please - if: ${{ needs.release-please.outputs.release_created }} steps: - uses: actions/checkout@v3 @@ -45,11 +33,24 @@ jobs: python-version: ${{ env.PYTHON_VERSION }} cache: poetry + - name: Check if tag matches the package version + run: | + PKG_VERSION = $(poetry version -s) + TAG = ${GITHUB_REF#refs/tags/} + if [[ "v${PKG_VERSION}" != $TAG ]]; then + echo "Error: Tag ($TAG) does not match the package version (v${PKG_VERSION})." + exit 1 + - name: Install Dependencies using Poetry - run: poetry install + run: poetry build + + - uses: ncipollo/release-action@v1 + with: + generateReleaseNotes: true + artifacts: "dist/*" - name: Publish to PyPi env: PYPI_USERNAME: __token__ PYPI_PASSWORD: ${{ secrets.PYPI_TOKEN }} - run: poetry publish --build --username $PYPI_USERNAME --password $PYPI_PASSWORD \ No newline at end of file + run: poetry publish --username $PYPI_USERNAME --password $PYPI_PASSWORD \ No newline at end of file From ba952dde288030b6534700cd0f354163c55a9e11 Mon Sep 17 00:00:00 2001 From: jakevc Date: Mon, 12 Feb 2024 18:15:14 -0500 Subject: [PATCH 2/2] update versino --- fibermorph/__init__.py | 3 +++ fibermorph/_version.py | 1 - fibermorph/fibermorph.py | 15 +++------------ 3 files changed, 6 insertions(+), 13 deletions(-) delete mode 100644 fibermorph/_version.py diff --git a/fibermorph/__init__.py b/fibermorph/__init__.py index e69de29..0a78ad1 100644 --- a/fibermorph/__init__.py +++ b/fibermorph/__init__.py @@ -0,0 +1,3 @@ + +import importlib.metadata +__version__= importlib.metadata.version('fibermorph') \ No newline at end of file diff --git a/fibermorph/_version.py b/fibermorph/_version.py deleted file mode 100644 index f9aa3e1..0000000 --- a/fibermorph/_version.py +++ /dev/null @@ -1 +0,0 @@ -__version__ = "0.3.2" diff --git a/fibermorph/fibermorph.py b/fibermorph/fibermorph.py index cf7976b..4fbc083 100644 --- a/fibermorph/fibermorph.py +++ b/fibermorph/fibermorph.py @@ -1,4 +1,3 @@ -# %% Import libraries import argparse import datetime import os @@ -11,7 +10,6 @@ from functools import wraps from timeit import default_timer as timer -# import cv2 import numpy as np import pandas as pd import rawpy @@ -32,18 +30,9 @@ from skimage.segmentation import clear_border from skimage.util import invert from tqdm import tqdm -#%% sys.path.append(os.path.dirname(os.path.abspath(__file__))) import demo - -# Grab version from _version.py in the fibermorph directory -dir = os.path.dirname(__file__) -version_py = os.path.join(dir, "_version.py") -exec(open(version_py).read()) - -# %% Functions - -# parse_args() and timing() listed first for easy updating/access +from fibermorph import __version__ def parse_args(): """ @@ -53,6 +42,8 @@ def parse_args(): Parser argument namespace """ parser = argparse.ArgumentParser(description="fibermorph") + + parser.add_argument('--version', action='version', version=f'%(prog)s {__version__}') parser.add_argument( "-o", "--output_directory", metavar="", default=None,