mandeep/Travis-Encrypt

Question: what's alternative to this travis command?

Closed this issue · 6 comments

I need to add encrypt token for deployment on pypi, here is the travis command:

travis encrypt your-api-token --add deploy.password

I failed to install travis client. After read your document, I still don't know how to use this tool. I tried:

travis-encrypt zillionare omicron .travis.yml --deploy

it'll ask me for the password, what is it? Is it the pypi token?

Thanks if you could help.

The password is the password that you would like to encrypt. In this case it's the password to your PyPI login.

If I use token to deploy, is the following command right?

travis-encrypt --token pypi-AgEIcHlwaS...  zillionare omega_jqadaptor .travis.yml

then it'll prompt to input password, then I feed it with my pypi password, finally it fails with log:

Traceback (most recent call last):
  File "/miniconda/lib/python3.8/site-packages/travis/encrypt.py", line 51, in retrieve_public_key
    return response.json()["public_key"]
  File "/miniconda/lib/python3.8/site-packages/requests/models.py", line 898, in json
    return complexjson.loads(self.text, **kwargs)
  File "/miniconda/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/miniconda/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/miniconda/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/miniconda/bin/travis-encrypt", line 8, in <module>
    sys.exit(cli())
  File "/miniconda/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/miniconda/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/miniconda/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/miniconda/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/miniconda/lib/python3.8/site-packages/travis/cli.py", line 111, in cli
    key = retrieve_public_key(
  File "/miniconda/lib/python3.8/site-packages/travis/encrypt.py", line 54, in retrieve_public_key
    raise InvalidCredentialsError(
travis.encrypt.InvalidCredentialsError: Either the username: 'zillionare' or the repository: 'omega_jqadaptor' does not exist. Please enter a valid username or repository name. The username and repository name are both case sensitive.

user name is zillionare, which is my github account. The repo does exist. Why travis.encrpyt says either username of repo does not exist?

ps. my pypi account is different than my github user name. I tried 'zillionare-omega-adaptors-jq' which is my pypi project name, no luck either.

@mandeep , would you please confirm if travis-encrypt still sync with travis updates now? per travis's declaration, they'll retire travis.org at the end of this year, so to encrypt password now, --com option should be add:

travis encrypt your-api-token --add deploy.password --com

I cannot find supporting of "--com" option.

After serveral days trying, I still cannot make it work. Would you please help me on this, what is the alternative command of travis encrypt your-api-token --ad deploy.password --com?

you tool asked for github account and password, which is not mentioned by travis itself, this puzzled me.

Thanks~

Try using the --private flag. It's the same thing as --com

Update:

At last I found another machine wich can install ruby (requires ruby > 2.4), then I can install travis client. Everything works then. But with the experience I got from travis official client, I still failed to get travis-encrypt to work.

I will share my experience with travis official client here, so may help others save couple of days:

  1. install ruby, gems and travis client:
sudo apt-add-repository ppa:brightbox/ruby-ng
# it has to be 2.4 or greater
sudo apt install ruby2.4 ruby2.4-dev
gem install travis
  1. generate a personal token at github, under the account which owns your project. It's at settings > develop settings >Edit personal access token
  2. try login with travis:
travis login --pro -g __token_issued_by_github_
  1. encrypt the pypi issued token:
travis encrypt pypi-Age... --com -r zillionare/cfg4py

if you want the tool write the output into .travis.yml, then you add --add deploy.password.
5. then update your .travis.yml as the following:

deploy:
  provider: pypi
  distribution: sdist bdist_wheel
  skip_existing: true
  skip_cleanup: true
  username: __token__
  password:
    secure: "your_encrpyt_token"

be noticed use token (literally), not your user name of pypi, and use 'username' instead of 'user' as the key

I feel still like to use python travis-encrypt, but I still don't know how to use it:

  1. does this tool need proceed login as travis client too? But no doc to mention this
  2. what does the --token mean? it's a pypi token, or a github token or anything else?
  3. by refer to github project, do you mean something like (owner/project) or just the project name?

$ travis-encrypt --private --deploy zillionare omega_jqadaptor .travis.yml

When it asks you for your password, you type in your PyPI password.