先build,再tag,做小版本 #4
Workflow file for this run
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
name: easylangchain | |
on: | |
# 手动触发 | |
workflow_dispatch: | |
# # 推送 tag 是 v*.*.*时触发 | |
push: | |
tags: | |
- "v*.*.*" | |
# 以下是推送到 main 分支时触发 | |
# push: | |
# branches: | |
# - 'master' | |
jobs: | |
build: | |
# 打包 | |
name: Build distribution 📦 | |
runs-on: ubuntu-latest | |
steps: | |
# clone 仓库 | |
- uses: actions/checkout@v4 | |
# 设置 Python环境和版本 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.x" | |
# 安装 build | |
- name: Install pypa/build | |
run: >- | |
python3 -m | |
pip install | |
build | |
--user | |
# 打包你的项目 | |
- name: Build a binary wheel and a source tarball | |
run: python3 -m build | |
# 将打包得到的文件上传到 artifact | |
- name: Store the distribution packages | |
uses: actions/upload-artifact@v3 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
retention-days: 1 # 1 天后删除 artifact | |
publish-to-pypi: | |
# 上传到 PPyPIypi | |
name: >- | |
Publish Python 🐍 distribution 📦 to PyPI | |
# if: startsWith(github.ref, 'refs/tags/') # 只在推送tag时,才发布到 PyPI | |
needs: | |
- build | |
runs-on: ubuntu-latest | |
environment: | |
name: pypi | |
url: https://pypi.org/p/easylangchain # 将 <package-name> with 改成你自己的项目名字 | |
permissions: | |
id-token: write # IMPORTANT: mandatory for trusted publishing | |
steps: | |
# 从 artifact 下载打包的文件 | |
- name: Download all the dists | |
uses: actions/download-artifact@v3 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
# 通过 pypa/gh-action-pypi-publish 这个 action 发布到 PyPI | |
- name: Publish distribution 📦 to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 |