⬆️ chore: Update pre-commit hook astral-sh/ruff-pre-commit to v0.8.6 … #110
This file contains 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 And Publish Python Package | |
on: | |
push: | |
branches: | |
- "main" | |
permissions: | |
contents: write | |
packages: write | |
jobs: | |
generate-changelog: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.GH_TOKEN }} | |
- name: Generate release-notes | |
id: git-cliff | |
uses: orhun/git-cliff-action@v4 | |
env: | |
OUTPUT: docs/release-notes.md | |
- name: Commit | |
run: | | |
git checkout main | |
git config user.name 'github-actions[bot]' | |
git config user.email '41898282+github-actions[bot]@users.noreply.github.com' | |
set +e docs/release-notes.md | |
git add docs/release-notes.md | |
git commit -m "🧹 chore(release-notes): Update release notes" | |
git push https://${{ secrets.GH_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git main | |
generate-release-body: | |
runs-on: ubuntu-latest | |
if: contains(github.event.head_commit.message, 'chore(release)') | |
outputs: | |
release_body: ${{ steps.git-cliff.outputs.content }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Generate release body | |
id: git-cliff | |
uses: orhun/git-cliff-action@v4 | |
with: | |
args: -vv --unreleased --strip all | |
publish: | |
runs-on: ubuntu-latest | |
environment: release | |
needs: [generate-release-body] | |
permissions: | |
id-token: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install uv | |
uses: astral-sh/setup-uv@v5 | |
with: | |
enable-cache: true | |
- name: Set up Python | |
run: uv python install | |
- name: Install the project | |
run: uv sync | |
- name: Build and publish | |
run: | | |
uv build | |
uv publish --trusted-publishing automatic | |
release: | |
runs-on: ubuntu-latest | |
needs: [generate-changelog, generate-release-body, publish] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Get version | |
run: echo "PACKAGE_VERSION=$(grep '__version__' qqmusic_api/__init__.py | awk -F'\"' '{print $2}')" >> $GITHUB_ENV | |
- name: Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
body: ${{ needs.generate-release-body.outputs.release_body }} | |
tag_name: v${{ env.PACKAGE_VERSION }} | |
token: ${{ secrets.GH_TOKEN }} |