@@ -32,21 +32,18 @@ jobs:
3232
3333 - name : Extract version from PR
3434 id : extract-version
35- shell : bash
35+ shell : pwsh
36+ env :
37+ PR_TITLE : ${{ github.event.pull_request.title }}
3638 run : |
37- # Extract version from PR title only
38- PR_TITLE="${{ github.event.pull_request.title }}"
39-
40- # Search for version pattern in title (any x.y.z.dev version)
41- VERSION=$(echo "$PR_TITLE" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+\.dev[0-9]+' | head -1)
42-
43- if [ -z "$VERSION" ]; then
44- echo "No version found in PR title. Please include version in title like: 2.0.65.dev1004030443"
39+ $match = [regex]::Match($env:PR_TITLE, '[0-9]+\.[0-9]+\.[0-9]+\.dev[0-9]+')
40+ if (-not $match.Success) {
41+ Write-Output "No version found in PR title. Please include version in title like: 2.0.65.dev1004030443"
4542 exit 1
46- fi
47-
48- echo "Extracted version: $VERSION "
49- echo "version=$VERSION" >> $ GITHUB_OUTPUT
43+ }
44+ $version = $match.Value
45+ Write-Output "Extracted version: $version "
46+ "version=$version" | Add-Content -Path $env: GITHUB_OUTPUT
5047
5148 - name : Setup uv
5249 uses : astral-sh/setup-uv@v5
@@ -59,31 +56,26 @@ jobs:
5956 python-version : ${{ matrix.python-version }}
6057
6158 - name : Modify pyproject.toml for custom UiPath version
62- shell : bash
59+ shell : pwsh
60+ env :
61+ UIPATH_VERSION : ${{ steps.extract-version.outputs.version }}
6362 run : |
64- # Backup original pyproject.toml
65- cp pyproject.toml pyproject.toml.backup
66-
67- # Update the uipath dependency to the custom version
68- sed -i 's|"uipath>=.*"|"uipath==${{ steps.extract-version.outputs.version }}"|' pyproject.toml
63+ Copy-Item pyproject.toml pyproject.toml.backup
6964
65+ $content = Get-Content pyproject.toml -Raw
66+ $content = $content -replace '"uipath>=[^"]*"', "`"uipath==$env:UIPATH_VERSION`""
7067
68+ if ($content -notmatch '\[tool\.uv\.sources\]') {
69+ $content = $content.TrimEnd() + "`n`n[tool.uv.sources]`nuipath = { index = `"testpypi`" }`n"
70+ } elseif ($content -notmatch 'uipath\s*=\s*\{\s*index\s*=\s*"testpypi"\s*\}') {
71+ $content = $content -replace '(\[tool\.uv\.sources\])', "`$1`nuipath = { index = `"testpypi`" }"
72+ }
7173
72- # Add or update [tool.uv.sources] section if it doesn't exist
73- if ! grep -q "\[tool\.uv\.sources\]" pyproject.toml; then
74- echo "" >> pyproject.toml
75- echo "[tool.uv.sources]" >> pyproject.toml
76- echo 'uipath = { index = "testpypi" }' >> pyproject.toml
77- else
78- # Update existing sources if needed
79- if ! grep -q 'uipath = { index = "testpypi" }' pyproject.toml; then
80- sed -i '/\[tool\.uv\.sources\]/a uipath = { index = "testpypi" }' pyproject.toml
81- fi
82- fi
74+ Set-Content -Path pyproject.toml -Value $content -NoNewline
8375
84- echo "Modified pyproject.toml to use UiPath version ${{ steps.extract-version.outputs.version }} from testpypi"
85- echo "=== Modified pyproject.toml content ==="
86- grep -A5 -B5 "uipath\|testpypi" pyproject.toml || true
76+ Write-Output "Modified pyproject.toml to use UiPath version $env:UIPATH_VERSION from testpypi"
77+ Write-Output "=== Modified pyproject.toml content ==="
78+ Get-Content pyproject.toml
8779
8880 - name : Install dependencies with specific UiPath version
8981 run : uv sync --all-extras
9789
9890 - name : Restore original pyproject.toml
9991 if : always()
100- shell : bash
101- run : |
102- mv pyproject.toml.backup pyproject.toml
92+ shell : pwsh
93+ run : Move-Item -Force pyproject.toml.backup pyproject.toml
0 commit comments