Upload Python Package #9
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
# This workflow will upload a Python Package using Twine when a release is created | |
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries | |
# This workflow uses actions that are not certified by GitHub. | |
# They are provided by a third-party and are governed by | |
# separate terms of service, privacy policy, and support | |
# documentation. | |
name: Upload Python Package | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: | |
inputs: | |
version: | |
description: package version | |
type: string | |
required: true | |
jobs: | |
deploy: | |
runs-on: windows-latest | |
steps: | |
- name: chcp 65001 | |
run: chcp 65001 | |
- name: Checkout-检出项目 | |
uses: actions/checkout@v4 | |
- name: Install Poetry-安装poetry | |
run: pipx install poetry | |
- name: Setup Python-安装python环境 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.8" | |
cache: 'poetry' # 缓存poetry | |
- name: Update pip | |
run: pip install --upgrade pip | |
- name: Install | |
run: | | |
poetry install | |
poetry show | |
- name: 将Tag版本号填写到toml配置中 | |
if: github.event.release.tag_name | |
run: poetry version ${{github.event.release.tag_name}} | |
- name: 将version参数更新到toml配置中 | |
if: github.event.inputs.version | |
run: poetry version ${{github.event.inputs.version}} | |
- name: Install dependencies | |
run: | | |
poetry install | |
- name: Build package | |
run: poetry build | |
- name: Publish package | |
run: | | |
poetry publish --username __token__ --password ${{ secrets.PYPI_API_TOKEN }} | |
docs: | |
needs: [ deploy ] | |
permissions: | |
contents: write | |
uses: ./.github/workflows/docs.yml | |
with: | |
deploy: true |