V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
black11black
V2EX  ›  Python

Python , Github 上传仓库的代码有办法自动同步到 pypi 吗 ?

  •  
  •   black11black · 2020-02-06 21:05:34 +08:00 · 3613 次点击
    这是一个创建于 1532 天前的主题,其中的信息可能已经有所发展或是发生改变。

    如题,我觉得 pypi 是个挺好的包管理器,每次新换到一台机器上不用安装任何其他工具都能直接拉取想要的代码,都感觉很爽。

    最近遇到一个问题是我更新 repo 肯定是在 github 做的,但代码每次都需要手动再同步到 pypi 一份,非常麻烦,除非我不想保持最新了。请问各位带佬有什么方案能自动让 gh 同步到 pypi 吗 ?感觉上应该是需要一些自动测试服务自动运行一些上传代码?没了解过这方面,求问。

    如果能每次 commit 都自动更新版本号就更好了...

    9 条回复    2020-02-09 10:58:43 +08:00
    malusama
        1
    malusama  
       2020-02-06 21:28:33 +08:00
    actions
    locoz
        2
    locoz  
       2020-02-06 22:29:37 +08:00 via Android
    各种 cicd 工具了解一下,就是个自动发布的事嘛
    black11black
        3
    black11black  
    OP
       2020-02-07 02:45:50 +08:00
    @locoz
    感谢,研究了一下 travis 感觉很好用

    顺便,有办法能自动更新版本号吗?
    locoz
        4
    locoz  
       2020-02-07 02:56:58 +08:00
    @black11black #3 一般会有个自增的环境变量,或者是可以自己写脚本实现自增
    msg7086
        5
    msg7086  
       2020-02-07 06:43:29 +08:00
    版本号可以通过计算历史提交数来实现。

    参考: https://github.com/msg7086/x265-Yuuki-Asuna/blob/Yuuki/source/version.rb
    tikazyq
        7
    tikazyq  
       2020-02-07 10:25:42 +08:00
    actions
    ihciah
        8
    ihciah  
       2020-02-07 17:27:58 +08:00
    版本可以用 git tag 管理。
    yucongo
        9
    yucongo  
       2020-02-09 10:58:43 +08:00
    - name: Build Python package
    run: |
    pip install wheel twine; python setup.py sdist bdist_wheel
    - name: Twine check
    run: |
    twine check dist/*
    - name: Publish to PyPI
    env:
    TWINE_USERNAME: ${{ secrets.PYPI_USER }}
    TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
    run: |
    twine upload dist/* --skip-existing

    github action workflow 供你参考
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3686 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 00:12 · PVG 08:12 · LAX 17:12 · JFK 20:12
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.