Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keystore & password #34

Closed
Haelle opened this issue Feb 5, 2020 · 17 comments
Closed

Keystore & password #34

Haelle opened this issue Feb 5, 2020 · 17 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@Haelle
Copy link

Haelle commented Feb 5, 2020

Is there a way to pass the keystore file in the parameters ? And also the password ? (using github secrets)

Should it be in the customParameters ?

@webbertakken
Copy link
Member

@Haelle thanks for your request!

I do not know your current context. Could you tell us a bit more about what you are trying to do? Links to official documentation of related tools would be very helpful too.

Technically you could pass anything in customParameters but it depends on the build method what happens to it.

What would be your suggested approach or desired API?

@Haelle
Copy link
Author

Haelle commented Feb 6, 2020

To deploy to the Google PlayStore you need to sign your application. It's done with a keystore.

In Unity you can then set your keystore in the Publishing menu.

And everytime you want to build your app you need to provide the password of the keystore via the Editor actually.

So for instance via Unity Cloud build you can provide in their web interface the keystore and the password (cannot show sorry). Here is the info in the FAQ section Android, 2rd question

I've never worked with the command line tool, so currently I have no idea how you're doing the command line build... I suppose there is a way to sign the app (as Unity Cloud Build does it !)

@marco-perin
Copy link

Looking at here, the GabLeRoux unity3d library lets you specify the keystore by binary64 formatting it and putting it in a repos' secret variable

@dabo248
Copy link

dabo248 commented Mar 2, 2020

@Haelle did you find a solution for this?

@webbertakken
Copy link
Member

Feel free to open a PR with your suggested approach. You're free to make any additions to the builder method, as long as it's usable for everyone.

@Haelle
Copy link
Author

Haelle commented Mar 3, 2020

This is in pending on my side, I'll come back to it later

@webbertakken webbertakken added enhancement New feature or request help wanted Extra attention is needed labels Jun 2, 2020
@webbertakken
Copy link
Member

@Haelle did you work this out? Anything we can reuse for everyone?

@Haelle
Copy link
Author

Haelle commented Jun 3, 2020

No sorry CI is postponed indefinitely for the moment

@davidmfinol
Copy link
Member

Added these parameters: androidAppBundle, androidKeystoreName, androidKeystoreBase64, androidKeystorePass, androidKeyaliasName, androidKeyaliasPass

I tested with my personal project, but maybe someone else can test with their project to confirm?
You would pass through GitHub Secrets in your workflow like this:

      - uses: webbertakken/unity-builder@6ece6447b229baedca54df3aae22fc3d097bc4f3
        with:
          unityVersion: ${{ matrix.unityVersion }}
          targetPlatform: ${{ matrix.targetPlatform }}
          buildsPath: builds
          androidAppBundle: true
          androidKeystoreName: keystore.keystore
          androidKeystoreBase64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
          androidKeystorePass: ${{ secrets.ANDROID_KEYSTORE_PASS }}
          androidKeyaliasName: ${{ secrets.ANDROID_KEYALIAS_NAME }}
          androidKeyaliasPass: ${{ secrets.ANDROID_KEYALIAS_PASS }}

@louis030195
Copy link

louis030195 commented Oct 7, 2020

@davidmfinol did you successfully built & sign android?
I had working Android build then added the android signing options in order to publish to Google Play and it fails:

UnityException: Can not sign the application
Unable to sign the application; please provide passwords!

https://github.com/louis030195/niwrad/runs/1221825955?check_suite_focus=true#step:4:3197

However i properly set my secrets etc.

Run webbertakken/[email protected]
with:
customParameters: -niwradMode offline
projectPath: .
unityVersion: 2019.4.11f1
targetPlatform: Android
buildMethod: Editor.Builds.BuildOptions
androidAppBundle: true
androidKeystoreName: ***.keystore
androidKeystoreBase64: ***
androidKeystorePass: ***
androidKeyaliasName: ***
androidKeyaliasPass: ***
buildsPath: builds
kubeContainerMemory: 800M
kubeContainerCPU: 0.25
kubeVolumeSize: 5Gi
versioning: Semantic
env:
UNITY_LICENSE: ***

