Skip to content

Commit

Permalink
fix(core): add optional fraction and status
Browse files Browse the repository at this point in the history
  • Loading branch information
Vacxe committed Apr 10, 2024
1 parent a3e7bbe commit 0761a55
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 25 deletions.
6 changes: 4 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ inputs:
changes-not-sent-for-review:
description: 'Do not send changes for review'
required: false
default: 'false'
status:
description: 'The status of a release'
required: false
default: 'draft'
user-fraction:
description: 'Fraction of users who are eligible to receive the release. 0 < fraction < 1. To be set, release status must be "inProgress" or "halted".'
required: false

runs:
using: 'docker'
Expand All @@ -58,3 +59,4 @@ runs:
- ${{ inputs.path-to-mapping }}
- ${{ inputs.changes-not-sent-for-review }}
- ${{ inputs.status }}
- ${{ inputs.user-fraction }}
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.1
FROM ghcr.io/vacxe/google-play-cli:0.4.2

COPY entrypoint.sh /entrypoint.sh
COPY templates /templates
Expand Down
5 changes: 3 additions & 2 deletions github-action/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ PATH_TO_MAPPING=${9}

FLAG_CHANGES_NOT_SENT_FOR_REVIEW=${10}
STATUS=${11}
USER_FRACTION=${12}

echo "Play console version:"
google-play-cli version
Expand All @@ -44,15 +45,15 @@ 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" "$STATUS"
sh /templates/apk-upload.sh "$SERVICE_ACCOUNT_JSON" "$PACKAGE_NAME" "$PATH_TO_APK" "$VERSION_CODE" "$TRACK" "$FLAG_CHANGES_NOT_SENT_FOR_REVIEW" "$STATUS" "$USER_FRACTION"
;;

"bundles-upload")
checkParameter "Package name" "$PACKAGE_NAME"
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" "$STATUS"
sh /templates/bundles-upload.sh "$SERVICE_ACCOUNT_JSON" "$PACKAGE_NAME" "$PATH_TO_BUNDLE" "$VERSION_CODE" "$TRACK" "$FLAG_CHANGES_NOT_SENT_FOR_REVIEW" "$STATUS" "$USER_FRACTION"
;;

"deobfuscation-files-upload")
Expand Down
10 changes: 8 additions & 2 deletions github-action/templates/apk-upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ VERSION_CODE=$4
TRACK=$5
FLAG_CHANGES_NOT_SENT_FOR_REVIEW=$6
STATUS="${7}"
USER_FRACTION=${8}

echo "---"
echo "Package name: $PACKAGE_NAME"
echo "Path to apk: $PATH_TO_APK"
echo "Version code: $VERSION_CODE"
echo "Track: $TRACK"
echo "Status: $STATUS"
echo "User fraction: $USER_FRACTION"
echo "Changes not sent for review: $FLAG_CHANGES_NOT_SENT_FOR_REVIEW"
echo "---"

Expand All @@ -26,8 +29,11 @@ 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" --status "$STATUS"
google-play-cli tracks update --edit-id "$EDIT_ID" --track "$TRACK" --apk-version-code "$VERSION_CODE" --track "$TRACK" \
${USER_FRACTION:+ --user-fraction "$USER_FRACTION"} \
${STATUS:+ --status "$STATUS"}
echo "Validate..."
google-play-cli edit validate --edit-id "$EDIT_ID"
echo "Commit..."
google-play-cli edit commit --edit-id "$EDIT_ID" --changes-not-sent-for-review "$FLAG_CHANGES_NOT_SENT_FOR_REVIEW"
google-play-cli edit commit --edit-id "$EDIT_ID" \
${FLAG_CHANGES_NOT_SENT_FOR_REVIEW:+ --changes-not-sent-for-review "$FLAG_CHANGES_NOT_SENT_FOR_REVIEW"}
10 changes: 8 additions & 2 deletions github-action/templates/bundles-upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ VERSION_CODE="${4}"
TRACK="${5}"
FLAG_CHANGES_NOT_SENT_FOR_REVIEW="${6}"
STATUS="${7}"
USER_FRACTION=${8}

