Skip to content

构建并发布到 PyPI #34

构建并发布到 PyPI

构建并发布到 PyPI #34

Workflow file for this run

# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#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: 构建并发布到 PyPI
on:
push:
tags:
- v**
workflow_dispatch:
permissions:
contents: read
jobs:
build-and-publish:
runs-on: ubuntu-16.04
steps:
- name: 检出 ${{ github.ref_name }} 分支
uses: actions/checkout@v4
- name: 安装 Python 3.10.11
uses: actions/setup-python@v5
with:
python-version: '3.10.11'
- name: 安装打包所需依赖
run: |
python -m pip install --upgrade pip
pip install wheel build twine
- name: 构建阶段
run: python -m build
- name: 发布到 TestPyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
run: |
twine upload --repository testpypi dist/*
- name: 发布到 PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
twine upload dist/*