标记,构建和上传python库 [英] Tagging, and building and uploading a python library

查看:75
本文介绍了标记,构建和上传python库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个github动作,当分支合并到master时运行.它应该使用从setup.py获得的版本号标记该存储库,然后按下该标记.然后,它应该构建软件包并将其上传到软件包存储库.

I have a github action that runs when a branch is merged into master. It should tag the repo with a version number that it obtains from setup.py, and then push the tag. It should then build the package and upload it to a package repository.

到目前为止的进展:构建和上传作品有效,但标记无效

Progress so far: Building and uploading works, tagging does not

name: Deploy Library



on [push]



jobs:

  build:

    runs-on: ubuntu latest

    steps:

    - uses: actions/checkout@master

    - name: Set up Python env

       uses: actions/setup-python@v1

         with:

           python-version: '3.6'

    - name: Install Deps

    run: |

      python -m pip install --upgrade pip

      pip install wheel

      pip install twine

    - name: Build

       run: |

         python setup.py build bdist_wheel

    - name: Tag

       env:

         GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

        run: |

          VERSION=*sed magic on setup.py*

          git tag v$VERSION

          git push origin v$VERSION

除了末尾的git push之外,其他所有方法都起作用.日志抱怨需要用户名和密码(我只有GITHUB_TOKEN),无论如何,操作/结帐都没有抱怨...

Everything works except for the git push at the end. The logs complain about the need for a username and password (I only have the GITHUB_TOKEN), and anyway, actions/checkout didn't complain...

我已经检查了github操作页面,但找不到与标记相关的页面.

I've checked the github actions page, and I can't find one relating to tagging.

推荐答案

actions/checkout@v1操作使git存储库处于分离的HEAD状态.因此,要推回存储库,需要执行一些步骤.

The actions/checkout@v1 action leaves the git repository in a detached HEAD state. So in order to push back to the repository there are a few steps required.

为要成为提交作者的用户设置git config:

Set git config for the user you want to be the commit author:

git config --global user.name 'My User'
git config --global user.email 'myuser@example.com'

设置遥控器:

git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/username/repository

您可能还需要结帐.您可以从GITHUB_REF中提取分支名称:

You may also need to checkout. You can extract the branch name from the GITHUB_REF:

git checkout "${GITHUB_REF:11}"

相关问题和答案:

  • Push to origin from GitHub action
  • Unable to commit and push back changes made by github action (invalid user)

这篇关于标记,构建和上传python库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