Skip to content

Commit 3be5a2e

Browse files
committed
feat: add ci & publish
1 parent 5d41da8 commit 3be5a2e

File tree

2 files changed

+160
-0
lines changed

2 files changed

+160
-0
lines changed

.github/workflows/release.yml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Release & Publish
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
name: Publish to PyPI
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Python
18+
uses: actions/setup-python@v4
19+
with:
20+
python-version: '3.12'
21+
22+
- name: Install build dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
pip install build twine
26+
27+
- name: Install package dependencies
28+
run: |
29+
pip install -e ".[test]"
30+
31+
- name: Validate package
32+
run: |
33+
python -c "import src.thecompaniesapi; print('✅ Package imports successfully')"
34+
python -c "from src.thecompaniesapi import Client, HttpClient, ApiError; print('✅ All exports available')"
35+
python -m py_compile src/thecompaniesapi/*.py
36+
python -m py_compile src/thecompaniesapi/generated/*.py
37+
38+
- name: Run tests
39+
env:
40+
TCA_API_TOKEN: ${{ secrets.TCA_API_TOKEN }}
41+
run: |
42+
pytest tests/test_client.py -m unit -v
43+
pytest tests/test_integration.py -m integration -v
44+
45+
- name: Extract version
46+
id: extract_version
47+
run: |
48+
VERSION=${GITHUB_REF#refs/tags/}
49+
echo "version=$VERSION" >> $GITHUB_OUTPUT
50+
echo "clean_version=${VERSION#v}" >> $GITHUB_OUTPUT
51+
52+
- name: Build package
53+
run: python -m build
54+
55+
- name: Check package
56+
run: |
57+
python -m twine check dist/*
58+
ls -la dist/
59+
60+
- name: Publish to PyPI
61+
env:
62+
TWINE_USERNAME: __token__
63+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
64+
run: |
65+
echo "Publishing to PyPI..."
66+
python -m twine upload dist/*
67+
echo "✅ Package published to PyPI successfully"
68+
69+
- name: Create Release
70+
uses: softprops/action-gh-release@v1
71+
with:
72+
tag_name: ${{ steps.extract_version.outputs.version }}
73+
name: Release ${{ steps.extract_version.outputs.version }}
74+
body: |
75+
## 🚀 Release ${{ steps.extract_version.outputs.version }}
76+
77+
### 📦 Installation
78+
79+
```bash
80+
pip install thecompaniesapi==${{ steps.extract_version.outputs.clean_version }}
81+
```
82+
83+
### 📋 What's Changed
84+
85+
See the [commit history](https://github.com/${{ github.repository }}/commits/${{ steps.extract_version.outputs.version }}) for detailed changes.
86+
87+
### 🔗 Links
88+
89+
- 📖 [Documentation](https://github.com/${{ github.repository }}#readme)
90+
- 📦 [PyPI Package](https://pypi.org/project/thecompaniesapi/)
91+
- 🌐 [The Companies API](https://www.thecompaniesapi.com)
92+
- 📚 [API Documentation](https://www.thecompaniesapi.com/api)
93+
- 🔗 [TypeScript SDK](https://github.com/thecompaniesapi/sdk-typescript)
94+
draft: false
95+
prerelease: false
96+
generate_release_notes: true
97+
env:
98+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/tests.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
python-version: ['3.12']
15+
16+
name: Test Python ${{ matrix.python-version }}
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Set up Python ${{ matrix.python-version }}
22+
uses: actions/setup-python@v4
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
26+
- name: Cache pip packages
27+
uses: actions/cache@v3
28+
with:
29+
path: ~/.cache/pip
30+
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml') }}
31+
restore-keys: |
32+
${{ runner.os }}-pip-${{ matrix.python-version }}-
33+
34+
- name: Install dependencies
35+
run: |
36+
python -m pip install --upgrade pip
37+
pip install -e ".[test]"
38+
39+
- name: Validate package
40+
run: |
41+
python -c "import src.thecompaniesapi; print('✅ Package imports successfully')"
42+
python -c "from src.thecompaniesapi import Client, HttpClient, ApiError; print('✅ All exports available')"
43+
44+
- name: Check syntax
45+
run: |
46+
python -m py_compile src/thecompaniesapi/*.py
47+
python -m py_compile src/thecompaniesapi/generated/*.py
48+
python -m py_compile tests/*.py
49+
python -m py_compile scripts/*.py
50+
51+
- name: Run unit tests
52+
run: pytest tests/test_client.py -m unit -v
53+
54+
- name: Run integration tests
55+
env:
56+
TCA_API_TOKEN: ${{ secrets.TCA_API_TOKEN }}
57+
run: pytest tests/test_integration.py -m integration -v
58+
59+
- name: Test package installation
60+
run: |
61+
pip install -e .
62+
python -c "import thecompaniesapi; print('✅ Package installs and imports correctly')"

0 commit comments

Comments
 (0)