|
1 | 1 | name: Upload ragas-examples Package |
2 | 2 |
|
3 | 3 | on: |
4 | | - push: |
5 | | - tags: |
6 | | - - "v*" # Sync with main package tags |
7 | | - workflow_dispatch: |
8 | | - inputs: |
9 | | - force_examples_release: |
10 | | - description: 'Force examples release even without changes' |
11 | | - required: false |
12 | | - default: false |
13 | | - type: boolean |
| 4 | + release: |
| 5 | + types: [published] |
14 | 6 |
|
15 | | -jobs: |
16 | | - check-examples-changes: |
17 | | - runs-on: ubuntu-latest |
18 | | - outputs: |
19 | | - examples-changed: ${{ steps.changes.outputs.examples }} |
20 | | - should-release: ${{ steps.decision.outputs.should-release }} |
21 | | - steps: |
22 | | - - uses: actions/checkout@v4 |
23 | | - with: |
24 | | - fetch-depth: 0 |
25 | | - |
26 | | - - name: Check for examples changes |
27 | | - id: changes |
28 | | - run: | |
29 | | - # Get the most recent examples release tag |
30 | | - LAST_EXAMPLES_TAG=$(git tag -l "examples-v*" --sort=-version:refname | head -n 1 || echo "") |
31 | | - |
32 | | - if [ -z "$LAST_EXAMPLES_TAG" ]; then |
33 | | - echo "No previous examples releases found, marking as changed" |
34 | | - echo "examples=true" >> $GITHUB_OUTPUT |
35 | | - else |
36 | | - echo "Checking changes since $LAST_EXAMPLES_TAG" |
37 | | - if git diff --quiet "$LAST_EXAMPLES_TAG"..HEAD -- examples/; then |
38 | | - echo "examples=false" >> $GITHUB_OUTPUT |
39 | | - echo "No changes in examples/ directory since $LAST_EXAMPLES_TAG" |
40 | | - else |
41 | | - echo "examples=true" >> $GITHUB_OUTPUT |
42 | | - echo "Changes detected in examples/ directory since $LAST_EXAMPLES_TAG" |
43 | | - fi |
44 | | - fi |
45 | | - |
46 | | - - name: Make release decision |
47 | | - id: decision |
48 | | - run: | |
49 | | - EXAMPLES_CHANGED="${{ steps.changes.outputs.examples }}" |
50 | | - FORCE_RELEASE="${{ github.event.inputs.force_examples_release }}" |
51 | | - |
52 | | - if [ "$EXAMPLES_CHANGED" = "true" ] || [ "$FORCE_RELEASE" = "true" ]; then |
53 | | - echo "should-release=true" >> $GITHUB_OUTPUT |
54 | | - if [ "$FORCE_RELEASE" = "true" ]; then |
55 | | - echo "Releasing examples due to manual override" |
56 | | - else |
57 | | - echo "Releasing examples due to detected changes" |
58 | | - fi |
59 | | - else |
60 | | - echo "should-release=false" >> $GITHUB_OUTPUT |
61 | | - echo "Skipping examples release - no changes detected" |
62 | | - fi |
| 7 | +permissions: |
| 8 | + contents: read |
63 | 9 |
|
64 | | - deploy-examples: |
65 | | - needs: check-examples-changes |
66 | | - if: needs.check-examples-changes.outputs.should-release == 'true' |
| 10 | +jobs: |
| 11 | + deploy: |
67 | 12 | runs-on: ubuntu-latest |
| 13 | + environment: pypi-release |
| 14 | + strategy: |
| 15 | + matrix: |
| 16 | + package: |
| 17 | + - name: ragas-examples |
| 18 | + directory: examples |
| 19 | + token: PYPI_API_TOKEN |
68 | 20 | steps: |
69 | | - - uses: actions/checkout@v4 |
70 | | - with: |
71 | | - fetch-depth: 0 |
72 | | - |
73 | | - - name: Set up Python |
74 | | - uses: actions/setup-python@v5 |
75 | | - with: |
76 | | - python-version: '3.x' |
77 | | - |
78 | | - - name: Install uv |
79 | | - uses: astral-sh/setup-uv@v3 |
80 | | - with: |
81 | | - version: "latest" |
82 | | - |
83 | | - - name: Install build deps (fallback) |
84 | | - run: | |
85 | | - python -m pip install --upgrade pip |
86 | | - pip install --upgrade setuptools setuptools_scm[toml] build |
87 | | - |
88 | | - - name: Sync workspace dependencies |
89 | | - run: uv sync --locked || uv sync |
90 | | - |
91 | | - - name: Build examples package with uv |
92 | | - run: uv build --package ragas-examples || python -m build |
93 | | - working-directory: examples |
94 | | - |
95 | | - - name: Publish examples to PyPI |
96 | | - uses: pypa/gh-action-pypi-publish@release/v1 |
97 | | - with: |
98 | | - password: ${{ secrets.PYPI_API_TOKEN }} |
99 | | - packages-dir: examples/dist/ |
100 | | - attestations: false |
101 | | - |
102 | | - - name: Create examples release tag |
103 | | - if: success() |
104 | | - run: | |
105 | | - # Extract version from built package using uv or fallback to setuptools_scm |
106 | | - cd examples |
107 | | - VERSION=$(uv run python -c "import ragas_examples; print(ragas_examples.__version__)" 2>/dev/null || python -m setuptools_scm) |
108 | | - TAG_NAME="examples-v${VERSION}" |
109 | | - |
110 | | - cd .. |
111 | | - git config user.name "github-actions[bot]" |
112 | | - git config user.email "github-actions[bot]@users.noreply.github.com" |
113 | | - |
114 | | - git tag "$TAG_NAME" -m "Release ragas-examples $VERSION" |
115 | | - git push origin "$TAG_NAME" |
116 | | - env: |
117 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 21 | + - uses: actions/checkout@v3 |
| 22 | + with: |
| 23 | + fetch-depth: 0 |
| 24 | + - name: Set up Python |
| 25 | + uses: actions/setup-python@v3 |
| 26 | + with: |
| 27 | + python-version: '3.x' |
| 28 | + - name: Install dependencies |
| 29 | + run: | |
| 30 | + python -m pip install --upgrade pip |
| 31 | + pip install --upgrade setuptools setuptools_scm[toml] build |
| 32 | + - name: get setuptools-scm version |
| 33 | + run: python -m setuptools_scm |
| 34 | + working-directory: ${{ matrix.package.directory }} |
| 35 | + - name: Build package |
| 36 | + run: python -m build |
| 37 | + working-directory: ${{ matrix.package.directory }} |
| 38 | + - name: Publish package |
| 39 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 40 | + with: |
| 41 | + password: ${{ secrets[matrix.package.token] }} |
| 42 | + packages-dir: ${{ matrix.package.directory }}/dist/ |
| 43 | + attestations: false |
118 | 44 |
|
119 | 45 |
|
0 commit comments