|
| 1 | +name: Publish Fixed Version |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + good_version: |
| 7 | + description: 'Version number of the good/fixed version from PyPI (e.g., 0.0.110)' |
| 8 | + required: true |
| 9 | + type: string |
| 10 | + |
| 11 | +jobs: |
| 12 | + publish-prior-stable-version: |
| 13 | + name: Publish Fixed Version |
| 14 | + runs-on: ubuntu-latest |
| 15 | + environment: pypi |
| 16 | + |
| 17 | + permissions: |
| 18 | + contents: write |
| 19 | + id-token: write |
| 20 | + |
| 21 | + steps: |
| 22 | + - name: Checkout |
| 23 | + uses: actions/checkout@v4 |
| 24 | + |
| 25 | + - name: Setup uv |
| 26 | + uses: astral-sh/setup-uv@v5 |
| 27 | + with: |
| 28 | + enable-cache: true |
| 29 | + |
| 30 | + - name: Setup Python |
| 31 | + uses: actions/setup-python@v5 |
| 32 | + with: |
| 33 | + python-version-file: ".python-version" |
| 34 | + |
| 35 | + - name: Get current version and increment |
| 36 | + id: version |
| 37 | + shell: pwsh |
| 38 | + run: | |
| 39 | + $pyprojcontent = Get-Content pyproject.toml -Raw |
| 40 | + $CURRENT_VERSION = ($pyprojcontent | Select-String -Pattern '(?m)^\[project\][^\[]*?version\s*=\s*"([^"]*)"' -AllMatches).Matches[0].Groups[1].Value |
| 41 | +
|
| 42 | + # Parse version and increment patch number |
| 43 | + $versionParts = $CURRENT_VERSION.Split('.') |
| 44 | + $major = [int]$versionParts[0] |
| 45 | + $minor = [int]$versionParts[1] |
| 46 | + $patch = [int]$versionParts[2] + 1 |
| 47 | +
|
| 48 | + $NEW_VERSION = "$major.$minor.$patch" |
| 49 | +
|
| 50 | + Write-Output "current_version=$CURRENT_VERSION" >> $env:GITHUB_OUTPUT |
| 51 | + Write-Output "new_version=$NEW_VERSION" >> $env:GITHUB_OUTPUT |
| 52 | + Write-Output "good_version=${{ github.event.inputs.good_version }}" >> $env:GITHUB_OUTPUT |
| 53 | +
|
| 54 | + Write-Host "Current version: $CURRENT_VERSION" |
| 55 | + Write-Host "New version: $NEW_VERSION" |
| 56 | + Write-Host "Good version: ${{ github.event.inputs.good_version }}" |
| 57 | +
|
| 58 | + - name: Download and extract good version from PyPI |
| 59 | + shell: pwsh |
| 60 | + run: | |
| 61 | + $goodVersion = "${{ github.event.inputs.good_version }}" |
| 62 | + $packageName = "uipath-langchain" |
| 63 | +
|
| 64 | + Write-Host "Downloading $packageName==$goodVersion from PyPI..." |
| 65 | +
|
| 66 | + # Download the source package (tar.gz preferred for easier extraction) |
| 67 | + pip download "$packageName==$goodVersion" --no-deps --no-binary=:all: --dest . |
| 68 | +
|
| 69 | + # Find the downloaded tar.gz file |
| 70 | + $downloadedFile = Get-ChildItem | Where-Object { $_.Name -match "uipath.langchain.*\.tar\.gz$" } | Select-Object -First 1 |
| 71 | +
|
| 72 | + if ($downloadedFile) { |
| 73 | + Write-Host "Found downloaded file: $($downloadedFile.FullName)" |
| 74 | +
|
| 75 | + # Extract the tar.gz file |
| 76 | + tar -xzf $downloadedFile.FullName --strip-components=1 |
| 77 | +
|
| 78 | + Write-Host "Extracted good version content to current directory" |
| 79 | +
|
| 80 | + # Remove the downloaded tar.gz file |
| 81 | + Remove-Item $downloadedFile.FullName |
| 82 | + } else { |
| 83 | + Write-Error "Could not find downloaded package file" |
| 84 | + exit 1 |
| 85 | + } |
| 86 | +
|
| 87 | + - name: Update version to new version in pyproject.toml |
| 88 | + shell: pwsh |
| 89 | + run: | |
| 90 | + (Get-Content pyproject.toml) -replace 'version = "${{ github.event.inputs.good_version }}"', 'version = "${{ steps.version.outputs.new_version }}"' | Set-Content pyproject.toml |
| 91 | + Write-Host "Updated version from ${{ github.event.inputs.good_version }} to ${{ steps.version.outputs.new_version }}" |
| 92 | +
|
| 93 | + - name: Install dependencies |
| 94 | + run: uv sync --all-extras |
| 95 | + |
| 96 | + - name: Build and publish fixed version |
| 97 | + run: | |
| 98 | + echo "Building version ${{ steps.version.outputs.new_version }} (republishing PyPI version ${{ github.event.inputs.good_version }})..." |
| 99 | + uv build |
| 100 | + echo "Publishing fixed version to PyPI..." |
| 101 | + uv publish |
| 102 | + env: |
| 103 | + UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }} |
| 104 | + |
| 105 | + - name: Summary |
| 106 | + run: | |
| 107 | + echo "✅ Successfully published version ${{ steps.version.outputs.new_version }} with content from PyPI version ${{ github.event.inputs.good_version }}" |
0 commit comments