export PLAYSTORE_SERVICE_ACCOUNT_JSON_CONTENT="$SERVICE_ACCOUNT_JSON"
export APP_PACKAGE_NAME="$PACKAGE_NAME"
Expand All @@ -18,6 +19,8 @@ echo "Package name: $PACKAGE_NAME"
echo "Path to bundle: $PATH_TO_BUNDLE"
echo "Version code: $VERSION_CODE"
echo "Track: $TRACK"
echo "Status: $STATUS"
echo "User fraction: $USER_FRACTION"
echo "Changes not sent for review: $FLAG_CHANGES_NOT_SENT_FOR_REVIEW"
echo "---"

Expand All @@ -26,8 +29,11 @@ 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" --status "$STATUS"
google-play-cli tracks update --edit-id "$EDIT_ID" --package-name "$PACKAGE_NAME" --apk-version-code "$VERSION_CODE" --track "$TRACK" \
${USER_FRACTION:+ --user-fraction "$USER_FRACTION"} \
${STATUS:+ --status "$STATUS"}
echo "Validate..."
google-play-cli edit validate --edit-id "$EDIT_ID" --package-name "$PACKAGE_NAME"
echo "Commit..."
google-play-cli edit commit --edit-id "$EDIT_ID" --package-name "$PACKAGE_NAME" --changes-not-sent-for-review "$FLAG_CHANGES_NOT_SENT_FOR_REVIEW"
google-play-cli edit commit --edit-id "$EDIT_ID" --package-name "$PACKAGE_NAME" \
${FLAG_CHANGES_NOT_SENT_FOR_REVIEW:+ --changes-not-sent-for-review "$FLAG_CHANGES_NOT_SENT_FOR_REVIEW"}
3 changes: 2 additions & 1 deletion github-action/templates/deobfuscation-files-upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ google-play-cli deobfuscation-files upload --edit-id "$EDIT_ID" --package-name "
echo "Validate..."
google-play-cli edit validate --edit-id "$EDIT_ID" --package-name "$PACKAGE_NAME"
echo "Commit..."
google-play-cli edit commit --edit-id "$EDIT_ID" --package-name "$PACKAGE_NAME" --changes-not-sent-for-review "$FLAG_CHANGES_NOT_SENT_FOR_REVIEW"
google-play-cli edit commit --edit-id "$EDIT_ID" --package-name "$PACKAGE_NAME" \
${FLAG_CHANGES_NOT_SENT_FOR_REVIEW:+ --changes-not-sent-for-review "$FLAG_CHANGES_NOT_SENT_FOR_REVIEW"}
20 changes: 10 additions & 10 deletions src/main/kotlin/com/github/vacxe/googleplaycli/Commands.kt
Original file line number Diff line number Diff line change
Expand Up @@ -609,17 +609,17 @@ object Commands {
"-v",
help = "The version code of the APK whose will be promoted to the track"
).int().required()
private val userFraction: Double by option(
private val userFraction: Double? by option(
"--user-fraction",
"-f",
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)
).double()

private val status: String by option(
private val status: String? by option(
"--status",
"-s",
help = ""
).choice("statusUnspecified", "draft", "inProgress", "halted", "completed").default("draft")
help = "The status of a release"
).choice("statusUnspecified", "draft", "inProgress", "halted", "completed")

override fun run(api: PlayStoreApi) =
api.tracksPatch(
Expand All @@ -645,17 +645,17 @@ object Commands {
"-v",
help = "The version code of the APK whose will be promoted to the track"
).int().required()
private val userFraction: Double by option(
private val userFraction: Double? by option(
"--user-fraction",
"-f",
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)
).double()

private val status: String by option(
private val status: String? by option(
"--status",
"-s",
help = ""
).choice("statusUnspecified", "draft", "inProgress", "halted", "completed").default("draft")
help = "The status of a release"
).choice("statusUnspecified", "draft", "inProgress", "halted", "completed")

override fun run(api: PlayStoreApi) = api.tracksUpdate(
TracksUpdateModel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ fun main(args: Array<String>) {
addCmd {
object : CliktCommand(name = "version", help = "Library version code") {
override fun run() {
println("0.4.1")
println("0.4.2")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class TracksPatchModel(val packageName: String,
val editId: String?,
val track: String,
val apkVersionCode: Int,
val userFraction: Double,
val status: String,
val userFraction: Double?,
val status: String?,
requestParameters: String?
): RequestModel(requestParameters)
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class TracksUpdateModel(
val editId: String?,
val track: String,
val apkVersionCode: Int,
val userFraction: Double,
val status: String,
val userFraction: Double?,
val status: String?,
requestParameters: String?
) : RequestModel(requestParameters)

0 comments on commit 0761a55

Please sign in to comment.