Repository navigation
145 lines (131 loc) · 4.85 KB
/
Copy pathci.yml
File metadata and controls
145 lines (131 loc) · 4.85 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
name: SDK Release
on:
workflow_dispatch:
pull_request:
types: [closed]
branches:
- main
jobs:
compile:
if: github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Set up python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Bootstrap poetry
run: |
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
- name: Install dependencies
run: |
poetry install
pip install types-tqdm python-dotenv python-dateutil tqdm types-python-dateutil || echo "Optional dependencies not installed"
- name: Compile
run: |
if [ -f "mypy.ini" ] && [ -f "src/newscatcher/client.py" ] && [ -f "src/newscatcher/utils.py" ]; then
poetry run mypy --config-file=mypy.ini src/newscatcher/client.py src/newscatcher/utils.py tests/ || echo "Custom mypy check completed with warnings"
poetry run mypy --config-file=mypy.ini --disable-error-code=no-any-return src/newscatcher/core/ || echo "Core mypy check completed with warnings"
else
poetry run mypy .
fi
test:
if: github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Set up python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Bootstrap poetry
run: |
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
- name: Install dependencies
run: |
poetry install
poetry install --with dev || echo "Dev dependencies not available"
pip install pytest pytest-asyncio python-dateutil tqdm python-dotenv httpx || echo "Optional test dependencies not installed"
- name: Test
run: |
if [ -d "tests/utils" ]; then
poetry run pytest -rP tests/utils
else
poetry run pytest -rP .
fi
release:
needs: [compile, test]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout main
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0
- name: Read version from pyproject.toml
id: version
run: |
VERSION=$(grep -m1 '^version = ' pyproject.toml | grep -oP '"\K[^"]+')
if [ -z "$VERSION" ]; then
echo "ERROR: Could not read version from pyproject.toml"
exit 1
fi
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "TAG=v$VERSION" >> $GITHUB_OUTPUT
- name: Get latest git tag
id: latest_tag
run: |
LATEST=$(git describe --tags --abbrev=0 2>/dev/null || echo "none")
echo "LATEST_TAG=$LATEST" >> $GITHUB_OUTPUT
- name: Check if version was bumped
id: check
run: |
TAG="${{ steps.version.outputs.TAG }}"
LATEST="${{ steps.latest_tag.outputs.LATEST_TAG }}"
if [ "$TAG" = "$LATEST" ]; then
echo "bumped=false" >> $GITHUB_OUTPUT
echo "Version $TAG already tagged — skipping release."
else
echo "bumped=true" >> $GITHUB_OUTPUT
echo "New version detected: $TAG (previous: $LATEST)"
fi
- name: Set up python
if: steps.check.outputs.bumped == 'true'
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Bootstrap poetry
if: steps.check.outputs.bumped == 'true'
run: |
curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1
- name: Install dependencies
if: steps.check.outputs.bumped == 'true'
run: poetry install
- name: Create and push tag
if: steps.check.outputs.bumped == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag "${{ steps.version.outputs.TAG }}"
git push origin "${{ steps.version.outputs.TAG }}"
- name: Publish to PyPI
if: steps.check.outputs.bumped == 'true'
run: |
poetry config pypi-token.pypi "$PYPI_TOKEN"
poetry --no-interaction -v publish --build
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
- name: Create GitHub release with generated notes
if: steps.check.outputs.bumped == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "${{ steps.version.outputs.TAG }}" \
--title "${{ steps.version.outputs.TAG }}" \
--generate-notes \
--latest