Skip to content

Commit

Permalink
update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Vacxe committed Apr 11, 2024
1 parent e71718d commit 86b4991
Show file tree
Hide file tree
Showing 8 changed files with 217 additions and 114 deletions.
168 changes: 87 additions & 81 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,115 +1,121 @@
# Google play CLI
CLI tool for publish and management application in Google Play Console.
Transparent CLI tooling for managing Google Play Console.

Actually this library is CLI wrapper for [Google Play Java library](https://developers.google.com/android-publisher/api-ref)
## Table of Contents

List of all vailable commands in [wiki](https://github.com/Vacxe/google-play-cli/wiki/Google-Play-CLI) *WIP*
- [Introduction](#introduction)
- [Installation](#installation)
- [Homebrew](#homebrew)
- [Docker](#docker)
- [GitHub Actions](#github-action)
- [How to use CLI](#how-to-use-cli-directly)

### How to use
* Before at all you should obtain a `serviceAccount.json`
This library is transparent CLI wrapper for official [Google Play Java Library](https://developers.google.com/android-publisher/api-ref)

Goto: Google Play Console -> Developer Account -> Api access -> Service Accounts -> CREATE SERVICE ACCOUNT
Follow the instruction and grant the access for service accout
* Try simplest command
* ```google-play-cli --help``` - list of all commands
* ```google-play-cli apk list --config-file service_account.json --package-name <your uploaded apk package name>```

* Apk info extraction

Install [Apk info extractor](https://github.com/Vacxe/apk-info-extractor) and JQ `apkinfoextractor <pathtoApk> | jq '.package'`

* How to upload apk
Bash function can be copied to any .sh file and used as `uploadapk "path/to/my.apk" "path/to/service_account.json"`

```
function uploadapk(){
path_to_apk=$1
export PLAYSTORE_SERVICE_ACCOUNT_JSON_FILE=$2
#If proxy needed
#PLAYSTORE_PROXY=192.168.0.1:3128
#Increase connection timeout
#PLAYSTORE_CONNECTION_TIMEOUT=PT6M
apk_package=$(apkinfoextractor $path_to_apk | jq '.package')
export APP_PACKAGE_NAME=$apk_package
apk_version_code=$(apkinfoextractor $path_to_apk | jq '.versionCode')
## Introduction

edit_id=$(google-play-cli edit create)
google-play-cli apk upload --edit-id $edit_id --apk $path_to_apk
google-play-cli tracks update --edit-id $edit_id --track "internal" --apk-version-code $apk_version_code
google-play-cli edit validate --edit-id $edit_id
google-play-cli edit commit --edit-id $edit_id
Previous libs what been used for application deployment contained disadvantages what blocked me from application delivery. As well, all libraries contains internal logic for uploading, but will be nice hot have some more **transparent** solution.
* [Gradle Triple-T Plugin](https://github.com/Triple-T/gradle-play-publisher)
* Integration with build system - Distribution should not be a part of build system. Its blocking us to create a reusable chains on CI. If project is huge, it will create a lot of overhead with evaluation project.
* Not flexible enough - suitable only for Apk/Bundle upload
* [r0adkll/sign-android-release](https://github.com/r0adkll/sign-android-release)
* Not flexible enough - suitable only for Apk/Bundle upload

unset APP_PACKAGE_NAME
unset PLAYSTORE_SERVICE_ACCOUNT_JSON_FILE
}
```
**Advantages of this project**
* Core: Transparent CLI wrapper for Official Google Play Console library
* Can be installed on host directly as CLI (via brew or binaries) or can be used via Docker or GitHub actions. You are able to test it locally before deployment.
* Docker: Transparent environment for CLI, as well JQ for easier Json response management in case of custom actions
* GitHub Action: Transparent wrapper for Docker, with amount of custom *templates* to simplify day to day actions like upload apk

On CI you can add service account json file as a secret to environment variable
## Installation

``
PLAYSTORE_SERVICE_ACCOUNT_JSON_CONTENT
``

# How to install

## Homebrew
### Homebrew

```
brew tap vacxe/tap
brew install vacxe/tap/googleplaycli
```

## [Docker](https://github.com/Vacxe/google-play-cli-kt/pkgs/container/google-play-cli)
### [Docker](https://github.com/Vacxe/google-play-cli-kt/pkgs/container/google-play-cli)

```
ghcr.io/vacxe/google-play-cli:<VERSION>
```

## [GitHub Action](https://github.com/marketplace/actions/google-play-console)
### [GitHub Action](https://github.com/marketplace/actions/google-play-console)

*Note: replace `@master` with latest version for stable behaviour or leave it for last updates*
[GitHub Action](https://github.com/marketplace/actions/google-play-console) `vacxe/google-play-cli-kt` is transparent wrapper over [Docker](https://github.com/Vacxe/google-play-cli-kt/pkgs/container/google-play-cli) `google-play-cli-kt`, what contains transparent CLI warapper for [Google Play Java Library](https://developers.google.com/android-publisher/api-ref). It can provide for you possibility to write any custom scripts in depends on you needs or use one of **[Available templates](#github-action/README.md)**.

Bundle upload example
*Example of APK uploading template:*
```yaml
- uses: vacxe/google-play-cli-kt@master
with:
template: bundles-upload
service-account-json: ${{ secrets.SERVICE_ACCOUNT_JSON }}
version-code: ${{ github.run_number }} # You may need to know version code
package-name: <package name>
path-to-bundle: <path to bundle>
track: internal
status: draft
- uses: vacxe/google-play-cli-kt@master
with:
template: apk-upload
service-account-json: ${{ secrets.SERVICE_ACCOUNT_JSON }}
version-code: ${{ github.run_number }}
package-name: <package name>
path-to-apk: <path to apk>
track: internal
status: draft
```
APK upload example
```yaml
- uses: vacxe/google-play-cli-kt@master
with:
template: apk-upload
service-account-json: ${{ secrets.SERVICE_ACCOUNT_JSON }}
version-code: ${{ github.run_number }} # You may need to know version code
package-name: <package name>
path-to-apk: <path to apk>
track: internal
status: draft
## How to use CLI directly
* Before you started you should obtain a `serviceAccount.json`

Goto: Google Play Console -> Developer Account -> Api access -> Service Accounts -> CREATE SERVICE ACCOUNT
Follow the instruction and grant the access for service account
* Try basic command
* ```google-play-cli --help``` - list of all commands
* ```google-play-cli apk list --config-file service_account.json --package-name <your uploaded apk package name>```

Example how to upload apk with step by step explanation:

* Let configure few environment variables first, what will make our next CLI calls much easier
```shell
# If proxy needed
#PLAYSTORE_PROXY=192.168.0.1:3128
# Increase connection timeout
#PLAYSTORE_CONNECTION_TIMEOUT=PT6M
export PLAYSTORE_SERVICE_ACCOUNT_JSON_FILE="/path/to/service_account.json"
# Or set a plain text
#export PLAYSTORE_SERVICE_ACCOUNT_JSON_CONTENT="CONTENT OF JSON"
export APP_PACKAGE_NAME="com.my.package"
```

Custom script example
Exporting is not required, but if you will not decide to do it you may need to add for each command
* `--config-file "/path/to/service_account.json"`
* or `--config-content "CONTENT OF JSON"`
* `--package-name "com.my.package"`

```yaml
- uses: vacxe/google-play-cli-kt@master
with:
custom-script: "Any direct calls for google-play-cli"
*Tip: On CI you can add service account json file as a secret to environment variable*

---

* First of all you may need to create **edit_id**
```shell
edit_id=$(google-play-cli edit create)
```
* With existing `edit_id` you can do any modifications in Play Console, let's upload APK
```shell
google-play-cli apk upload --edit-id $edit_id --apk "path/to/my.apk"
```
* APK been uploaded, we need to assign it to `track`. Let choice `internal` track and status will be `draft`, as well we need to know version code (for example `42`)
```shell
google-play-cli tracks update --edit-id $edit_id --track "internal" --status "draft" --version-code "42"
```
* As a non-required step you can validate your edit at any time
```shell
google-play-cli edit validate --edit-id $edit_id
```
* And as last step - commit your changes
```shell
google-play-cli edit commit --edit-id $edit_id
```

``````
## License

License
-------

Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 1 addition & 1 deletion github-action/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ghcr.io/vacxe/google-play-cli:0.4.2
FROM ghcr.io/vacxe/google-play-cli:0.4.3

COPY entrypoint.sh /entrypoint.sh
COPY templates /templates
Expand Down
97 changes: 97 additions & 0 deletions github-action/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Google play CLI (GitHub Actions)

## Requirements
Any GitHub Action `vacxe/google-play-cli-kt` required two parameters to be set
* `service-account-json` - Plain text Service Account JSON, can be stored and provided via `secrets`

*Example: `service-account-json: ${{ secrets.SERVICE_ACCOUNT_JSON }}`*
* `package-name` - package name for target application

*Example: `com.my.application`*

## Custom Script
[GitHub Action](https://github.com/marketplace/actions/google-play-console) `vacxe/google-play-cli-kt` is transparent wrapper over [Docker](https://github.com/Vacxe/google-play-cli-kt/pkgs/container/google-play-cli) `google-play-cli-kt`, what contains transparent CLI warapper for [Google Play Java Library](https://developers.google.com/android-publisher/api-ref). It can provide for you possibility to write any custom scripts in depends on you needs.

*Example: Request all bundles*

```yaml
- uses: vacxe/google-play-cli-kt@master
with:
service-account-json: ${{ secrets.SERVICE_ACCOUNT_JSON }}
package-name: my.package.name
custom-script: 'google-play-cli bundles list | jq'
```
However, most of the cases is actually repeatable for many projects. You can take a look on *Templates* or **contribute** to it.
## Templates
- [Apk](#apk)
- [Upload](#upload)
- [Bundles](#bundles)
- [Upload](#upload-1)
- [Deobfuscation Files](#deobfuscation-files)
- [Upload](#upload-2)
*Note: replace `@master` with latest version for stable behaviour or leave it for last updates*

## Apk
### Upload
* `path-to-apk` - Path to APK file
* `version-code` - Integer version code of Apk
* `track` - Target track
* `changes-not-sent-for-review` - Do not send changes for review
* `status` - The status of a release
* `user-fraction` - Fraction of users who are eligible to receive the release. 0 < fraction < 1. To be set, release status must be "inProgress" or "halted".

*Example:*
```yaml
- uses: vacxe/google-play-cli-kt@master
with:
template: apk-upload
service-account-json: ${{ secrets.SERVICE_ACCOUNT_JSON }}
package-name: <package name>
version-code: ${{ github.run_number }}
path-to-apk: <path to apk>
track: internal
status: draft
```

## Bundles
### Upload
* `path-to-bundle` - Path to Bundle file
* `version-code` - Integer version code of Bundle
* `track` - Target track
* `changes-not-sent-for-review` - Do not send changes for review
* `status` - The status of a release
* `user-fraction` - Fraction of users who are eligible to receive the release. 0 < fraction < 1. To be set, release status must be "inProgress" or "halted".

*Example:*
```yaml
- uses: vacxe/google-play-cli-kt@master
with:
template: bundles-upload
service-account-json: ${{ secrets.SERVICE_ACCOUNT_JSON }}
package-name: <package name>
version-code: ${{ github.run_number }}
path-to-bundle: <path to bundle>
track: internal
status: draft
```

## Deobfuscation Files
### Upload
* `path-to-mapping` - Path to Mapping file
* `version-code` - Integer version code of assigned Apk or Bundle
* `changes-not-sent-for-review` - Do not send changes for review

*Example:*
```yaml
- uses: vacxe/google-play-cli-kt@master
with:
template: deobfuscation-files-upload
service-account-json: ${{ secrets.SERVICE_ACCOUNT_JSON }}
package-name: <package name>
path-to-mapping: <path to mapping file>
version-code: ${{ github.run_number }}
```
2 changes: 1 addition & 1 deletion github-action/templates/apk-upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ echo "Edit id created: $EDIT_ID"
echo "Upload APK..."
google-play-cli apk upload --edit-id "$EDIT_ID" --apk "$PATH_TO_APK"
echo "Update track..."
google-play-cli tracks update --edit-id "$EDIT_ID" --apk-version-code "$VERSION_CODE" --track "$TRACK" \
google-play-cli tracks update --edit-id "$EDIT_ID" --version-code "$VERSION_CODE" --track "$TRACK" \
${USER_FRACTION:+ --user-fraction "$USER_FRACTION"} \
${STATUS:+ --status "$STATUS"}
echo "Validate..."
Expand Down
2 changes: 1 addition & 1 deletion github-action/templates/bundles-upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ echo "Edit id created: $EDIT_ID"
echo "Upload Bundle..."
google-play-cli bundles upload --edit-id "$EDIT_ID" --bundle "$PATH_TO_BUNDLE"
echo "Update track..."
google-play-cli tracks update --edit-id "$EDIT_ID" --apk-version-code "$VERSION_CODE" --track "$TRACK" \
google-play-cli tracks update --edit-id "$EDIT_ID" --version-code "$VERSION_CODE" --track "$TRACK" \
${USER_FRACTION:+ --user-fraction "$USER_FRACTION"} \
${STATUS:+ --status "$STATUS"}
echo "Validate..."
Expand Down
2 changes: 1 addition & 1 deletion github-action/templates/deobfuscation-files-upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ echo "---"
EDIT_ID=$(google-play-cli edit create)
echo "Edit id created: $EDIT_ID"
echo "Upload deobfuscation files..."
google-play-cli deobfuscation-files upload --edit-id "$EDIT_ID" --deobfuscation "$PATH_TO_MAPPING" --apk-version-code "$VERSION_CODE"
google-play-cli deobfuscation-files upload --edit-id "$EDIT_ID" --deobfuscation "$PATH_TO_MAPPING" --version-code "$VERSION_CODE"
echo "Validate..."
google-play-cli edit validate --edit-id "$EDIT_ID" || true # Ignore until changes-not-sent-for-review will be added as parameter
echo "Commit..."
Expand Down
Loading

0 comments on commit 86b4991

Please sign in to comment.