From fc332329e54f032a000e20662217e5ba09131c53 Mon Sep 17 00:00:00 2001 From: xaoyo Date: Sat, 28 Oct 2023 20:44:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=87=AA=E5=8A=A8=E5=8F=91?= =?UTF-8?q?=E5=B8=83=E5=88=B0pypi=E7=9A=84github=20action?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/publishNew.yml | 53 ++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 .github/workflows/publishNew.yml diff --git a/.github/workflows/publishNew.yml b/.github/workflows/publishNew.yml new file mode 100644 index 0000000..6588c27 --- /dev/null +++ b/.github/workflows/publishNew.yml @@ -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 +