python自动版本不能使用github操作进行

发布于 2025-01-28 12:07:55 字数 2521 浏览 1 评论 0 原文

我有一个自动化的github操作工作流程,该工作流程应该使用发行标签的版本构建并上传到PYPI。

但是,无论标签如何,动作都以0.0.0版本构建包装 (

?构建文件:

GA Workflow

name: Upload Python Package

on:
  release:
    types: [published]

jobs:
  deploy:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Set up Python
      uses: actions/setup-python@v2
      with:
        python-version: '3.x'
    - 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@27b31702a0e7fc50959f5ad993c78deac1bdfc29
      with:
        user: __token__
        password: ${{ secrets.PYPI_API_TOKEN }}

Setup.py

import setuptools

if __name__ == "__main__":
    setuptools.setup()

Setup.cfg



[metadata]
name = pyenergydiagram
author = Remi Delaporte-Mathurin
author_email = [email protected]
description = Plot potential energy diagram in python
long_description = file: README.md
long_description_content_type = text/markdown
url = https://github.com/RemDelaporteMathurin/pyEnergyDiagram
license = MIT
license_file = LICENSE
classifiers =
    Natural Language :: English
    Topic :: Scientific/Engineering
    Programming Language :: Python :: 3
    Programming Language :: Python :: 3.6
    Programming Language :: Python :: 3.7
    Programming Language :: Python :: 3.8
    Programming Language :: Python :: 3.9
    License :: OSI Approved :: MIT License
    Operating System :: OS Independent
project_urls =
    Source = https://github.com/RemDelaporteMathurin/pyEnergyDiagram
    Tracker = https://github.com/RemDelaporteMathurin/pyEnergyDiagram/issues

[options]
packages = find:
python_requires= >=3.6
install_requires =
    numpy >= 1.22
    matplotlib >= 3.5.1
    scipy >= 1.8

[options.extras_require]
tests = 
    pytest >= 5.4.3

Project.toml

[build-system]
requires = [
    "setuptools >= 45",
    "wheel",
    "setuptools_scm[toml] >= 6.2",
    "setuptools_scm_git_archive",
]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
write_to = "pyenergydiagram/_version.py"

提前感谢您的帮助!

I have an automated Github Actions workflow that is supposed to build and upload to pypi with the version of the release tag.

However, regardless of the tag, the action builds the packge with version 0.0.0
(see the run)

Below are the build files:

GA workflow

name: Upload Python Package

on:
  release:
    types: [published]

jobs:
  deploy:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Set up Python
      uses: actions/setup-python@v2
      with:
        python-version: '3.x'
    - 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@27b31702a0e7fc50959f5ad993c78deac1bdfc29
      with:
        user: __token__
        password: ${{ secrets.PYPI_API_TOKEN }}

setup.py

import setuptools

if __name__ == "__main__":
    setuptools.setup()

setup.cfg



[metadata]
name = pyenergydiagram
author = Remi Delaporte-Mathurin
author_email = [email protected]
description = Plot potential energy diagram in python
long_description = file: README.md
long_description_content_type = text/markdown
url = https://github.com/RemDelaporteMathurin/pyEnergyDiagram
license = MIT
license_file = LICENSE
classifiers =
    Natural Language :: English
    Topic :: Scientific/Engineering
    Programming Language :: Python :: 3
    Programming Language :: Python :: 3.6
    Programming Language :: Python :: 3.7
    Programming Language :: Python :: 3.8
    Programming Language :: Python :: 3.9
    License :: OSI Approved :: MIT License
    Operating System :: OS Independent
project_urls =
    Source = https://github.com/RemDelaporteMathurin/pyEnergyDiagram
    Tracker = https://github.com/RemDelaporteMathurin/pyEnergyDiagram/issues

[options]
packages = find:
python_requires= >=3.6
install_requires =
    numpy >= 1.22
    matplotlib >= 3.5.1
    scipy >= 1.8

[options.extras_require]
tests = 
    pytest >= 5.4.3

project.toml

[build-system]
requires = [
    "setuptools >= 45",
    "wheel",
    "setuptools_scm[toml] >= 6.2",
    "setuptools_scm_git_archive",
]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
write_to = "pyenergydiagram/_version.py"

Thanks in advance for the help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

孤寂小茶 2025-02-04 12:07:56

我对此很陌生,但基于本文:

可能更改设置

if __name__ == "__main__":
    setuptools.setup(version={{VERSION_PLACEHOLDER}})

- name: Extract tag name
        id: tag
        run: echo ::set-output name=TAG_NAME::$(echo $GITHUB_REF | cut -d / -f 3)

- name: Update version in setup.py
        run: >-
          sed -i "s/{{VERSION_PLACEHOLDER}}/${{ steps.tag.outputs.TAG_NAME }}/g" setup.py

I am pretty new to this, but based on this article:
https://medium.com/@VersuS_/automate-pypi-releases-with-github-actions-4c5a9cfe947d

Potentially changing your setup.py to include:

if __name__ == "__main__":
    setuptools.setup(version={{VERSION_PLACEHOLDER}})

and then editing your GA to include:

- name: Extract tag name
        id: tag
        run: echo ::set-output name=TAG_NAME::$(echo $GITHUB_REF | cut -d / -f 3)

- name: Update version in setup.py
        run: >-
          sed -i "s/{{VERSION_PLACEHOLDER}}/${{ steps.tag.outputs.TAG_NAME }}/g" setup.py

Hope that helps!

踏月而来 2025-02-04 12:07:56

该文件应为“ pyproject.toml”非“ project.toml”。因此,这并没有被行动所困扰。

The file should be name "pyproject.toml" not "project.toml". Therefore it wasn't caught up by the actions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文