Skip to content

[WIP] Add gitversion #50

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
34 changes: 19 additions & 15 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for GitVersion to accurately determine version

- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '5.x'

- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/[email protected]

- uses: astral-sh/setup-uv@v5

Expand All @@ -28,19 +39,12 @@ jobs:
- name: Build
run: |
uv build

- name: Check if version in pyproject.toml was modified
id: check_version
run: |
if git diff --name-only ${{ github.sha }} ${{ github.event.before }} | grep -q 'pyproject.toml'; then
echo "modified=true" >> $GITHUB_OUTPUT
else
echo "modified=false" >> $GITHUB_OUTPUT
fi

- name: "Publish"
if: ${{ steps.check_version.outputs.modified }} == 'true'
run: |
uv publish
env:
UV_PUBLISH_TOKEN: ${{ secrets.token }}
HATCH_BUILD_HOOK_VCS_VERSION: ${{ steps.gitversion.outputs.semVer }}

# - name: Publish
# if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')
# run: |
# uv publish
# env:
# UV_PUBLISH_TOKEN: ${{ secrets.token }}
2 changes: 1 addition & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
build:
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push' && github.event.workflow_run.head_branch == 'main' }}
# if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push' && github.event.workflow_run.head_branch == 'main' }}
uses: ./.github/workflows/build.yml
secrets:
token: ${{ secrets.PYPI_TOKEN }}
66 changes: 66 additions & 0 deletions .github/workflows/promote-to-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Promote Alpha to Release

on:
workflow_dispatch:
inputs:
version:
description: 'Version to promote (without alpha suffix, e.g., 0.0.98)'
required: true
type: string

jobs:
promote:
name: Promote alpha to release
runs-on: "ubuntu-24.04"

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- name: Set Git User
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"

- name: Create and Push Tag
run: |
VERSION="${{ github.event.inputs.version }}"
echo "Creating release tag v$VERSION"
git tag -a "v$VERSION" -m "Release v$VERSION"
git push origin "v$VERSION"

- name: Install GitVersion
uses: gittools/actions/gitversion/[email protected]
with:
versionSpec: '5.x'

- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/[email protected]
with:
useConfigFile: true

- uses: astral-sh/setup-uv@v5

- uses: actions/setup-python@v5
with:
python-version-file: ".python-version"

- name: Setup venv
run: |
uv venv
uv sync --all-extras

- name: Build
run: |
uv build
env:
HATCH_BUILD_HOOK_VCS_VERSION: ${{ github.event.inputs.version }}

# - name: Publish
# run: |
# uv publish
# env:
# UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}
34 changes: 34 additions & 0 deletions GitVersion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
mode: Mainline
next-version: 0.0.98
major-version-bump-message: '\+semver:\s?(breaking|major)'
minor-version-bump-message: '\+semver:\s?(feature|minor)'
patch-version-bump-message: '\+semver:\s?(fix|patch)'
no-bump-message: '\+semver:\s?(none|skip)'
tag-prefix: 'v'
commit-message-incrementing: Enabled
branches:
main:
regex: ^main$|^master$
tag: 'alpha'
increment: Patch
feature:
regex: ^feature?\/
tag: 'alpha'
increment: Inherit
hotfix:
regex: ^hotfix?\/
tag: 'beta'
increment: Patch
release:
regex: ^release?\/
tag: 'rc'
increment: None
release-tag:
regex: ^v[0-9]+\.[0-9]+\.[0-9]+$
tag: ''
source-branches: ['main']
is-release-branch: true
increment: None
ignore:
sha: []
merge-message-formats: {}
11 changes: 9 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "uipath-langchain"
version = "0.0.98"
version = "0.0.98" # This will be overridden by GitVersion
description = "UiPath Langchain"
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.10"
Expand Down Expand Up @@ -40,9 +40,15 @@ Homepage = "https://uipath.com"
Repository = "https://github.com/UiPath/uipath-langchain-python"

[build-system]
requires = ["hatchling"]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"

[tool.hatch.version]
source = "vcs"

[tool.hatch.build.hooks.vcs]
version-file = "src/uipath_langchain/_version.py"

[dependency-groups]
dev = [
"mypy>=1.14.1",
Expand All @@ -52,6 +58,7 @@ dev = [
"pytest-mock>=3.11.1",
"pre-commit>=4.1.0",
"numpy>=1.24.0",
"hatch-vcs>=0.3.0",
]

[project.optional-dependencies]
Expand Down
3 changes: 3 additions & 0 deletions src/uipath_langchain/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""Version information."""

__version__ = "0.0.0" # This will be replaced by GitVersion during build
Loading