Skip to content

Commit bed3b2b

Browse files
authored
Merge pull request #216 from UiPath/fix/security_github_actions
feat(actions): harden security on github actions
2 parents 5579ef3 + 775d80c commit bed3b2b

File tree

1 file changed

+29
-31
lines changed

1 file changed

+29
-31
lines changed

.github/workflows/publish-dev.yml

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ on:
77
PYPI_TOKEN_NIGHTLY:
88
required: true
99

10-
1110
jobs:
1211
publish-dev:
1312
runs-on: ubuntu-latest
@@ -34,44 +33,43 @@ jobs:
3433

3534
- name: Modify pyproject.toml for custom UiPath version
3635
if: contains(github.event.pull_request.labels.*.name, 'test-core-dev-version')
37-
shell: bash
36+
shell: pwsh
37+
env:
38+
PR_TITLE: ${{ github.event.pull_request.title }}
3839
run: |
39-
# Backup original pyproject.toml
40-
cp pyproject.toml pyproject.toml.backup
41-
42-
# Extract custom version from PR title
43-
PR_TITLE="${{ github.event.pull_request.title }}"
44-
VERSION=$(echo "$PR_TITLE" | grep -oE '[0-9]+\.[0-9]+\.[0-9]+\.dev[0-9]+' | head -1)
45-
46-
if [ -z "$VERSION" ]; then
47-
echo "No version found in PR title. Please include version like: 2.0.65.dev1004030443"
40+
# Extract version from PR title (e.g., "2.0.65.dev1004030443")
41+
if ($env:PR_TITLE -match '(\d+\.\d+\.\d+\.dev\d+)') {
42+
$VERSION = $matches[1]
43+
} else {
44+
Write-Error "No version found in PR title. Example: 'chore: test (uipath version 2.0.65.dev1004030443)'"
4845
exit 1
49-
fi
46+
}
5047
51-
echo "Extracted version: $VERSION"
48+
Write-Output "Using UiPath version: $VERSION"
5249
53-
# Update the uipath dependency to the custom version (match both == and >= patterns)
54-
# Target only the dependency lines in dependencies arrays, not project name
55-
sed -i '/dependencies = \[/,/\]/ s|"uipath[=><^~!]*[^"]*"|"uipath=='$VERSION'"|' pyproject.toml
56-
sed -i '/\[project\.optional-dependencies\]/,/^\[/ s|"uipath[=><^~!]*[^"]*"|"uipath=='$VERSION'"|' pyproject.toml
50+
# Update uipath dependency to exact version (only in dependency arrays, not project name)
51+
$content = Get-Content pyproject.toml -Raw
5752
53+
# Replace in main dependencies array
54+
$content = $content -replace '(?s)(dependencies\s*=\s*\[.*?\])', {
55+
param($match)
56+
$match.Value -replace '"uipath([>=<\s,][^"]*|)"', "`"uipath==$VERSION`""
57+
}
5858
59+
# Replace in optional-dependencies section (from [project.optional-dependencies] to next [)
60+
$content = $content -replace '(?s)(\[project\.optional-dependencies\].*?)(?=\n\[|\z)', {
61+
param($match)
62+
$match.Value -replace '"uipath([>=<\s,][^"]*|)"', "`"uipath==$VERSION`""
63+
}
5964
60-
# Add or update [tool.uv.sources] section if it doesn't exist
61-
if ! grep -q "\[tool\.uv\.sources\]" pyproject.toml; then
62-
echo "" >> pyproject.toml
63-
echo "[tool.uv.sources]" >> pyproject.toml
64-
echo 'uipath = { index = "testpypi" }' >> pyproject.toml
65-
else
66-
# Update existing sources if needed
67-
if ! grep -q 'uipath = { index = "testpypi" }' pyproject.toml; then
68-
sed -i '/\[tool\.uv\.sources\]/a uipath = { index = "testpypi" }' pyproject.toml
69-
fi
70-
fi
65+
# Add [tool.uv.sources] if missing
66+
if ($content -notmatch '\[tool\.uv\.sources\]') {
67+
$content += "`n`n[tool.uv.sources]`n uipath = { index = `"testpypi`" }`n"
68+
}
7169
72-
echo "Modified pyproject.toml to use UiPath version $VERSION from testpypi"
73-
echo "=== Modified pyproject.toml content ==="
74-
grep -A5 -B5 "uipath\|testpypi" pyproject.toml || true
70+
# Save changes
71+
$content | Set-Content pyproject.toml -NoNewline
72+
Write-Output "✓ Updated pyproject.toml"
7573
7674
- name: Install dependencies
7775
run: uv sync --all-extras

0 commit comments

Comments
 (0)