https://github.com/louis030195/niwrad/runs/1221825955?check_suite_focus=true#step:4:1

What is actually "androidKeystoreName" ? Since you store the b64 keystore in your secrets ...

I generated my keys using unity IDE btw (first tried CLI but better trust Unity ...)

FYI my Android build config

image

learned that you can't do arm64 with Mono, so IL2CPP has to be used and target API should be >=29 to publish to Google Play.

@davidmfinol
Copy link
Member

I had working Android builds, but they've been broken for a while now, since the Android images don't have the Android NDK properly set. Are you able to get past that error?

The androidKeystoreName is the name of the file, while androidKeystoreBase64 is the contents of that file, encoded in base64.

Your workflow looks good to me. Are you applying the passwords in your Editor.Builds.BuildOptions method?
If not, see https://github.com/finol-digital/Card-Game-Simulator/blob/e3d90591b5df4b0b4be9dc64a913da5084eeedad/Assets/Scripts/Cgs/Editor/BuildCgs.cs#L35 for how it can be done.

@louis030195
Copy link

I had working Android builds, but they've been broken for a while now, since the Android images don't have the Android NDK properly set. Are you able to get past that error?

The androidKeystoreName is the name of the file, while androidKeystoreBase64 is the contents of that file, encoded in base64.

Your workflow looks good to me. Are you applying the passwords in your Editor.Builds.BuildOptions method?
If not, see https://github.com/finol-digital/Card-Game-Simulator/blob/e3d90591b5df4b0b4be9dc64a913da5084eeedad/Assets/Scripts/Cgs/Editor/BuildCgs.cs#L35 for how it can be done.

I don't understand "The androidKeystoreName is the name of the file", you don't commit any keystore file anywhere, it's just base64 content ? What file are you referring to ?

I think this doc is much nicer, I hope something similar would be put on the unity-ci website https://gitlab.com/gableroux/unity3d-gitlab-ci-example#android-support
Thanks for the build options, now I'm stuck at the same point as you : Android NDK, would be nice to automatically use an image with android ndk whenever it's required (building .aab ?).
Also wondering how it works for the api levels if the image can build for any sdk version ?

@webbertakken
Copy link
Member

This is the PR that indended to do that (until i renamed master to main). It's a work in progress by @GabLeRoux

Feel free to contribute and help out.

Could you also elaborate on what's nicer about it exactly? Perhaps we could learn from that.

@GabLeRoux
Copy link
Member

Also curious on that, but I happen to have gone through the unity-ci docs for github-actions today and I think that the main difference is the approach.

Right now, github-actions documentation provides parts of code that you need to assemble on your own to get things working where on unity3d-gitlab-ci-example's side, you simply grab the files, add them to your project and follow activation steps.

I think this can be easily solved by providing working files out of the box in the documentation and then do the more modular explanation on how things work and how they can customize it for people who want to go deeper.

I'd say most of the use cases are the following:

  1. I want automatic builds for my game for my platforms, ie; windows, linux, mac, webgl, ios, android
  2. I want to run tests in the cloud for edit and play mode
  3. If I have code coverage out of the box without efforts, why not. (replace code coverage with wathever feature we may have an example for that is easy to integrate).

Everything else is probably secondary.

@webbertakken
Copy link
Member

Yea fully agree! Anyone is free to edit the docs or describe feature requests here.

I see you've already created one issue regarding improvements game-ci/documentation#46 @GabLeRoux, thanks!

@davidmfinol
Copy link
Member

Since keystore & password are supported now, do we want to close this issue?

Or do we want to keep this issue open until the documentation is improved?

@webbertakken
Copy link
Member

Yea lets close it. Anyone is free to add to the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

7 participants