From c820e114ae88a32b99af128b37175d1dbb8936ad Mon Sep 17 00:00:00 2001 From: ionmincu Date: Mon, 28 Apr 2025 15:02:53 +0300 Subject: [PATCH 1/2] add GitVersion --- .github/workflows/build.yml | 26 +++++++++++++++----------- GitVersion.yml | 28 ++++++++++++++++++++++++++++ pyproject.toml | 11 +++++++++-- src/uipath_langchain/_version.py | 3 +++ 4 files changed, 55 insertions(+), 13 deletions(-) create mode 100644 GitVersion.yml create mode 100644 src/uipath_langchain/_version.py diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 660e5ec..1dd53b6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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/setup@v0.10.2 + with: + versionSpec: '5.x' + + - name: Determine Version + id: gitversion + uses: gittools/actions/gitversion/execute@v0.10.2 - uses: astral-sh/setup-uv@v5 @@ -28,18 +39,11 @@ jobs: - name: Build run: | uv build + env: + HATCH_BUILD_HOOK_VCS_VERSION: ${{ steps.gitversion.outputs.semVer }} - - 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' + - name: Publish + if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') run: | uv publish env: diff --git a/GitVersion.yml b/GitVersion.yml new file mode 100644 index 0000000..1799ac0 --- /dev/null +++ b/GitVersion.yml @@ -0,0 +1,28 @@ +mode: Mainline +next-version: 0.0.99 +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: '' + increment: Patch + feature: + regex: ^feature?\/ + tag: 'alpha' + increment: Inherit + hotfix: + regex: ^hotfix?\/ + tag: 'beta' + increment: Patch + release: + regex: ^release?\/ + tag: 'rc' + increment: None +ignore: + sha: [] +merge-message-formats: {} \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 61f6a6f..0352d7a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" @@ -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", @@ -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] diff --git a/src/uipath_langchain/_version.py b/src/uipath_langchain/_version.py new file mode 100644 index 0000000..9d69233 --- /dev/null +++ b/src/uipath_langchain/_version.py @@ -0,0 +1,3 @@ +"""Version information.""" + +__version__ = "0.0.0" # This will be replaced by GitVersion during build From 9fa8a3e02f73556a4db5bc8641637bb88e5004a1 Mon Sep 17 00:00:00 2001 From: ionmincu Date: Mon, 28 Apr 2025 15:05:46 +0300 Subject: [PATCH 2/2] test --- .github/workflows/build.yml | 12 ++--- .github/workflows/cd.yml | 2 +- .github/workflows/promote-to-release.yml | 66 ++++++++++++++++++++++++ GitVersion.yml | 10 +++- 4 files changed, 81 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/promote-to-release.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1dd53b6..9dfd59c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -42,9 +42,9 @@ jobs: env: 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 }} + # - name: Publish + # if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/') + # run: | + # uv publish + # env: + # UV_PUBLISH_TOKEN: ${{ secrets.token }} diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 0a1a5af..e3c6a12 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -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 }} \ No newline at end of file diff --git a/.github/workflows/promote-to-release.yml b/.github/workflows/promote-to-release.yml new file mode 100644 index 0000000..7e5019f --- /dev/null +++ b/.github/workflows/promote-to-release.yml @@ -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/setup@v0.10.2 + with: + versionSpec: '5.x' + + - name: Determine Version + id: gitversion + uses: gittools/actions/gitversion/execute@v0.10.2 + 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 }} \ No newline at end of file diff --git a/GitVersion.yml b/GitVersion.yml index 1799ac0..d71c621 100644 --- a/GitVersion.yml +++ b/GitVersion.yml @@ -1,5 +1,5 @@ mode: Mainline -next-version: 0.0.99 +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)' @@ -9,7 +9,7 @@ commit-message-incrementing: Enabled branches: main: regex: ^main$|^master$ - tag: '' + tag: 'alpha' increment: Patch feature: regex: ^feature?\/ @@ -23,6 +23,12 @@ branches: 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: {} \ No newline at end of file