|
41 | 41 | - name: Run tests - ${{ matrix.python-version }} - ${{ matrix.os }}
|
42 | 42 | run: |
|
43 | 43 | uv run --all-extras pytest
|
| 44 | + |
| 45 | + |
44 | 46 |
|
45 | 47 | publish:
|
46 | 48 | name: Build & Publish
|
|
71 | 73 | - name: Publish to PyPI
|
72 | 74 | uses: pypa/gh-action-pypi-publish@release/v1
|
73 | 75 |
|
| 76 | + generate-changelog: |
| 77 | + name: Generate Changelog |
| 78 | + needs: publish |
| 79 | + if: | |
| 80 | + github.ref_type == 'tag' && |
| 81 | + startsWith(github.ref, 'refs/tags/v') && |
| 82 | + !endsWith(github.ref, '-test') && |
| 83 | + success() |
| 84 | + runs-on: ubuntu-latest |
| 85 | + steps: |
| 86 | + - name: Checkout |
| 87 | + uses: actions/checkout@v4 |
| 88 | + with: |
| 89 | + fetch-depth: 0 |
| 90 | + - name: Auto-generate Changelog |
| 91 | + |
| 92 | + with: |
| 93 | + REPO_NAME: 'JnyJny/busylight' |
| 94 | + ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 95 | + PATH: 'CHANGELOG.md' |
| 96 | + COMMIT_MESSAGE: 'docs(CHANGELOG): update release notes' |
| 97 | + TYPE: 'feat:Feature,bug:Bug Fixes,fix:Bug Fixes,docs:Documentation,refactor:Refactor,perf:Performance Improvements' |
| 98 | + |
| 99 | + github-release: |
| 100 | + name: Create GitHub Release |
| 101 | + needs: publish |
| 102 | + if: | |
| 103 | + github.ref_type == 'tag' && |
| 104 | + startsWith(github.ref, 'refs/tags/v') && |
| 105 | + !endsWith(github.ref, '-test') && |
| 106 | + success() |
| 107 | + runs-on: ubuntu-latest |
| 108 | + |
| 109 | + steps: |
| 110 | + - name: Checkout |
| 111 | + uses: actions/checkout@v4 |
| 112 | + with: |
| 113 | + fetch-depth: 0 |
| 114 | + |
| 115 | + - name: Install uv |
| 116 | + uses: astral-sh/setup-uv@v6 |
| 117 | + with: |
| 118 | + python-version: 3.8 |
| 119 | + |
| 120 | + - name: Build package |
| 121 | + run: | |
| 122 | + uv build |
| 123 | +
|
| 124 | + - name: Generate release notes |
| 125 | + id: release_notes |
| 126 | + run: | |
| 127 | + # Get the tag name |
| 128 | + TAG_NAME=${GITHUB_REF#refs/tags/} |
| 129 | + |
| 130 | + # Get the previous tag |
| 131 | + PREVIOUS_TAG=$(git describe --tags --abbrev=0 ${TAG_NAME}^ 2>/dev/null || echo "") |
| 132 | + |
| 133 | + # Generate changelog |
| 134 | + if [[ -n "$PREVIOUS_TAG" ]]; then |
| 135 | + echo "## Changes since $PREVIOUS_TAG" >> release_notes.md |
| 136 | + echo "" >> release_notes.md |
| 137 | + git log --pretty=format:"- %s (%h)" ${PREVIOUS_TAG}..${TAG_NAME} >> release_notes.md |
| 138 | + else |
| 139 | + echo "## Initial Release" >> release_notes.md |
| 140 | + echo "" >> release_notes.md |
| 141 | + echo "- Initial release of busylight" >> release_notes.md |
| 142 | + fi |
| 143 | + |
| 144 | + # Check if there's a CHANGELOG.md file |
| 145 | + if [[ -f "CHANGELOG.md" ]]; then |
| 146 | + echo "" >> release_notes.md |
| 147 | + echo "## Full Changelog" >> release_notes.md |
| 148 | + echo "" >> release_notes.md |
| 149 | + echo "See [CHANGELOG.md](CHANGELOG.md) for complete release notes." >> release_notes.md |
| 150 | + fi |
| 151 | +
|
| 152 | + - name: Create GitHub Release |
| 153 | + uses: ncipollo/release-action@v1 |
| 154 | + with: |
| 155 | + artifacts: "dist/*" |
| 156 | + bodyFile: "release_notes.md" |
| 157 | + draft: false |
| 158 | + prerelease: false |
| 159 | + generateReleaseNotes: true |
| 160 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 161 | + |
0 commit comments