Continuous Deploy no Android

Continuous Deploy no Android

2bf14ad96e09ea7eda4973795ce70fa6?s=128

Júlio Zynger

April 12, 2016
Tweet

Transcript

  1. Continuous Deploy no Android Júlio Zynger

  2. Deploy Contínuo?

  3. None
  4. http://bit.ly/cd_codeship

  5. http://bit.ly/cd_codeship

  6. http://bit.ly/cd_codeship

  7. None
  8. None
  9. None
  10. Configuração do console

  11. Google Developer Console Habilitar a Google Play Android Developer API

    * * crie um projeto no developer console se já não houver um com APIs configuradas * painel Visão Geral do console https://console.developers.google.com/apis
  12. Google Developer Console Obtendo a service account key * painel

    Credenciais do console https://console.developers.google.com/apis
  13. Google Developer Console JSON da chave https://console.developers.google.com/apis

  14. Google Developer Console JSON da chave https://console.developers.google.com/apis

  15. Google Developer Console secret.pem * https://console.developers.google.com/apis * substituição de \n

    por nova linha
  16. Google Play Store Console Vincular o acesso à API https://play.google.com/apps/publish

  17. Google Play Store Console Adicionar conta de serviço https://play.google.com/apps/publish *

    vincule o email do campo client_email no JSON da chave
  18. None
  19. O Android Publisher

  20. Google Play Developer API * • Subscriptions and In-App Purchases

    API ◦ In-App Products ◦ Status de produtos comprados ◦ Produtos recorrentes e subscriptions • Publishing API ◦ Criação e modificação dos Listings de seu app ◦ Upload de novas versões do APK ◦ Atribuição de APKs às Tracks do Google Play (alpha, beta, staged rollout e produção) * Limite de 200 mil requisições por dia
  21. developers.google.com/android-publisher/api-ref/

  22. Configurando a dependência Download da biblioteca compile 'com.google.apis:google-api-services-androidpublisher:v2-rev30- 1.22.0' http://bit.ly/androidpublisher_maven

    https://developers.google.com/android-publisher/#publishing
  23. Configurando a dependência Instanciando o GoogleCredential NetHttpTransport http = GoogleNetHttpTransport.newTrustedTransport();

    JacksonFactory json = JacksonFactory.getDefaultInstance(); Set<String> scopes = Collections.singleton(AndroidPublisherScopes.ANDROIDPUBLISHER); File secretFile = new File(Constants.SECRET_FILE_PATH); GoogleCredential credential = new GoogleCredential.Builder(). setTransport(http). setJsonFactory(json). setServiceAccountPrivateKeyId(Constants.KEY_ID). setServiceAccountId(Constants.SERVICE_ACCOUNT_EMAIL). setServiceAccountScopes(scopes). setServiceAccountPrivateKeyFromPemFile(secretFile). build(); https://developers.google.com/android-publisher/#publishing
  24. Configurando a dependência Instanciando o GoogleCredential NetHttpTransport http = GoogleNetHttpTransport.newTrustedTransport();

    JacksonFactory json = JacksonFactory.getDefaultInstance(); Set<String> scopes = Collections.singleton(AndroidPublisherScopes.ANDROIDPUBLISHER); File secretFile = new File(Constants.SECRET_FILE_PATH); GoogleCredential credential = new GoogleCredential.Builder(). setTransport(http). setJsonFactory(json). setServiceAccountPrivateKeyId(Constants.KEY_ID). setServiceAccountId(Constants.SERVICE_ACCOUNT_EMAIL). setServiceAccountScopes(scopes). setServiceAccountPrivateKeyFromPemFile(secretFile). build(); https://developers.google.com/android-publisher/#publishing setServiceAccountPrivateKeyId(Constants.KEY_ID). setServiceAccountId(Constants.SERVICE_ACCOUNT_EMAIL). setServiceAccountPrivateKeyFromPemFile(secretFile). private_key_id client_email private_key (.pem)
  25. Configurando a dependência Instanciando o AndroidPublisher NetHttpTransport http = GoogleNetHttpTransport.newTrustedTransport();

    JacksonFactory json = JacksonFactory.getDefaultInstance(); GoogleCredential credential = ... AndroidPublisher publisher = new AndroidPublisher.Builder(http, json, credential). setApplicationName(PACKAGE). build(); https://developers.google.com/android-publisher/#publishing
  26. Configurando a dependência AppEdits AndroidPublisher publisher = ... Edits edits

    = publisher.edits(); // insert, get, delete AppEdit appEdit = edits.insert(PACKAGE, null).execute(); String transactionId = appEdit.getId(); ... ... https://developers.google.com/android-publisher/#publishing
  27. Configurando a dependência AppEdits - validate e commit AndroidPublisher publisher

    = ... Edits edits = publisher.edits(); // insert, get, delete AppEdit appEdit = edits.insert(PACKAGE, null).execute(); String transactionId = appEdit.getId(); ... ... edits.validate(PACKAGE, transactionId).execute(); edits.commit(PACKAGE, transactionId).execute(); https://developers.google.com/android-publisher/#publishing
  28. Configurando a dependência AppEdits - validate e commit AndroidPublisher publisher

    = ... Edits edits = publisher.edits(); // insert, get, delete AppEdit appEdit = edits.insert(PACKAGE, null).execute(); String transactionId = appEdit.getId(); ... ... edits.validate(PACKAGE, transactionId).execute(); edits.commit(PACKAGE, transactionId).execute(); https://developers.google.com/android-publisher/#publishing { "code" : 403, "errors" : [ { "domain" : "androidpublisher", "message" : "The full description for the app is too long for language en-US.", "reason" : "fullDescriptionTooLong" } ], "message" : "The full description for the app is too long for language en-US." }
  29. Configurando a dependência AppEdits - Listings Edits edits = publisher.edits();

    Listings listings = edits.listings(); ListingsListResponse listingsListResponse = listings.list(PACKAGE, transactionId).execute(); // Selecionar o Listing que vai ser atualizado Listing listing = listingsListResponse.getListings().get(...) listing.setFullDescription(description); listings.update(PACKAGE, transactionId, language, listing).execute(); // ... validate // ... commit https://developers.google.com/android-publisher/#publishing
  30. Configurando a dependência AppEdits - Listings Edits edits = publisher.edits();

    Listings listings = edits.listings(); ListingsListResponse listingsListResponse = listings.list(PACKAGE, transactionId).execute(); // Selecionar o Listing que vai ser atualizado Listing listing = listingsListResponse.getListings().get(...) listing.setFullDescription(description); listings.update(PACKAGE, transactionId, language, listing).execute(); // ... validate // ... commit https://developers.google.com/android-publisher/#publishing { "fullDescription" : "This app is a simple demo application for developers who are interested in continuous deploy in the android platform.", "language" : "en-US", "shortDescription" : "Demo application for developers", "title" : "Continuous Deploy Demo App", "video" : "" }
  31. Configurando a dependência AppEdits - upload do APK Apks apks

    = edits.apks(); FileContent apkContent = new FileContent(APK_MIME_TYPE, apkFile); Apk apk = apks.upload(PACKAGE, transactionId, apkContent).execute(); int version = apk.getVersionCode(); https://developers.google.com/android-publisher/#publishing
  32. Configurando a dependência AppEdits - Tracks Apks apks = edits.apks();

    FileContent apkContent = new FileContent(APK_MIME_TYPE, apkFile); Apk apk = apks.upload(PACKAGE, transactionId, apkContent).execute(); int version = apk.getVersionCode(); Tracks tracks = edits.tracks(); List<Integer> versions = Collections.singletonList(version); Track track = new Track().setVersionCodes(versions); tracks.update(PACKAGE, transactionId, trackId, track).execute(); https://developers.google.com/android-publisher/#publishing
  33. Configurando a dependência AppEdits - Tracks Apks apks = edits.apks();

    FileContent apkContent = new FileContent(APK_MIME_TYPE, apkFile); Apk apk = apks.upload(PACKAGE, transactionId, apkContent).execute(); int version = apk.getVersionCode(); Tracks tracks = edits.tracks(); List<Integer> versions = Collections.singletonList(version); Track track = new Track().setVersionCodes(versions); tracks.update(PACKAGE, transactionId, trackId, track).execute(); https://developers.google.com/android-publisher/#publishing “alpha”, “beta”, “rollout” (com userFraction), “production”
  34. Configurando a dependência AppEdits - APKListings Apks apks = edits.apks();

    FileContent apkContent = new FileContent(APK_MIME_TYPE, apkFile); Apk apk = apks.upload(PACKAGE, transactionId, apkContent).execute(); int version = apk.getVersionCode(); Tracks tracks = edits.tracks(); List<Integer> versions = Collections.singletonList(version); Track track = new Track().setVersionCodes(versions); tracks.update(PACKAGE, transactionId, trackId, track).execute(); Apklistings apklistings = edits.apklistings(); ApkListing whatsnew = new ApkListing().setRecentChanges(whatsNewDescription); apklistings.update(PACKAGE, transactionId, version, language, whatsnew).execute(); https://developers.google.com/android-publisher/#publishing
  35. Continuous Delivery De um git push para produção bit.ly/googlepublisher_jenkins bit.ly/googlepublisher_gradle

  36. Continuous Delivery De um git push para produção bit.ly/googlepublisher_jenkins bit.ly/googlepublisher_gradle

  37. Demo!

  38. https://github.com/julioz/continuousdeploydemo

  39. http://bit.ly/android-continuous-deploy-post

  40. Perguntas?