
- Add workflow_call trigger to test.yml to make it reusable by other workflows - Fix codecov action parameter from 'file' to 'files' for v4 compatibility - Update deprecated actions/create-release@v1 to softprops/action-gh-release@v2 - Add automated version bumping with commitizen - Implement PyPI trusted publishing for secure, token-free uploads - Add changelog generation with smart commit filtering - Update to Python 3.13 and enhance dependency caching - Use PERSONAL_ACCESS_TOKEN for enhanced permissions Signed-off-by: longhao <hal.long@outlook.com>
87 lines
2.2 KiB
YAML
87 lines
2.2 KiB
YAML
name: Upload Python Package
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*"
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
# IMPORTANT: this permission is mandatory for trusted publishing
|
|
id-token: write
|
|
contents: write
|
|
|
|
steps:
|
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
|
with:
|
|
token: "${{ secrets.GITHUB_TOKEN }}"
|
|
fetch-depth: 0
|
|
ref: main
|
|
- uses: olegtarasov/get-tag@v2.1.4
|
|
id: get_tag_name
|
|
with:
|
|
tagRegex: "v(?<version>.*)"
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.13'
|
|
|
|
# 缓存 Poetry 依赖
|
|
- name: Cache Poetry dependencies
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.cache/pypoetry
|
|
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-poetry-
|
|
|
|
- name: Install Poetry
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install uv
|
|
uv --version
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
uvx poetry install
|
|
uvx poetry build
|
|
|
|
# Note that we don't need credentials.
|
|
# We rely on https://docs.pypi.org/trusted-publishers/.
|
|
- name: Upload to PyPI
|
|
uses: pypa/gh-action-pypi-publish@release/v1
|
|
with:
|
|
packages-dir: dist
|
|
verbose: true
|
|
print-hash: true
|
|
|
|
- name: Generate changelog
|
|
id: changelog
|
|
uses: jaywcjlove/changelog-generator@main
|
|
with:
|
|
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
|
|
filter-author: (|dependabot|renovate\[bot\]|dependabot\[bot\]|Renovate Bot)
|
|
filter: '[R|r]elease[d]\s+[v|V]\d(\.\d+){0,2}'
|
|
template: |
|
|
## Bugs
|
|
{{fix}}
|
|
## Feature
|
|
{{feat}}
|
|
## Improve
|
|
{{refactor,perf,clean}}
|
|
## Misc
|
|
{{chore,style,ci||🔶 Nothing change}}
|
|
## Unknown
|
|
{{__unknown__}}
|
|
|
|
- uses: ncipollo/release-action@v1
|
|
with:
|
|
artifacts: "dist/*"
|
|
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
|
|
body: |
|
|
Comparing Changes: ${{ steps.changelog.outputs.compareurl }}
|
|
|
|
${{ steps.changelog.outputs.changelog }}
|