๐Ÿ“ฆ langgenius / dify-python-sdk

๐Ÿ“„ build.yml ยท 94 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94name: Build and Publish

on:
  push:
    tags:
      - 'v*'
  release:
    types: [published]

jobs:
  build:
    name: Build Package
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v4

    - name: Set up Python
      uses: actions/setup-python@v4
      with:
        python-version: "3.11"

    - name: Install uv
      uses: astral-sh/setup-uv@v3
      with:
        enable-cache: true
        cache-dependency-glob: "pyproject.toml"

    - name: Install build dependencies
      run: |
        uv sync --dev

    - name: Build package
      run: |
        uv run build

    - name: Check package
      run: |
        uv run twine check dist/*

    - name: Upload build artifacts
      uses: actions/upload-artifact@v4
      with:
        name: dist
        path: dist/

  test-install:
    name: Test Package Installation
    runs-on: ubuntu-latest
    needs: build
    strategy:
      matrix:
        python-version: ["3.10", "3.11", "3.12", "3.14"]

    steps:
    - uses: actions/checkout@v4

    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v4
      with:
        python-version: ${{ matrix.python-version }}

    - name: Download build artifacts
      uses: actions/download-artifact@v4
      with:
        name: dist
        path: dist/

    - name: Install package
      run: |
        python -m pip install --upgrade pip
        pip install dist/*.whl

    - name: Test import
      run: |
        python -c "import dify_client; print('Package imported successfully')"

  publish:
    name: Publish to PyPI
    runs-on: ubuntu-latest
    needs: [build, test-install]
    if: github.event_name == 'release' && github.event.action == 'published'

    steps:
    - name: Download build artifacts
      uses: actions/download-artifact@v4
      with:
        name: dist
        path: dist/

    - name: Publish to PyPI
      uses: pypa/gh-action-pypi-publish@release/v1
      with:
        password: ${{ secrets.PYPI_API_TOKEN }}