title: Upload to pypi from Gitlab Pipelines
body: <p>I'm trying to upload a package to pypi using a Gitlab CI job, but I cannot make it work :/ Anyone has a working example?</p>
  
  <p>What I have tried so far in my <code>.gitlab-ci.yaml</code> (from my local machine all of them are working):</p>
  
  <ol>
  <li><p>Twine with a <code>.pypirc</code> file</p>
  
  <pre><code>- echo "[distutils]" &gt;&gt; ~/.pypirc
  - echo "index-servers =" &gt;&gt; ~/.pypirc
  - echo "    pypi" &gt;&gt; ~/.pypirc
  - echo "" &gt;&gt; ~/.pypirc
  - echo "[pypi]" &gt;&gt; ~/.pypirc
  - 'echo "repository: https://upload.pypi.org/legacy/" &gt;&gt; ~/.pypirc'
  - 'echo "username: ${PYPI_USER}" &gt;&gt; ~/.pypirc'
  - 'echo "password: ${PYPI_PASSWORD}" &gt;&gt; ~/.pypirc'
  - python3 setup.py check sdist bdist  # This will fail if your creds are bad.
  - cat ~/.pypirc
  - twine upload dist/* --config-file ~/.pypirc
  </code></pre></li>
  <li><p>Same as before but with <code>$VARIABLE</code></p>
  
  <pre><code>[...]
  - 'echo "username: $PYPI_USER" &gt;&gt; ~/.pypirc'
  - 'echo "password: $PYPI_PASSWORD" &gt;&gt; ~/.pypirc'
  [...]
  </code></pre></li>
  <li><p>Two options before but using <code>python setup.py ... upload</code></p></li>
  <li><code>twine upload dist/* -u $PYPI_USER -p $PYPI_PASSWORD</code></li>
  <li><code>twine upload dist/*</code> wiht <code>TWINE_USERNAME</code> and <code>TWINE_PASSWORD</code> environment variables.</li>
  </ol>
  
  <p>... and always get a <code>403 Client Error: Invalid or non-existent authentication information</code>. I'm running out of options...</p>