forked from mpfaffenberger/code_puppy
-
Notifications
You must be signed in to change notification settings - Fork 0
134 lines (112 loc) · 4.69 KB
/
Copy pathpublish.yml
File metadata and controls
134 lines (112 loc) · 4.69 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
# Publishes your package to PyPI using Astral/uv for builds.
# Set PYPI_API_TOKEN in repo secrets.
permissions:
contents: write # Allows writing to the repository
name: Build and Publish to PyPI
on:
push:
branches:
- main
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest]
python-version: ['3.13']
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
run: pip install uv
- name: Setup uv virtual environment
run: uv venv
- name: Install dependencies
# [durable] extras pulls in dbos, required by integration test
# tests/integration/test_dbos_enabled.py
run: uv pip install -e ".[durable]"
- name: Install pexpect for integration tests
run: uv pip install pexpect>=4.9.0
- name: Debug environment variables
env:
CEREBRAS_API_KEY: ${{ secrets.CEREBRAS_API_KEY || 'fake-key-for-ci-testing' }}
CONTEXT7_API_KEY: ${{ secrets.CONTEXT7_API_KEY || 'fake-key-for-ci-testing' }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY || 'fake-key-for-ci-testing' }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY || 'fake-key-for-ci-testing' }}
SYN_API_KEY: ${{ secrets.SYN_API_KEY || 'fake-key-for-ci-testing' }}
run: |
echo "=== DEBUG: Environment Variables ==="
echo "CEREBRAS_API_KEY is set: ${{ secrets.CEREBRAS_API_KEY != '' }}"
echo "CONTEXT7_API_KEY is set: ${{ secrets.CONTEXT7_API_KEY != '' }}"
echo "OPENAI_API_KEY is set: ${{ secrets.OPENAI_API_KEY != '' }}"
echo "ANTHROPIC_API_KEY is set: ${{ secrets.ANTHROPIC_API_KEY != '' }}"
echo "SYN_API_KEY is set: ${{ secrets.SYN_API_KEY != '' }}"
echo "CEREBRAS_API_KEY length: ${#CEREBRAS_API_KEY}"
echo "CONTEXT7_API_KEY length: ${#CONTEXT7_API_KEY}"
echo "OPENAI_API_KEY length: ${#OPENAI_API_KEY}"
echo "ANTHROPIC_API_KEY length: ${#ANTHROPIC_API_KEY}"
echo "SYN_API_KEY length: ${#SYN_API_KEY}"
echo "=== END DEBUG ==="
- name: Run tests
env:
CI: '1'
CODE_PUPPY_TEST_FAST: '1'
CEREBRAS_API_KEY: ${{ secrets.CEREBRAS_API_KEY || 'fake-key-for-ci-testing' }}
CONTEXT7_API_KEY: ${{ secrets.CONTEXT7_API_KEY || 'fake-key-for-ci-testing' }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY || 'fake-key-for-ci-testing' }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY || 'fake-key-for-ci-testing' }}
SYN_API_KEY: ${{ secrets.SYN_API_KEY || 'fake-key-for-ci-testing' }}
run: |
echo "Running tests (including integration tests) on ${{ runner.os }} with Python ${{ matrix.python-version }}..."
echo "Required environment variables are set (using CI fallbacks if secrets not available)"
uv run pytest tests/ -v --cov=code_puppy --cov-report=term-missing
build-publish:
runs-on: ubuntu-latest
needs: test
permissions:
contents: write # Allows writing to the repository
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Python 3.13
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Install uv, build, and twine
run: pip install uv build twine
- name: Setup uv virtual environment
run: uv venv
- name: Bump version
run: uv version --bump patch
- name: Capture new version
id: version
run: |
NEW_VERSION=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/')
echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
echo "New version: $NEW_VERSION"
- name: Build package
run: |
uv build
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: uv run twine upload --verbose dist/*
- name: Push version bump and tag to GitHub
if: ${{ success() }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add .
git commit -m "chore: bump version [ci skip]" || echo "No changes to commit"
TAG="v${{ steps.version.outputs.version }}"
git tag -a "$TAG" -m "Release $TAG"
git push
git push origin "$TAG"