|
| 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 }} |
0 commit comments