bump: version 1.5.0 → 1.6.0 #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 to PyPI | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| permissions: | |
| contents: write | |
| id-token: write | |
| jobs: | |
| validate: | |
| name: Validate Release | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.get_version.outputs.version }} | |
| changelog: ${{ steps.extract_changelog.outputs.changelog }} | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.11" | |
| - name: Get version from tag | |
| id: get_version | |
| run: | | |
| TAG_VERSION=${GITHUB_REF#refs/tags/v} | |
| echo "version=$TAG_VERSION" >> $GITHUB_OUTPUT | |
| echo "Tag version: $TAG_VERSION" | |
| - name: Validate version consistency | |
| run: | | |
| TAG_VERSION=${{ steps.get_version.outputs.version }} | |
| # Check pyproject.toml [project] version | |
| # NOTE: `grep '^version = '` would match both [project].version and | |
| # [tool.commitizen].version. Restrict to the first match. | |
| PYPROJECT_VERSION=$(grep -m1 '^version = ' pyproject.toml | cut -d '"' -f 2) | |
| echo "pyproject.toml version: $PYPROJECT_VERSION" | |
| # Check __version__.py version | |
| VERSION_PY=$(grep '^__version__ = ' src/flac_detective/__version__.py | cut -d '"' -f 2) | |
| echo "__version__.py version: $VERSION_PY" | |
| # Validate all versions match | |
| if [ "$TAG_VERSION" != "$PYPROJECT_VERSION" ]; then | |
| echo "❌ Error: Tag version ($TAG_VERSION) doesn't match pyproject.toml ($PYPROJECT_VERSION)" | |
| exit 1 | |
| fi | |
| if [ "$TAG_VERSION" != "$VERSION_PY" ]; then | |
| echo "❌ Error: Tag version ($TAG_VERSION) doesn't match __version__.py ($VERSION_PY)" | |
| exit 1 | |
| fi | |
| echo "✅ All versions match: $TAG_VERSION" | |
| - name: Install Commitizen | |
| run: | | |
| python -m pip install commitizen | |
| - name: Extract changelog for this version | |
| id: extract_changelog | |
| run: | | |
| VERSION=${{ steps.get_version.outputs.version }} | |
| # Extract changelog section for this version using Commitizen format | |
| python3 << 'EOF' > release_notes.md | |
| import re | |
| import sys | |
| version = "${{ steps.get_version.outputs.version }}" | |
| with open("CHANGELOG.md", "r", encoding="utf-8") as f: | |
| content = f.read() | |
| # Find the section for this version (Commitizen format: ## vX.Y.Z (date)) | |
| pattern = rf"## v{re.escape(version)}.*?\n(.*?)(?=\n## v|$)" | |
| match = re.search(pattern, content, re.DOTALL) | |
| if match: | |
| changelog_text = match.group(1).strip() | |
| print(changelog_text) | |
| else: | |
| print(f"⚠️ No changelog found for version {version}") | |
| sys.exit(1) | |
| EOF | |
| # Store changelog in output (escaped for multiline) | |
| { | |
| echo 'changelog<<EOF' | |
| cat release_notes.md | |
| echo EOF | |
| } >> $GITHUB_OUTPUT | |
| echo "📝 Changelog extracted successfully" | |
| - name: Validate CHANGELOG.md entry exists | |
| run: | | |
| VERSION=${{ steps.get_version.outputs.version }} | |
| # Check for Commitizen format: ## vX.Y.Z (date) | |
| if ! grep -q "## v$VERSION" CHANGELOG.md; then | |
| echo "❌ Error: No CHANGELOG.md entry found for version $VERSION" | |
| echo "Run 'cz changelog' to generate/update the changelog." | |
| exit 1 | |
| fi | |
| echo "✅ CHANGELOG.md entry exists for version $VERSION" | |
| build: | |
| name: Build Distribution | |
| needs: validate | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.11" | |
| - name: Install build dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install build twine | |
| - name: Build package | |
| run: | | |
| python -m build | |
| echo "📦 Package built successfully" | |
| - name: Check distribution | |
| run: | | |
| twine check dist/* | |
| echo "✅ Distribution check passed" | |
| - name: List built files | |
| run: | | |
| echo "📋 Built files:" | |
| ls -lh dist/ | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: dist-packages | |
| path: dist/ | |
| retention-days: 7 | |
| test-package: | |
| name: Test Package Installation | |
| needs: build | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-latest] | |
| python-version: ["3.10", "3.12"] | |
| steps: | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: dist-packages | |
| path: dist/ | |
| - name: Install package from wheel | |
| # `shell: bash` so the `dist/*.whl` glob expands on Windows runners | |
| # too — PowerShell's default does not glob unquoted arguments to | |
| # native executables, so `pip` would receive a literal "*". | |
| shell: bash | |
| run: | | |
| pip install dist/*.whl | |
| - name: Test CLI entry point | |
| run: | | |
| flac-detective --version | |
| - name: Test Python import | |
| # Plain ASCII print — Windows runners default to cp1252 for the | |
| # process and an emoji here makes the test fail with UnicodeEncodeError. | |
| run: | | |
| python -c "import flac_detective; print('Import OK, version', flac_detective.__version__)" | |
| publish-pypi: | |
| name: Publish to PyPI | |
| needs: [validate, build, test-package] | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/project/flac-detective/ | |
| steps: | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: dist-packages | |
| path: dist/ | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| print-hash: true | |
| verbose: true | |
| - name: Confirm publication | |
| run: | | |
| echo "🎉 Package published to PyPI successfully!" | |
| echo "📦 View at: https://pypi.org/project/flac-detective/${{ needs.validate.outputs.version }}/" | |
| create-github-release: | |
| name: Create GitHub Release | |
| needs: [validate, publish-pypi] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: dist-packages | |
| path: dist/ | |
| - name: Create release notes file | |
| run: | | |
| cat > release_notes.md << 'EOF' | |
| ${{ needs.validate.outputs.changelog }} | |
| EOF | |
| # Add installation instructions | |
| cat >> release_notes.md << 'EOF' | |
| --- | |
| ## Installation | |
| Install via pip: | |
| ```bash | |
| pip install flac-detective==${{ needs.validate.outputs.version }} | |
| ``` | |
| Or upgrade to this version: | |
| ```bash | |
| pip install --upgrade flac-detective | |
| ``` | |
| ## Links | |
| - 📦 [PyPI Package](https://pypi.org/project/flac-detective/${{ needs.validate.outputs.version }}/) | |
| - 📖 [Documentation](https://github.com/Guillain-RDCDE/FLAC_Detective#readme) | |
| - 🐛 [Report Issues](https://github.com/Guillain-RDCDE/FLAC_Detective/issues) | |
| ## Checksums | |
| SHA256 checksums for distribution files: | |
| EOF | |
| # Add checksums | |
| cd dist | |
| sha256sum * >> ../release_notes.md | |
| cd .. | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v3 | |
| with: | |
| name: "Release v${{ needs.validate.outputs.version }}" | |
| body_path: release_notes.md | |
| files: dist/* | |
| draft: false | |
| prerelease: false | |
| generate_release_notes: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Confirm release creation | |
| run: | | |
| echo "🎉 GitHub Release created successfully!" | |
| echo "🔗 View at: https://github.com/${{ github.repository }}/releases/tag/${{ github.ref_name }}" | |
| notify: | |
| name: Post-Release Notifications | |
| needs: [validate, create-github-release] | |
| runs-on: ubuntu-latest | |
| if: always() | |
| steps: | |
| - name: Release Summary | |
| run: | | |
| echo "## 🚀 Release Summary" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Version:** ${{ needs.validate.outputs.version }}" >> $GITHUB_STEP_SUMMARY | |
| echo "**Tag:** ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### Status" >> $GITHUB_STEP_SUMMARY | |
| echo "- ✅ Package built and validated" >> $GITHUB_STEP_SUMMARY | |
| echo "- ✅ Published to PyPI" >> $GITHUB_STEP_SUMMARY | |
| echo "- ✅ GitHub Release created" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### Links" >> $GITHUB_STEP_SUMMARY | |
| echo "- [PyPI Package](https://pypi.org/project/flac-detective/${{ needs.validate.outputs.version }}/)" >> $GITHUB_STEP_SUMMARY | |
| echo "- [GitHub Release](https://github.com/${{ github.repository }}/releases/tag/${{ github.ref_name }})" >> $GITHUB_STEP_SUMMARY |