@@ -14,97 +14,17 @@ jobs:
14
14
runs-on : ubuntu-latest
15
15
permissions :
16
16
contents : read
17
- id-token : write # For trusted publishing to PyPI
17
+ id-token : write
18
18
environment :
19
19
name : pypi
20
20
steps :
21
21
- uses : actions/checkout@v4
22
+ - uses : actions/setup-python@v5
23
+ - uses : astral-sh/setup-uv@v5
22
24
with :
23
- fetch-depth : 0 # Important for setuptools_scm
25
+ enable-cache : true
26
+ - run : uv build
24
27
25
- - name : Install uv
26
- uses : astral-sh/setup-uv@v4
27
-
28
- - name : Set up Python
29
- run : uv python install 3.10
30
-
31
- - name : Create virtual environment
32
- run : uv venv
33
-
34
- - name : Install build dependencies
35
- run : uv pip install build twine setuptools_scm
36
-
37
- - name : Build package
38
- run : uv run python -m build
39
-
40
- - name : Check package with twine
41
- run : uv run twine check dist/*
42
-
43
- - name : Verify version matches tag
44
- run : |
45
- TAG_VERSION=$(echo ${{ github.ref_name }} | sed 's/^v//')
46
- PKG_VERSION=$(uv run python -c "import setuptools_scm; print(setuptools_scm.get_version())")
47
- echo "Tag version: $TAG_VERSION"
48
- echo "Package version: $PKG_VERSION"
49
- # Store package version for later use in installation
50
- echo "PKG_VERSION=$PKG_VERSION" >> $GITHUB_ENV
51
-
52
- # Extract just the base version part (e.g., "0.3.0a3" from "0.3.0a3.dev0+g24d832d.d20250621")
53
- BASE_TAG_VERSION=$(echo "$TAG_VERSION" | grep -o '^[0-9]\+\.[0-9]\+\.[0-9]\+[a-z][0-9]\+')
54
- BASE_PKG_VERSION=$(echo "$PKG_VERSION" | grep -o '^[0-9]\+\.[0-9]\+\.[0-9]\+[a-z][0-9]\+')
55
-
56
- echo "Base tag version: $BASE_TAG_VERSION"
57
- echo "Base package version: $BASE_PKG_VERSION"
58
-
59
- if [[ "$BASE_PKG_VERSION" == "$BASE_TAG_VERSION" || "$PKG_VERSION" == *"$TAG_VERSION"* ]]; then
60
- echo "Version check passed!"
61
- else
62
- echo "Version mismatch between tag and package!"
63
- exit 1
64
- fi
65
-
66
- - name : Show package files
67
- run : |
68
- echo "Tag: ${GITHUB_REF#refs/tags/}"
69
- echo "Package files:"
70
- ls -la dist/
71
-
72
- - name : Publish to TestPyPI
73
- uses : pypa/gh-action-pypi-publish@release/v1
28
+ - uses : pypa/gh-action-pypi-publish@release/v1
74
29
with :
75
30
repository-url : https://test.pypi.org/legacy/
76
- user : __token__
77
- password : ${{ secrets.TEST_PYPI_API_TOKEN }}
78
- verbose : true
79
- skip-existing : true
80
-
81
- - name : Test installation from TestPyPI
82
- run : |
83
- # Add a delay to allow TestPyPI to process the upload
84
- echo "Waiting 10 seconds for TestPyPI to process the package..."
85
- sleep 10
86
-
87
- # Try to install the package with retry mechanism
88
- MAX_RETRIES=3
89
- RETRY_DELAY=10
90
- for i in $(seq 1 $MAX_RETRIES); do
91
- echo "Installation attempt $i of $MAX_RETRIES..."
92
- if uv pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ "ollama-mpc-bridge==$PKG_VERSION"; then
93
- echo "Package installed successfully!"
94
- uv run python -c "from ollama_mpc_bridge import __version__; print(f'Installed version: {__version__}')"
95
- exit 0
96
- else
97
- echo "Installation failed. Waiting $RETRY_DELAY seconds before retrying..."
98
- sleep $RETRY_DELAY
99
- fi
100
- done
101
-
102
- echo "Failed to install package after $MAX_RETRIES attempts."
103
- exit 1
104
-
105
- # Upload the built packages as artifacts for inspection
106
- - name : Upload package artifacts
107
- uses : actions/upload-artifact@v4
108
- with :
109
- name : dist
110
- path : dist/
0 commit comments