# Cannot upload wheel to both PyPI and Github Releases, dist directory empty after PyPI upload

**URL:** https://travis-ci.community/t/cannot-upload-wheel-to-both-pypi-and-github-releases-dist-directory-empty-after-pypi-upload/11006
**Category:** Python
**Tags:** python, github-releases, pypi
**Created:** [January 10, 2021, 4:57pm UTC](https://travis-ci.community/t/cannot-upload-wheel-to-both-pypi-and-github-releases-dist-directory-empty-after-pypi-upload/11006 "2021-01-10T16:57:13Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![afonsoc12](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/afonsoc12/32/6009_2.png) [@afonsoc12](https://travis-ci.community/u/afonsoc12)
#### Post date: [January 10, 2021, 4:57pm UTC](https://travis-ci.community/t/cannot-upload-wheel-to-both-pypi-and-github-releases-dist-directory-empty-after-pypi-upload/11006/1 "2021-01-10T16:57:13Z")

</div>

Hello,

I would like to know how I could release the files published to Pypi to Github releases.

After deploying to pypi, these files should be maintained on the CI server (`dist/reponame-0.0.1.tar.gz` and `dist/reponame-0.0.3-py3-none-any.whl`). However, they are not released to github

```
language: python
python:
  - "3.7"

cache:
  directories:
    - $HOME/.cache/pip

install:
  - echo "========== INSTALL =========="
  - pip install -r requirements.txt
# - pip install flake8

script: 
  - echo "========== TESTING =========="
  - python -m unittest test/test_*.py

before_deploy: echo "========== DEPLOYING =========="

deploy:
  - provider: pypi
    server: https://test.pypi.org/legacy/
    distributions: "sdist bdist_wheel"
    username: " __token__"
    password:
      secure: "pass"
    on:
      branch: master
      tags: true
  
  - provider: releases
    api_key:
      secure: "password"
    file_glob: true
    file: dist/*
    skip_cleanup: true
    on:
      branch: master
      tags: true

after_deploy:
  - ls -alh 
  - ls -alh dist/
  - ls -alh build/

```

I have tried other configurations for file but none work.

What am I missing?

Thanks

---

<div class="post-metadata">

### Author: ![native-api](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/native-api/32/430_2.png) [@native-api](https://travis-ci.community/u/native-api)
#### Post date: [January 10, 2021, 8:31pm UTC](https://travis-ci.community/t/cannot-upload-wheel-to-both-pypi-and-github-releases-dist-directory-empty-after-pypi-upload/11006/2 "2021-01-10T20:31:22Z")

</div>

At first glance, this should work.  
Could you link to a build?

---

<div class="post-metadata">

### Author: ![afonsoc12](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/afonsoc12/32/6009_2.png) [@afonsoc12](https://travis-ci.community/u/afonsoc12)
#### Post date: [January 10, 2021, 9:19pm UTC](https://travis-ci.community/t/cannot-upload-wheel-to-both-pypi-and-github-releases-dist-directory-empty-after-pypi-upload/11006/3 "2021-01-10T21:19:29Z")

</div>

Hello,  
Thank you for looking at this.  
[https://api.travis-ci.com/v3/job/470164732/log.txt?log.token=Ph4RdkTNpyJ12yn2Gi7etg](https://api.travis-ci.com/v3/job/470164732/log.txt?log.token=Ph4RdkTNpyJ12yn2Gi7etg)

It appears that the dist directory is empty. I use skip\_cleanup: true, but I get a warning saying that this is deprecated.

---

<div class="post-metadata">

### Author: ![native-api](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/native-api/32/430_2.png) [@native-api](https://travis-ci.community/u/native-api)
#### Post date: [January 10, 2021, 10:34pm UTC](https://travis-ci.community/t/cannot-upload-wheel-to-both-pypi-and-github-releases-dist-directory-empty-after-pypi-upload/11006/4 "2021-01-10T22:34:51Z")

</div>

> [@afonsoc12](#):
>
> It appears that the dist directory is empty.

It actually is! The PyPI deployment provider creates the distributions from scratch and deletes them right after uploading! [https://github.com/travis-ci/dpl/blob/b577682ac17ff10b7f3fe58c5da1113b05e68cb7/lib/dpl/provider/pypi.rb#L134](https://github.com/travis-ci/dpl/blob/b577682ac17ff10b7f3fe58c5da1113b05e68cb7/lib/dpl/provider/pypi.rb#L134)

You can **use the DPL v2 version of the PyPI provider with `edge: true` and specify [`remove_build_dir: false`](https://docs.travis-ci.com/user/deployment-v2/providers/pypi/)** to prevent that:

```auto
deploy:
- provider: pypi
  edge: true
  remove_build_dir: false
  <...>
- provider: releases
  <...>

```

---

<div class="post-metadata">

### Author: ![afonsoc12](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/afonsoc12/32/6009_2.png) [@afonsoc12](https://travis-ci.community/u/afonsoc12)
#### Post date: [January 11, 2021, 9:37am UTC](https://travis-ci.community/t/cannot-upload-wheel-to-both-pypi-and-github-releases-dist-directory-empty-after-pypi-upload/11006/5 "2021-01-11T09:37:09Z")

</div>

Alright, this worked thanks!

However, I would like to ask you another thing: I would like to only trigger travis for branch master and when the commit is tagged (either only tags are pushed to the commit or not). I dont seem to make this trigger:  
if: branch = master AND tag IS true  
if: branch = master AND tag IS present  
if: branch = master AND tag =~ ^v

I add this to the .travis.yml, right on the beggining after specifying language, but it does not work.

Also, what is travis default? Runs in all branches or just master branch? Thank you

---

<div class="post-metadata">

### Author: ![native-api](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/native-api/32/430_2.png) [@native-api](https://travis-ci.community/u/native-api)
#### Post date: [January 11, 2021, 11:44am UTC](https://travis-ci.community/t/cannot-upload-wheel-to-both-pypi-and-github-releases-dist-directory-empty-after-pypi-upload/11006/6 "2021-01-11T11:44:13Z")

</div>

> [@Only build tags that are on the master branch](https://travis-ci.community/t/only-build-tags-that-are-on-the-master-branch/10081/3):
>
> In a tag build, branch is equal to the tag name so your current condition is false. See [Using `branches:` filter unexpectedly prevents tags from being built, too](https://travis-ci.community/t/using-branches-filter-unexpectedly-prevents-tags-from-being-built-too/9952/2) and [Travis-ci.com pointlessly builds tags](https://travis-ci.community/t/travis-ci-com-pointlessly-builds-tags/8532/6) for why that is. Use OR to build both master and tags: if: branch = master OR tag IS present If you want to additionally check if the tag is on the master branch, you need to do that by hand early in the build: if [[-n $TRAVIS\_TAG]]; then # Travis does a shallow clone by default # so…
