Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: better versioning #31

Merged
merged 3 commits into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions .github/workflows/build_and_release.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: Build and Upload to PyPI

on:
workflow_dispatch:
push:
tags:
- "v*"

jobs:
build-and-upload:
Expand All @@ -13,6 +15,9 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Print tag
run: echo ${{ github.ref_name }}

- name: Set up Python
uses: actions/setup-python@v5
with:
Expand All @@ -32,25 +37,20 @@ jobs:
run: |
pip install pytest
pytest -vvvv

- name: Extract version from pyproject.toml
id: get_version
run: |
echo "VERSION=$(python -c 'import toml; pyproject = toml.load("pyproject.toml"); print(pyproject["project"]["version"])')" >> $GITHUB_ENV

- name: Build package
run: python -m build --wheel

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: dist
version: ${{ env.VERSION }}

- name: Create a Release
uses: elgohr/Github-Release-Action@v5
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
title: Release v${{ env.VERSION }}
tag: v${{ env.VERSION }}
# - name: Publish to PyPI
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# packages-dir: dist
# version: ${{ github.ref_name }}

# - name: Create a Release
# uses: elgohr/Github-Release-Action@v5
# env:
# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# title: Release ${{ github.ref_name }}
# tag: ${{ github.ref_name }}
6 changes: 6 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,28 @@ on:
jobs:
test:
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ['3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e .[dev]

- name: Run lint
run: |
ruff check

- name: Run tests
run: |
pytest
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ dev = [
]

[tool.setuptools_scm]
version_file = "msfabricutils/_version.py"

[tool.ruff]
line-length = 100
Expand Down
8 changes: 6 additions & 2 deletions src/msfabricutils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from importlib.metadata import PackageNotFoundError, version

from msfabricutils.common.fabric_duckdb_connection import FabricDuckDBConnection
from msfabricutils.core import (
get_fabric_bearer_token,
Expand All @@ -18,7 +20,9 @@
"get_workspaces",
)


try:
from ._version import version as __version__ # type: ignore
except ImportError:
__version__ = version("msfabricutils")
except PackageNotFoundError:
# package is not installed
__version__ = "0.0.0"
Loading