Release v1.8.0 #34
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
| # ============================================================================= | |
| # Automated Release Workflow | |
| # ============================================================================= | |
| # Triggers when a version tag (v*.*.*) is pushed. | |
| # Creates a GitHub Release with changelog notes and publishes to PyPI. | |
| # | |
| # Setup (one-time): | |
| # 1. On PyPI: Add Trusted Publisher for this repo | |
| # - Go to: https://pypi.org/manage/account/publishing/ | |
| # - Owner: ductho-le, Repository: WaveDL, Workflow: release.yml | |
| # - Environment: pypi | |
| # 2. On GitHub: Create environment named "pypi" | |
| # - Go to: Settings > Environments > New environment > "pypi" | |
| # | |
| # Usage: | |
| # 1. Update CHANGELOG.md with release notes | |
| # 2. Bump version in src/wavedl/__init__.py | |
| # 3. Commit, tag, and push: | |
| # git tag v1.2.0 | |
| # git push origin main --tags | |
| # ============================================================================= | |
| name: Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*.*.*' | |
| permissions: | |
| contents: write | |
| jobs: | |
| # ============================================================================= | |
| # Test across Python versions (matrix) | |
| # ============================================================================= | |
| test: | |
| name: Test (Python ${{ matrix.python-version }}) | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: true | |
| matrix: | |
| python-version: ['3.11', '3.12', '3.13'] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Cache pip dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/pip | |
| key: ${{ runner.os }}-py${{ matrix.python-version }}-pip-${{ hashFiles('pyproject.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-py${{ matrix.python-version }}-pip- | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e ".[dev]" | |
| - name: Run tests | |
| run: pytest unit_tests -v -m "not slow" | |
| # ============================================================================= | |
| # Create GitHub Release (single job, no matrix) | |
| # ============================================================================= | |
| release: | |
| name: Create Release | |
| needs: test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Extract version from tag | |
| id: version | |
| run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
| - name: Extract changelog for this version | |
| id: changelog | |
| run: | | |
| # Extract the section for this version from CHANGELOG.md | |
| VERSION="${{ steps.version.outputs.VERSION }}" | |
| VERSION_NUM="${VERSION#v}" # Remove 'v' prefix for matching | |
| # Extract content between this version header and the next version header | |
| NOTES=$(awk -v ver="$VERSION_NUM" ' | |
| /^## \[/ { | |
| if (found) exit | |
| if (index($0, "[" ver "]") > 0) found=1 | |
| next | |
| } | |
| found { print } | |
| ' CHANGELOG.md) | |
| # Handle multi-line output for GitHub Actions | |
| echo "NOTES<<EOF" >> $GITHUB_OUTPUT | |
| echo "$NOTES" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| - name: Create GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| name: ${{ steps.version.outputs.VERSION }} | |
| body: ${{ steps.changelog.outputs.NOTES }} | |
| draft: false | |
| prerelease: ${{ contains(steps.version.outputs.VERSION, '-') }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # ============================================================================= | |
| # Publish to PyPI | |
| # ============================================================================= | |
| publish: | |
| name: Publish to PyPI | |
| needs: release | |
| runs-on: ubuntu-latest | |
| environment: pypi | |
| permissions: | |
| id-token: write # Required for Trusted Publishing | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install build tools | |
| run: pip install build | |
| - name: Build package | |
| run: python -m build | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 |