添加自动发布到pypi的github action
This commit is contained in:
parent
0a9a48c042
commit
fc332329e5
53
.github/workflows/publishNew.yml
vendored
Normal file
53
.github/workflows/publishNew.yml
vendored
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
name: Publish
|
||||||
|
|
||||||
|
on:
|
||||||
|
# 当master分支有push时,触发action
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*' # 以 'v' 开头的标签触发工作流程
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publish:
|
||||||
|
name: Publish Pypi and Create Release
|
||||||
|
if: github.repository == 'xaoyaoo/PyWxDump' && contains(github.ref, 'tags/v') # 仅在指定仓库的 tag 触发工作流程
|
||||||
|
# 此作业在 Linux 上运行
|
||||||
|
runs-on: windows-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository # 检出仓库
|
||||||
|
uses: actions/checkout@v2 # 使用 GitHub 官方的 checkout action
|
||||||
|
- run: |
|
||||||
|
git fetch --prune --unshallow
|
||||||
|
|
||||||
|
- name: Set up Python # 设置 Python 环境
|
||||||
|
uses: actions/setup-python@v2 # 使用 GitHub 官方的 setup-python action
|
||||||
|
with:
|
||||||
|
python-version: 3.8 # 指定 Python 版本 (3.8)
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install build
|
||||||
|
|
||||||
|
- name: Build package
|
||||||
|
run: python -m build
|
||||||
|
|
||||||
|
- name: Publish package
|
||||||
|
uses: pypa/gh-action-pypi-publish@release/v1 # 使用 PyPA 的 action
|
||||||
|
with:
|
||||||
|
user: __token__ # 使用 GitHub Token 进行身份验证
|
||||||
|
password: ${{ secrets.PYPI_TOKEN }} # 设置 GitHub Token 密钥
|
||||||
|
|
||||||
|
- name: Create Release
|
||||||
|
id: create_release
|
||||||
|
uses: actions/create-release@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
tag_name: ${{ github.ref }}
|
||||||
|
release_name: Release ${{ github.ref }}
|
||||||
|
body: |
|
||||||
|
Update PyWxDump
|
||||||
|
draft: false
|
||||||
|
prerelease: false
|
||||||
|
|
Loading…
Reference in New Issue
Block a user