0

我正在尝试使用 Github Actions 将我的 Python 项目打包为 .deb 推送。我正在使用 dh-virtualenv。我已经在本地对其进行了测试,它工作正常,但我在操作工作流程方面遇到了麻烦。据我所知,问题在于 Action 运行器没有读取与 .gitignore 文件匹配的一些源目录和构建目录。我收到以下错误:

dpkg-source: info: using options from my-package/debian/source/options: --tar-ignore --tar-ignore=.coverage --tar-ignore=.tox --tar-ignore=.venv --tar-ignore=bin --tar-ignore=docs/_build --tar-ignore=*.log --tar-ignore=*.egg-info
 debian/rules clean
test ! -d dist || rm -rf dist
test ! -d debian/my-package-0.1.6 || rm -rf debian/my-package-0.1.6
dh clean --setuptools --builtin-venv --python=/usr/bin/python3 --upgrade-pip --preinstall "setuptools>=38" --preinstall "wheel" --extra-pip-arg=--progress-bar=pretty --buildsystem=pybuild
   dh_auto_clean -O--setuptools -O--builtin-venv -O--python=/usr/bin/python3 -O--upgrade-pip -O--preinstall=setuptools\>=38 -O--preinstall=wheel -O--extra-pip-arg=--progress-bar=pretty -O--buildsystem=pybuild
I: pybuild base:217: python3.8 setup.py clean 
running clean
removing '/home/runner/work/my-package/my-package/.pybuild/cpython3_3.8/build' (and everything under it)
'build/bdist.linux-x86_64' does not exist -- can't clean it
'build/scripts-3.8' does not exist -- can't clean it
   dh_clean -O--setuptools -O--builtin-venv -O--python=/usr/bin/python3 -O--upgrade-pip -O--preinstall=setuptools\>=38 -O--preinstall=wheel -O--extra-pip-arg=--progress-bar=pretty -O--buildsystem=pybuild
 debian/rules build
dh build --with python-virtualenv --sourcedir debian/my-package-0.1.6 --buildsystem=pybuild
   dh_update_autotools_config -O--sourcedir=debian/my-package-0.1.6 -O--buildsystem=pybuild
   dh_auto_configure -O--sourcedir=debian/my-package-0.1.6 -O--buildsystem=pybuild
dh_auto_configure: error: invalid or non-existing path to the source directory: debian/my-package-0.1.6
make: *** [debian/rules:43: build] Error 25
dpkg-buildpackage: error: debian/rules build subprocess returned exit status 2
Error: Process completed with exit code 2.

该命令能够在 repo 中找到与 .gitignore 不匹配的所有其他文件。此外,当在我的本地机器上运行相同的进程时,所有源目录都被创建并找到并且没有错误。

我的 Actions 工作流 yml 文件如下所示:

  build-deb:
    name: Build deb package
    runs-on: ubuntu-latest
    steps:
    - name: Checkout code
      uses: actions/checkout@master
    - name: Disable .gitignore for build
      run: |
        sudo rm ./.gitignore
        sudo rm ./debian/.gitignore
        sudo find . -name ".gitignore" -delete
    - name: Prepare dh venv
      run: |
        sudo add-apt-repository ppa:jyrki-pulliainen/dh-virtualenv
        sudo apt-get update
        sudo apt-get install dh-virtualenv build-essential debhelper devscripts equivs
    - name: Install Build Dependencies    
      run: |
        sudo mk-build-deps --install debian/control
    - name: Build .deb package
      run: sudo dpkg-buildpackage -uc -us -b
    - name: Upload artifact
      uses: actions/upload-artifact@v2
      with:
        name: deb
        path: ../*.deb

如您所见,我尝试在签出代码后删除 .gitignore 文件,但这不起作用。我不想真正从存储库中删除 .gitignore 文件,因为我不希望所有构建工件都成为源代码的一部分。我在这里缺少什么吗?有没有人成功做到这一点?

4

0 回答 0