Skip to content

feat: api trigger hitl #18

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

Merged
merged 2 commits into from
May 22, 2025
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
254 changes: 127 additions & 127 deletions .github/workflows/publish-dev.yml
Original file line number Diff line number Diff line change
@@ -1,127 +1,127 @@
name: Publish Dev Build
on:
pull_request:
types: [opened, synchronize, reopened, labeled]
jobs:
publish-dev:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
# Only run if PR has the build:dev label
# if: contains(github.event.pull_request.labels.*.name, 'build:dev')
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version-file: ".python-version"
- name: Install dependencies
run: uv sync --all-extras
- name: Set development version
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
$pyprojcontent = Get-Content pyproject.toml -Raw
$PROJECT_NAME = ($pyprojcontent | Select-String -Pattern '(?m)^\[(project|tool\.poetry)\][^\[]*?name\s*=\s*"([^"]*)"' -AllMatches).Matches[0].Groups[2].Value
$CURRENT_VERSION = ($pyprojcontent | Select-String -Pattern '(?m)^\[(project|tool\.poetry)\][^\[]*?version\s*=\s*"([^"]*)"' -AllMatches).Matches[0].Groups[2].Value
# Get PR number and run number with proper padding
$PR_NUM = [int]"${{ github.event.pull_request.number }}"
$PADDED_PR = "{0:D5}" -f [int]"${{ github.event.pull_request.number }}"
$PADDED_RUN = "{0:D4}" -f [int]"${{ github.run_number }}"
$PADDED_NEXT_PR = "{0:D5}" -f ($PR_NUM + 1)
# Create version range strings for PR
$MIN_VERSION = "$CURRENT_VERSION.dev1$PADDED_PR" + "0000"
$MAX_VERSION = "$CURRENT_VERSION.dev1$PADDED_NEXT_PR" + "0000"
# Create unique dev version with PR number and run ID
$DEV_VERSION = "$CURRENT_VERSION.dev1$PADDED_PR$PADDED_RUN"
# Update version in pyproject.toml
(Get-Content pyproject.toml) -replace "version = `"$CURRENT_VERSION`"", "version = `"$DEV_VERSION`"" | Set-Content pyproject.toml
Write-Output "Package version set to $DEV_VERSION"
$dependencyMessage = @"
## Development Package
- Add this package as a dependency in your pyproject.toml:
``````toml
[project]
dependencies = [
# Exact version:
"$PROJECT_NAME==$DEV_VERSION",
# Any version from PR
"$PROJECT_NAME>=$MIN_VERSION,<$MAX_VERSION"
]
[[tool.uv.index]]
name = "testpypi"
url = "https://test.pypi.org/simple/"
publish-url = "https://test.pypi.org/legacy/"
explicit = true
[tool.uv.sources]
$PROJECT_NAME = { index = "testpypi" }
``````
"@
# Get the owner and repo from the GitHub repository
$owner = "${{ github.repository_owner }}"
$repo = "${{ github.repository }}".Split('/')[1]
$prNumber = $PR_NUM
# Get the current PR description
$prUri = "https://api.github.com/repos/$owner/$repo/pulls/$prNumber"
$headers = @{
Authorization = "token $env:GITHUB_TOKEN"
Accept = "application/vnd.github.v3+json"
}
$pr = Invoke-RestMethod -Uri $prUri -Method Get -Headers $headers
$currentBody = $pr.body
# Check if there's already a development package section
if ($currentBody -match '## Development Package') {
# Replace the existing section with the new dependency message
$newBody = $currentBody -replace '## Development Package(\r?\n|.)*?(?=##|$)', $dependencyMessage
} else {
# Append the dependency message to the end of the description
$newBody = if ($currentBody) { "$currentBody`n`n$dependencyMessage" } else { $dependencyMessage }
}
# Update the PR description
$updateBody = @{
body = $newBody
} | ConvertTo-Json
Invoke-RestMethod -Uri $prUri -Method Patch -Headers $headers -Body $updateBody -ContentType "application/json"
Write-Output "Updated PR description with development package information"
- name: Build package
run: uv build
- name: Publish
run: uv publish --index testpypi
env:
UV_PUBLISH_TOKEN: ${{ secrets.TEST_PYPI_TOKEN }}
name: Publish Dev Build

