-
Notifications
You must be signed in to change notification settings - Fork 53
184 lines (159 loc) · 5.37 KB
/
databricks-dspy-release.yml
File metadata and controls
184 lines (159 loc) · 5.37 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
name: Build and Release databricks-dspy
on:
push:
tags:
- 'databricks-dspy-v*'
jobs:
extract_tag:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.extract.outputs.version }}
steps:
- name: Extract version from tag
id: extract
run: |
# Extract version from tag like databricks-dspy-v1.0.0 -> 1.0.0
TAG=${GITHUB_REF#refs/tags/databricks-dspy-v}
echo "version=$TAG" >> $GITHUB_OUTPUT
echo "Extracted version: $TAG"
build_and_test:
runs-on: ubuntu-latest
needs: extract_tag
defaults:
run:
working-directory: integrations/dspy
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build twine
pip install .[dev]
- name: Lint with ruff
run: |
ruff check .
ruff format --check .
- name: Run tests
run: |
pytest tests/unit_tests
- name: Validate version matches tag
run: |
PYPROJECT_VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
TAG_VERSION="${{ needs.extract_tag.outputs.version }}"
if [ "$PYPROJECT_VERSION" != "$TAG_VERSION" ]; then
echo "Error: Version in pyproject.toml ($PYPROJECT_VERSION) does not match tag ($TAG_VERSION)"
exit 1
fi
echo "Version validation passed: $PYPROJECT_VERSION"
- name: Build original package for PyPI
run: |
python -m build
# Save original package for PyPI
mkdir -p dist-pypi
cp dist/* dist-pypi/
- name: Build test package for TestPyPI
run: |
# Clean previous build
rm -rf dist/*
# Update package name for TestPyPI
sed -i 's/^name *= *".*"/name = "databricks-dspy-test"/' pyproject.toml
# Add dev suffix with timestamp for unique TestPyPI versions
TIMESTAMP=$(date +%Y%m%d%H%M%S)
sed -i "s/^version *= *\"\(.*\)\"/version = \"\1.dev${TIMESTAMP}\"/" pyproject.toml
echo "Updated version for TestPyPI: $(grep '^version = ' pyproject.toml)"
# Build test package
python -m build
- name: Check packages
run: |
twine check dist/*
twine check dist-pypi/*
- name: Upload TestPyPI artifacts
uses: actions/upload-artifact@v4
with:
name: dist-test-files
path: integrations/dspy/dist/
- name: Upload PyPI artifacts
uses: actions/upload-artifact@v4
with:
name: dist-pypi-files
path: integrations/dspy/dist-pypi/
publish_test_pypi:
runs-on: ubuntu-latest
needs: [extract_tag, build_and_test]
defaults:
run:
working-directory: integrations/dspy
environment:
name: test-pypi
url: https://test.pypi.org/p/databricks-dspy-test
permissions:
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Download TestPyPI artifacts
uses: actions/download-artifact@v4
with:
name: dist-test-files
path: integrations/dspy/dist/
- name: Install twine
run: |
python -m pip install --upgrade pip twine
- name: Publish to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
packages-dir: integrations/dspy/dist/
- name: Test installation from TestPyPI
run: |
sleep 30 # Wait for package to be available
# Install the test package with dev version
pip install --index-url https://test.pypi.org/simple/ \
--extra-index-url https://pypi.org/simple \
databricks-dspy-test
python -c "import databricks_dspy; print('Package installed successfully from TestPyPI')"
publish_pypi:
runs-on: ubuntu-latest
if: github.repository_owner == 'databricks'
needs: [extract_tag, publish_test_pypi]
defaults:
run:
working-directory: integrations/dspy
environment:
name: pypi
url: https://pypi.org/p/databricks-dspy
permissions:
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Download PyPI artifacts
uses: actions/download-artifact@v4
with:
name: dist-pypi-files
path: integrations/dspy/dist/
- name: Install twine
run: |
python -m pip install --upgrade pip twine
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: integrations/dspy/dist/
- name: Test installation from PyPI
run: |
sleep 60 # Wait for package to be available
pip install databricks-dspy==${{ needs.extract_tag.outputs.version }}
python -c "import databricks_dspy; print('Package installed successfully from PyPI')"