diff --git a/action.yml b/action.yml index 9a4849b..0530a08 100644 --- a/action.yml +++ b/action.yml @@ -38,6 +38,10 @@ inputs: description: 'Do not send changes for review' required: false default: 'false' + status: + description: 'The status of a release' + required: false + default: 'draft' runs: using: 'docker' @@ -53,3 +57,4 @@ runs: - ${{ inputs.path-to-bundle }} - ${{ inputs.path-to-mapping }} - ${{ inputs.changes-not-sent-for-review }} + - ${{ inputs.status }} diff --git a/github-action/Dockerfile b/github-action/Dockerfile index 2d1c762..6f4c132 100644 --- a/github-action/Dockerfile +++ b/github-action/Dockerfile @@ -1,4 +1,4 @@ -FROM ghcr.io/vacxe/google-play-cli:0.4.0 +FROM ghcr.io/vacxe/google-play-cli:0.4.1 COPY entrypoint.sh /entrypoint.sh COPY templates /templates diff --git a/github-action/entrypoint.sh b/github-action/entrypoint.sh index 7e9ebe8..2d30448 100644 --- a/github-action/entrypoint.sh +++ b/github-action/entrypoint.sh @@ -25,6 +25,7 @@ PATH_TO_BUNDLE=${8} PATH_TO_MAPPING=${9} FLAG_CHANGES_NOT_SENT_FOR_REVIEW=${10} +STATUS=${11} echo "Play console version:" google-play-cli version @@ -43,7 +44,7 @@ case $TEMPLATE in checkParameter "Version code" "$VERSION_CODE" checkParameter "Path to apk" "$PATH_TO_APK" - sh /templates/apk-upload.sh "$SERVICE_ACCOUNT_JSON" "$PACKAGE_NAME" "$PATH_TO_APK" "$VERSION_CODE" "$TRACK" "$FLAG_CHANGES_NOT_SENT_FOR_REVIEW" + sh /templates/apk-upload.sh "$SERVICE_ACCOUNT_JSON" "$PACKAGE_NAME" "$PATH_TO_APK" "$VERSION_CODE" "$TRACK" "$FLAG_CHANGES_NOT_SENT_FOR_REVIEW" "$STATUS" ;; "bundles-upload") @@ -51,7 +52,7 @@ case $TEMPLATE in checkParameter "Version code" "$VERSION_CODE" checkParameter "Path to bundle" "$PATH_TO_BUNDLE" - sh /templates/bundles-upload.sh "$SERVICE_ACCOUNT_JSON" "$PACKAGE_NAME" "$PATH_TO_BUNDLE" "$VERSION_CODE" "$TRACK" "$FLAG_CHANGES_NOT_SENT_FOR_REVIEW" + sh /templates/bundles-upload.sh "$SERVICE_ACCOUNT_JSON" "$PACKAGE_NAME" "$PATH_TO_BUNDLE" "$VERSION_CODE" "$TRACK" "$FLAG_CHANGES_NOT_SENT_FOR_REVIEW" "$STATUS" ;; "deobfuscation-files-upload") diff --git a/github-action/templates/apk-upload.sh b/github-action/templates/apk-upload.sh index 6176b72..44db61e 100644 --- a/github-action/templates/apk-upload.sh +++ b/github-action/templates/apk-upload.sh @@ -7,7 +7,8 @@ PACKAGE_NAME=$2 PATH_TO_APK=$3 VERSION_CODE=$4 TRACK=$5 -FLAG_CHANGES_NOT_SENT_FOR_REVIEW=$5 +FLAG_CHANGES_NOT_SENT_FOR_REVIEW=$6 +STATUS="${7}" echo "---" echo "Package name: $PACKAGE_NAME" @@ -25,7 +26,7 @@ echo "Edit id created: $EDIT_ID" echo "Upload APK..." google-play-cli apk upload --config-content "$SERVICE_ACCOUNT_JSON" --edit-id "$EDIT_ID" --apk "$PATH_TO_APK" echo "Update track..." -google-play-cli tracks update --edit-id "$EDIT_ID" --track "$TRACK" --apk-version-code "$VERSION_CODE" +google-play-cli tracks update --edit-id "$EDIT_ID" --track "$TRACK" --apk-version-code "$VERSION_CODE" --status "$STATUS" echo "Validate..." google-play-cli edit validate --edit-id "$EDIT_ID" echo "Commit..." diff --git a/github-action/templates/bundles-upload.sh b/github-action/templates/bundles-upload.sh index 4b3b4fd..3476be4 100644 --- a/github-action/templates/bundles-upload.sh +++ b/github-action/templates/bundles-upload.sh @@ -8,6 +8,7 @@ PATH_TO_BUNDLE="${3}" VERSION_CODE="${4}" TRACK="${5}" FLAG_CHANGES_NOT_SENT_FOR_REVIEW="${6}" +STATUS="${7}" export PLAYSTORE_SERVICE_ACCOUNT_JSON_CONTENT="$SERVICE_ACCOUNT_JSON" export APP_PACKAGE_NAME="$PACKAGE_NAME" @@ -25,7 +26,7 @@ echo "Edit id created: $EDIT_ID" echo "Upload Bundle..." google-play-cli bundles upload --edit-id "$EDIT_ID" --package-name "$PACKAGE_NAME" --bundle "$PATH_TO_BUNDLE" echo "Update track..." -google-play-cli tracks update --edit-id "$EDIT_ID" --package-name "$PACKAGE_NAME" --track "$TRACK" --apk-version-code "$VERSION_CODE" +google-play-cli tracks update --edit-id "$EDIT_ID" --package-name "$PACKAGE_NAME" --track "$TRACK" --apk-version-code "$VERSION_CODE" --status "$STATUS" echo "Validate..." google-play-cli edit validate --edit-id "$EDIT_ID" --package-name "$PACKAGE_NAME" echo "Commit..." diff --git a/src/main/kotlin/com/github/vacxe/googleplaycli/Commands.kt b/src/main/kotlin/com/github/vacxe/googleplaycli/Commands.kt index b917c67..8463fde 100644 --- a/src/main/kotlin/com/github/vacxe/googleplaycli/Commands.kt +++ b/src/main/kotlin/com/github/vacxe/googleplaycli/Commands.kt @@ -615,8 +615,24 @@ object Commands { help = "Fraction of users who are eligible to receive the release. 0 < fraction < 1. To be set, release status must be \"inProgress\" or \"halted\"." ).double().default(1.0) + private val status: String by option( + "--status", + "-s", + help = "" + ).choice("statusUnspecified", "draft", "inProgress", "halted", "completed").default("draft") + override fun run(api: PlayStoreApi) = - api.tracksPatch(TracksPatchModel(packageName, editId, track, apkVersionCode, userFraction, parameters)) + api.tracksPatch( + TracksPatchModel( + packageName, + editId, + track, + apkVersionCode, + userFraction, + status, + parameters + ) + ) } class Update : EditCommand( @@ -635,6 +651,12 @@ object Commands { help = "Fraction of users who are eligible to receive the release. 0 < fraction < 1. To be set, release status must be \"inProgress\" or \"halted\"." ).double().default(1.0) + private val status: String by option( + "--status", + "-s", + help = "" + ).choice("statusUnspecified", "draft", "inProgress", "halted", "completed").default("draft") + override fun run(api: PlayStoreApi) = api.tracksUpdate( TracksUpdateModel( packageName, @@ -642,6 +664,7 @@ object Commands { track, apkVersionCode, userFraction, + status, parameters ) ) diff --git a/src/main/kotlin/com/github/vacxe/googleplaycli/PlayStoreCli.kt b/src/main/kotlin/com/github/vacxe/googleplaycli/PlayStoreCli.kt index b48a1c7..32ce3fb 100644 --- a/src/main/kotlin/com/github/vacxe/googleplaycli/PlayStoreCli.kt +++ b/src/main/kotlin/com/github/vacxe/googleplaycli/PlayStoreCli.kt @@ -86,7 +86,7 @@ fun main(args: Array) { addCmd { object : CliktCommand(name = "version", help = "Library version code") { override fun run() { - println("0.4.0") + println("0.4.1") } } } diff --git a/src/main/kotlin/com/github/vacxe/googleplaycli/actions/Tracks.kt b/src/main/kotlin/com/github/vacxe/googleplaycli/actions/Tracks.kt index dff63a0..04c04ce 100644 --- a/src/main/kotlin/com/github/vacxe/googleplaycli/actions/Tracks.kt +++ b/src/main/kotlin/com/github/vacxe/googleplaycli/actions/Tracks.kt @@ -42,6 +42,7 @@ interface Tracks : BaseAction { listOf(TrackRelease().apply { versionCodes = mutableListOf(model.apkVersionCode.toLong()) userFraction = model.userFraction + status = model.status }) ) return edits @@ -57,9 +58,11 @@ interface Tracks : BaseAction { val edits: AndroidPublisher.Edits = androidPublisher.edits() val editId = model.editId ?: edits.insert(model.packageName, null).execute().id - val release = TrackRelease() - .setVersionCodes(listOf(model.apkVersionCode.toLong())) - .setStatus("completed") + val release = TrackRelease().apply { + versionCodes = mutableListOf(model.apkVersionCode.toLong()) + userFraction = model.userFraction + status = model.status + } val track = Track().setReleases(listOf(release)) diff --git a/src/main/kotlin/com/github/vacxe/googleplaycli/actions/model/TracksPatchModel.kt b/src/main/kotlin/com/github/vacxe/googleplaycli/actions/model/TracksPatchModel.kt index 9a03d91..0c1a7f1 100644 --- a/src/main/kotlin/com/github/vacxe/googleplaycli/actions/model/TracksPatchModel.kt +++ b/src/main/kotlin/com/github/vacxe/googleplaycli/actions/model/TracksPatchModel.kt @@ -5,5 +5,6 @@ class TracksPatchModel(val packageName: String, val track: String, val apkVersionCode: Int, val userFraction: Double, + val status: String, requestParameters: String? ): RequestModel(requestParameters) \ No newline at end of file diff --git a/src/main/kotlin/com/github/vacxe/googleplaycli/actions/model/TracksUpdateModel.kt b/src/main/kotlin/com/github/vacxe/googleplaycli/actions/model/TracksUpdateModel.kt index ec15569..1f7c98b 100644 --- a/src/main/kotlin/com/github/vacxe/googleplaycli/actions/model/TracksUpdateModel.kt +++ b/src/main/kotlin/com/github/vacxe/googleplaycli/actions/model/TracksUpdateModel.kt @@ -6,5 +6,6 @@ class TracksUpdateModel( val track: String, val apkVersionCode: Int, val userFraction: Double, + val status: String, requestParameters: String? ) : RequestModel(requestParameters) \ No newline at end of file