|
| 1 | +name: Release Bundles |
| 2 | + |
| 3 | +# Manually-triggered workflow for publishing stable `lfx-<name>` bundle wheels |
| 4 | +# from src/bundles/* to PyPI. Bundles change infrequently, so we release them |
| 5 | +# on demand rather than on a schedule. Re-running the workflow without a |
| 6 | +# version bump is a no-op (PyPI rejects the duplicate upload and we tolerate |
| 7 | +# the conflict). |
| 8 | + |
| 9 | +on: |
| 10 | + workflow_dispatch: |
| 11 | + inputs: |
| 12 | + release_tag: |
| 13 | + description: "Git ref to build from (branch, tag, or SHA). Defaults to the workflow's checked-out ref." |
| 14 | + required: false |
| 15 | + type: string |
| 16 | + default: "" |
| 17 | + dry_run: |
| 18 | + description: "Build and test only; skip the PyPI publish step." |
| 19 | + required: false |
| 20 | + type: boolean |
| 21 | + default: false |
| 22 | + |
| 23 | +env: |
| 24 | + PYTHON_VERSION: "3.13" |
| 25 | + |
| 26 | +jobs: |
| 27 | + build-bundles: |
| 28 | + name: Build Langflow Bundles |
| 29 | + runs-on: ubuntu-latest |
| 30 | + defaults: |
| 31 | + run: |
| 32 | + shell: bash |
| 33 | + outputs: |
| 34 | + bundles-found: ${{ steps.build.outputs.bundles-found }} |
| 35 | + steps: |
| 36 | + - name: Checkout code |
| 37 | + uses: actions/checkout@v6 |
| 38 | + with: |
| 39 | + ref: ${{ inputs.release_tag || github.ref }} |
| 40 | + - name: Setup Environment |
| 41 | + uses: astral-sh/setup-uv@v6 |
| 42 | + with: |
| 43 | + enable-cache: true |
| 44 | + cache-dependency-glob: "uv.lock" |
| 45 | + python-version: ${{ env.PYTHON_VERSION }} |
| 46 | + prune-cache: false |
| 47 | + - name: Install the project |
| 48 | + run: uv sync |
| 49 | + - name: Build bundle wheels |
| 50 | + id: build |
| 51 | + run: | |
| 52 | + shopt -s nullglob |
| 53 | + bundles=(src/bundles/*/pyproject.toml) |
| 54 | + if [ ${#bundles[@]} -eq 0 ]; then |
| 55 | + echo "No bundles found under src/bundles/*/" |
| 56 | + echo "bundles-found=0" >> $GITHUB_OUTPUT |
| 57 | + exit 0 |
| 58 | + fi |
| 59 | + mkdir -p bundles-dist |
| 60 | + BUNDLES_DIST="$PWD/bundles-dist" |
| 61 | + for bundle_pyproject in "${bundles[@]}"; do |
| 62 | + bundle_dir=$(dirname "$bundle_pyproject") |
| 63 | + echo "Building wheel for $bundle_dir" |
| 64 | + (cd "$bundle_dir" && uv build --wheel --out-dir "$BUNDLES_DIST") |
| 65 | + done |
| 66 | + echo "bundles-found=1" >> $GITHUB_OUTPUT |
| 67 | + ls -la bundles-dist/ |
| 68 | + # Bundles pin lfx (e.g. lfx>=0.5.0,<0.6.0). The smoke test below |
| 69 | + # installs the bundles in a fresh venv, so it needs an lfx wheel that |
| 70 | + # satisfies the pin available locally — PyPI may not yet have a |
| 71 | + # matching lfx published when bundles are released ahead of a main |
| 72 | + # release. We build the lfx wheel from the current ref so the smoke |
| 73 | + # test resolves against it; this artifact is not published. |
| 74 | + - name: Build lfx wheel for smoke test |
| 75 | + if: steps.build.outputs.bundles-found == '1' |
| 76 | + run: | |
| 77 | + mkdir -p lfx-dist |
| 78 | + LFX_DIST="$PWD/lfx-dist" |
| 79 | + (cd src/lfx && uv build --wheel --out-dir "$LFX_DIST") |
| 80 | + ls -la lfx-dist/ |
| 81 | + - name: Upload bundles artifact |
| 82 | + if: steps.build.outputs.bundles-found == '1' |
| 83 | + uses: actions/upload-artifact@v6 |
| 84 | + with: |
| 85 | + name: dist-bundles |
| 86 | + path: bundles-dist |
| 87 | + - name: Upload lfx artifact (smoke-test only; not published) |
| 88 | + if: steps.build.outputs.bundles-found == '1' |
| 89 | + uses: actions/upload-artifact@v6 |
| 90 | + with: |
| 91 | + name: dist-lfx-smoketest |
| 92 | + path: lfx-dist |
| 93 | + |
| 94 | + test-install: |
| 95 | + name: Install Smoke Test - ${{ matrix.os }} ${{ matrix.python-version }} |
| 96 | + needs: [build-bundles] |
| 97 | + if: needs.build-bundles.outputs.bundles-found == '1' |
| 98 | + runs-on: ${{ matrix.runner }} |
| 99 | + strategy: |
| 100 | + fail-fast: false |
| 101 | + matrix: |
| 102 | + include: |
| 103 | + - os: linux |
| 104 | + runner: ubuntu-latest |
| 105 | + python-version: "3.10" |
| 106 | + - os: linux |
| 107 | + runner: ubuntu-latest |
| 108 | + python-version: "3.12" |
| 109 | + - os: macos |
| 110 | + runner: macos-latest |
| 111 | + python-version: "3.12" |
| 112 | + - os: windows |
| 113 | + runner: windows-latest |
| 114 | + python-version: "3.12" |
| 115 | + steps: |
| 116 | + - name: Setup Python |
| 117 | + uses: actions/setup-python@v6 |
| 118 | + with: |
| 119 | + python-version: ${{ matrix.python-version }} |
| 120 | + - name: Setup UV |
| 121 | + uses: astral-sh/setup-uv@v6 |
| 122 | + with: |
| 123 | + enable-cache: false |
| 124 | + ignore-empty-workdir: true |
| 125 | + - name: Download bundles artifact |
| 126 | + uses: actions/download-artifact@v7 |
| 127 | + with: |
| 128 | + name: dist-bundles |
| 129 | + path: ./bundles-dist |
| 130 | + - name: Download lfx artifact |
| 131 | + uses: actions/download-artifact@v7 |
| 132 | + with: |
| 133 | + name: dist-lfx-smoketest |
| 134 | + path: ./lfx-dist |
| 135 | + - name: Create fresh virtual environment |
| 136 | + run: uv venv test-env --seed |
| 137 | + shell: bash |
| 138 | + - name: Install lfx + bundle wheels (Unix) |
| 139 | + if: matrix.os != 'windows' |
| 140 | + run: | |
| 141 | + shopt -s nullglob |
| 142 | + BUNDLE_WHEELS=(./bundles-dist/*.whl) |
| 143 | + LFX_WHEELS=(./lfx-dist/*.whl) |
| 144 | + if [ ${#BUNDLE_WHEELS[@]} -eq 0 ]; then |
| 145 | + echo "No bundle wheels found in ./bundles-dist/" |
| 146 | + exit 1 |
| 147 | + fi |
| 148 | + if [ ${#LFX_WHEELS[@]} -eq 0 ]; then |
| 149 | + echo "No lfx wheel found in ./lfx-dist/" |
| 150 | + exit 1 |
| 151 | + fi |
| 152 | + printf 'Installing: %s\n' "${LFX_WHEELS[@]}" "${BUNDLE_WHEELS[@]}" |
| 153 | + uv pip install --prerelease=allow --python ./test-env/bin/python "${LFX_WHEELS[@]}" "${BUNDLE_WHEELS[@]}" |
| 154 | + shell: bash |
| 155 | + - name: Install lfx + bundle wheels (Windows) |
| 156 | + if: matrix.os == 'windows' |
| 157 | + run: | |
| 158 | + shopt -s nullglob |
| 159 | + BUNDLE_WHEELS=(./bundles-dist/*.whl) |
| 160 | + LFX_WHEELS=(./lfx-dist/*.whl) |
| 161 | + if [ ${#BUNDLE_WHEELS[@]} -eq 0 ]; then |
| 162 | + echo "No bundle wheels found in ./bundles-dist/" |
| 163 | + exit 1 |
| 164 | + fi |
| 165 | + if [ ${#LFX_WHEELS[@]} -eq 0 ]; then |
| 166 | + echo "No lfx wheel found in ./lfx-dist/" |
| 167 | + exit 1 |
| 168 | + fi |
| 169 | + printf 'Installing: %s\n' "${LFX_WHEELS[@]}" "${BUNDLE_WHEELS[@]}" |
| 170 | + uv pip install --prerelease=allow --python ./test-env/Scripts/python.exe "${LFX_WHEELS[@]}" "${BUNDLE_WHEELS[@]}" |
| 171 | + shell: bash |
| 172 | + |
| 173 | + publish-bundles: |
| 174 | + name: Publish Bundles to PyPI |
| 175 | + needs: [build-bundles, test-install] |
| 176 | + if: | |
| 177 | + always() && |
| 178 | + !cancelled() && |
| 179 | + !inputs.dry_run && |
| 180 | + needs.build-bundles.result == 'success' && |
| 181 | + needs.build-bundles.outputs.bundles-found == '1' && |
| 182 | + needs.test-install.result == 'success' |
| 183 | + runs-on: ubuntu-latest |
| 184 | + steps: |
| 185 | + - name: Download bundles artifact |
| 186 | + uses: actions/download-artifact@v7 |
| 187 | + with: |
| 188 | + name: dist-bundles |
| 189 | + path: bundles-dist |
| 190 | + - name: Setup Environment |
| 191 | + uses: astral-sh/setup-uv@v6 |
| 192 | + with: |
| 193 | + enable-cache: false |
| 194 | + python-version: ${{ env.PYTHON_VERSION }} |
| 195 | + - name: Publish bundles to PyPI |
| 196 | + env: |
| 197 | + UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }} |
| 198 | + run: | |
| 199 | + shopt -s nullglob |
| 200 | + wheels=(bundles-dist/*.whl) |
| 201 | + if [ ${#wheels[@]} -eq 0 ]; then |
| 202 | + echo "No bundle wheels to publish." |
| 203 | + exit 0 |
| 204 | + fi |
| 205 | + failed=0 |
| 206 | + for wheel in "${wheels[@]}"; do |
| 207 | + echo "Publishing $wheel" |
| 208 | + # Capture stderr so we can tolerate "already exists" without failing |
| 209 | + # the whole run — re-running this workflow without bumping a bundle |
| 210 | + # version should be a no-op for that bundle. |
| 211 | + if ! err=$(uv publish "$wheel" 2>&1); then |
| 212 | + echo "$err" |
| 213 | + if echo "$err" | grep -qiE 'already exists|file already exists|HTTP 400|duplicate'; then |
| 214 | + echo "Skipping $wheel: already published." |
| 215 | + else |
| 216 | + echo "Publish failed for $wheel" |
| 217 | + failed=1 |
| 218 | + fi |
| 219 | + fi |
| 220 | + done |
| 221 | + if [ "$failed" = "1" ]; then |
| 222 | + exit 1 |
| 223 | + fi |
0 commit comments