name: Build Skyvern SDK and publish to PyPI on: workflow_dispatch: push: branches: - main paths: - 'pyproject.toml' jobs: check-version-change: runs-on: ubuntu-latest outputs: version_changed: ${{ steps.check.outputs.version_changed }} steps: - uses: actions/checkout@v4 with: fetch-depth: 2 - name: Check if version changed id: check run: | # Get version from current pyproject.toml CURRENT_VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/') # Get version from previous commit git checkout HEAD^1 PREVIOUS_VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/') if [ "$CURRENT_VERSION" != "$PREVIOUS_VERSION" ]; then echo "Version changed from $PREVIOUS_VERSION to $CURRENT_VERSION" echo "version_changed=true" >> $GITHUB_OUTPUT else echo "Version remained at $CURRENT_VERSION" echo "version_changed=false" >> $GITHUB_OUTPUT fi run-ci: needs: check-version-change if: needs.check-version-change.outputs.version_changed == 'true' uses: ./.github/workflows/ci.yml build-sdk: runs-on: ubuntu-latest needs: [check-version-change, run-ci] if: needs.check-version-change.outputs.version_changed == 'true' steps: - name: Check out Git repository uses: actions/checkout@v4 # If you wanted to use multiple Python versions, you'd have specify a matrix in the job and # reference the matrixe python version here. - name: Setup Python id: setup-python uses: actions/setup-python@v6 with: python-version: "3.11" # Cache the installation of `uv` itself, e.g. the next step. This prevents the workflow # from installing `uv` every time, which can be slow. - name: Install uv run: | curl -LsSf https://astral.sh/uv/install.sh | sh echo "$HOME/.local/bin" >> $GITHUB_PATH # Cache uv's global cache (resolver/downloads) for speed - name: Cache uv cache uses: actions/cache@v4 with: path: ~/.cache/uv key: uv-cache-${{ runner.os }}-${{ hashFiles('**/pyproject.toml', '**/uv.lock') }} # Cache the project venv (keyed by lockfile + Python) - name: Cache venv id: cache-venv uses: actions/cache@v4 with: path: .venv key: venv-${{ runner.os }}-py${{ steps.setup-python.outputs.python-version || '3.11' }}-${{ hashFiles('**/uv.lock') }} # Create/refresh environment. We install dev deps to get twine/build. - name: Sync dependencies if: steps.cache-venv.outputs.cache-hit != 'true' run: | uv sync --group dev - name: Ensure environment is up to date (on cache hit) if: steps.cache-venv.outputs.cache-hit == 'true' run: uv sync --group dev - name: Clean dist directory run: rm -rf dist - name: Build Package run: uv build - name: Publish to PyPI env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} run: uv run twine upload --repository pypi dist/*