on:
pull_request:
types: [opened, synchronize, reopened, labeled]

jobs:
publish-dev:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write

# Only run if PR has the build:dev label
if: contains(github.event.pull_request.labels.*.name, 'build:dev')

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true

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

- name: Install dependencies
run: uv sync --all-extras

- name: Set development version
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
$pyprojcontent = Get-Content pyproject.toml -Raw

$PROJECT_NAME = ($pyprojcontent | Select-String -Pattern '(?m)^\[(project|tool\.poetry)\][^\[]*?name\s*=\s*"([^"]*)"' -AllMatches).Matches[0].Groups[2].Value
$CURRENT_VERSION = ($pyprojcontent | Select-String -Pattern '(?m)^\[(project|tool\.poetry)\][^\[]*?version\s*=\s*"([^"]*)"' -AllMatches).Matches[0].Groups[2].Value

# Get PR number and run number with proper padding
$PR_NUM = [int]"${{ github.event.pull_request.number }}"
$PADDED_PR = "{0:D5}" -f [int]"${{ github.event.pull_request.number }}"
$PADDED_RUN = "{0:D4}" -f [int]"${{ github.run_number }}"
$PADDED_NEXT_PR = "{0:D5}" -f ($PR_NUM + 1)

# Create version range strings for PR
$MIN_VERSION = "$CURRENT_VERSION.dev1$PADDED_PR" + "0000"
$MAX_VERSION = "$CURRENT_VERSION.dev1$PADDED_NEXT_PR" + "0000"

# Create unique dev version with PR number and run ID
$DEV_VERSION = "$CURRENT_VERSION.dev1$PADDED_PR$PADDED_RUN"

# Update version in pyproject.toml
(Get-Content pyproject.toml) -replace "version = `"$CURRENT_VERSION`"", "version = `"$DEV_VERSION`"" | Set-Content pyproject.toml

Write-Output "Package version set to $DEV_VERSION"

$dependencyMessage = @"
## Development Package

- Add this package as a dependency in your pyproject.toml:

``````toml
[project]
dependencies = [
# Exact version:
"$PROJECT_NAME==$DEV_VERSION",

# Any version from PR
"$PROJECT_NAME>=$MIN_VERSION,<$MAX_VERSION"
]

[[tool.uv.index]]
name = "testpypi"
url = "https://test.pypi.org/simple/"
publish-url = "https://test.pypi.org/legacy/"
explicit = true

[tool.uv.sources]
$PROJECT_NAME = { index = "testpypi" }
``````
"@

# Get the owner and repo from the GitHub repository
$owner = "${{ github.repository_owner }}"
$repo = "${{ github.repository }}".Split('/')[1]
$prNumber = $PR_NUM

# Get the current PR description
$prUri = "https://api.github.com/repos/$owner/$repo/pulls/$prNumber"
$headers = @{
Authorization = "token $env:GITHUB_TOKEN"
Accept = "application/vnd.github.v3+json"
}

$pr = Invoke-RestMethod -Uri $prUri -Method Get -Headers $headers
$currentBody = $pr.body

# Check if there's already a development package section
if ($currentBody -match '## Development Package') {
# Replace the existing section with the new dependency message
$newBody = $currentBody -replace '## Development Package(\r?\n|.)*?(?=##|$)', $dependencyMessage
} else {
# Append the dependency message to the end of the description
$newBody = if ($currentBody) { "$currentBody`n`n$dependencyMessage" } else { $dependencyMessage }
}

# Update the PR description
$updateBody = @{
body = $newBody
} | ConvertTo-Json

Invoke-RestMethod -Uri $prUri -Method Patch -Headers $headers -Body $updateBody -ContentType "application/json"

Write-Output "Updated PR description with development package information"

- name: Build package
run: uv build

- name: Publish
run: uv publish --index testpypi
env:
UV_PUBLISH_TOKEN: ${{ secrets.TEST_PYPI_TOKEN }}
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "uipath-llamaindex"
version = "0.0.12"
version = "0.0.13"
description = "UiPath LlamaIndex SDK"
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.10"
Expand Down
Loading