Update detection, codecs, docs, and tests #2
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' # Triggers on tags like v1.0.5, v2.0.0, etc. | |
| workflow_dispatch: # Allow manual triggering | |
| jobs: | |
| build-and-release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Fetch all history for tags | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.10' | |
| cache: 'pip' | |
| - name: Install build dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install build twine wheel setuptools | |
| - name: Extract version from tag | |
| id: tag_version | |
| run: | | |
| if [[ "${{ github.ref }}" == refs/tags/* ]]; then | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
| else | |
| # Fallback for workflow_dispatch | |
| VERSION=$(python -c "import iterable; print(iterable.__version__)") | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "tag=v$VERSION" >> $GITHUB_OUTPUT | |
| fi | |
| echo "Extracted version: $VERSION" | |
| echo "Tag: $(cat $GITHUB_OUTPUT | grep tag | cut -d= -f2)" | |
| - name: Verify version matches tag | |
| run: | | |
| PYTHON_VERSION=$(python -c "import iterable; print(iterable.__version__)") | |
| EXPECTED_VERSION="${{ steps.tag_version.outputs.version }}" | |
| if [ "$PYTHON_VERSION" != "$EXPECTED_VERSION" ]; then | |
| echo "ERROR: Version mismatch!" | |
| echo "Python package version: $PYTHON_VERSION" | |
| echo "Expected version from tag: $EXPECTED_VERSION" | |
| exit 1 | |
| fi | |
| echo "Version verification passed: $PYTHON_VERSION" | |
| - name: Run tests | |
| run: | | |
| pip install -r requirements.txt | |
| pip install pytest mock | |
| python -m pytest tests/ -v | |
| - name: Build source distribution and wheel | |
| run: | | |
| python -m build | |
| - name: Check distribution files | |
| run: | | |
| ls -lh dist/ | |
| python -m twine check dist/* | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: ${{ steps.tag_version.outputs.tag }} | |
| name: Release ${{ steps.tag_version.outputs.tag }} | |
| body: | | |
| ## Release ${{ steps.tag_version.outputs.tag }} | |
| ### Changes | |
| See [CHANGELOG](https://github.com/${{ github.repository }}/blob/${{ steps.tag_version.outputs.tag }}/CHANGELOG.md) for details. | |
| ### Installation | |
| ```bash | |
| pip install iterabledata==${{ steps.tag_version.outputs.version }} | |
| ``` | |
| ### Distribution Files | |
| - Source distribution (`.tar.gz`) | |
| - Wheel (`.whl`) | |
| Built on: ${{ github.run_started_at }} | |
| draft: false | |
| prerelease: ${{ contains(github.ref, '-alpha') || contains(github.ref, '-beta') || contains(github.ref, '-rc') }} | |
| files: dist/* | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Publish to PyPI | |
| if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-alpha') && !contains(github.ref, '-beta') && !contains(github.ref, '-rc') | |
| env: | |
| TWINE_USERNAME: __token__ | |
| TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | |
| run: | | |
| if [ -z "$TWINE_PASSWORD" ]; then | |
| echo "PyPI_API_TOKEN secret not set, skipping PyPI upload" | |
| exit 0 | |
| fi | |
| python -m twine upload dist/* | |