Skip to content

Commit

Permalink
#15 Support of publishType API param
Browse files Browse the repository at this point in the history
  • Loading branch information
cosic committed Oct 13, 2024
1 parent 29e805f commit cc9846d
Show file tree
Hide file tree
Showing 16 changed files with 89 additions and 52 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
# 0.5.1

##### Add
* [issue#15](https://github.com/cianru/rustore-publish-gradle-plugin/issues/15) Support of `publishType` param.
```groovy
/**
* (Optional)
* CLI: `--publishType`
* ----| 'instantly' – the application will be published immediately after the review process is completed.
* ----| 'manual' – the application must be published manually by the developer after ther review process is completed.
* Gradle Extenion DSL, available values:
* ----| ru.cian.rustore.publish.PublishType.INSTANTLY
* ----| ru.cian.rustore.publish.PublishType.MANUAL
* Default value: `instantly`
*/
publishType = ru.cian.rustore.publish.PublishType.INSTANTLY
```

# 0.5.0

##### Add
Expand Down
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
</h1>
</p>

![Version](https://img.shields.io/badge/GradlePortal-0.5.0-green.svg)
![Version](https://img.shields.io/badge/Gradle-8.*-pink.svg)
[//]: # (![Version]&#40;https://img.shields.io/badge/GradlePortal-0.5.0-green.svg&#41;)
<img src="https://img.shields.io/maven-metadata/v.svg?label=Gradle%20Plugins%20Portal&metadataUrl=https%3A%2F%2Fplugins.gradle.org%2Fm2%2Fru%2Fcian%2Frustore-publish-gradle-plugin%2Fru.cian.rustore-publish-gradle-plugin.gradle.plugin%2Fmaven-metadata.xml" />
[![License](https://img.shields.io/github/license/srs/gradle-node-plugin.svg)](http://www.apache.org/licenses/LICENSE-2.0.html)

The plugin use [Rustore API](https://help.rustore.ru/rustore/for_developers/work_with_RuStore_API/publish_RuStore_API) to publish Android build file to the [RuStore](https://rustore.ru).
Expand Down Expand Up @@ -215,13 +215,25 @@ rustorePublish {
* CLI: `--mobileServicesType`
* ----| 'Unknown'
* ----| 'HMS'
* Gradle Extention DSL, available values:
* Gradle Extension DSL, available values:
* ----| ru.cian.rustore.publish.MobileServicesType.UNKNOWN
* ----| ru.cian.rustore.publish.MobileServicesType.HMS
* Default value: `Unknown`
*/
mobileServicesType = ru.cian.rustore.publish.MobileServicesType.UNKNOWN

/**
* (Optional)
* CLI: `--publishType`
* ----| 'instantly' – the application will be published immediately after the review process is completed.
* ----| 'manual' – the application must be published manually by the developer after ther review process is completed.
* Gradle Extenion DSL, available values:
* ----| ru.cian.rustore.publish.PublishType.INSTANTLY
* ----| ru.cian.rustore.publish.PublishType.MANUAL
* Default value: `instantly`
*/
publishType = ru.cian.rustore.publish.PublishType.INSTANTLY

/**
* (Optional)
* Release Notes settings. For mote info see ReleaseNote param desc.
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ kotlin = "1.9.23"
detekt = "1.23.4"
junitJupiter = "5.9.3"
androidGradlePlugin = "8.0.2"
sampleRustorePlugin = "0.5.0-alpha02"
sampleRustorePlugin = "0.5.1-alpha01"

[libraries]
appcompat = "androidx.appcompat:appcompat:1.6.1"
Expand Down
2 changes: 1 addition & 1 deletion plugin/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android.enableJetifier=true
####################################################################################################

GROUP_ID=ru.cian.rustore-plugin
VERSION_NAME=0.5.0
VERSION_NAME=0.5.1-alpha02

POM_ARTIFACT_ID=rustore-publish-gradle-plugin
POM_NAME=Rustore Publish Gradle Plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import java.io.File

internal data class PluginConfig(
val credentials: Credentials,
val deployType: DeployType,
val publishType: PublishType,
val artifactFormat: BuildFormat,
val requestTimeout: Long?,
val mobileServicesType: MobileServicesType,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package ru.cian.rustore.publish

internal data class RustorePublishCli(
val deployType: DeployType? = null,
val publishType: PublishType? = null,
val credentialsPath: String? = null,
val keyId: String? = null,
val clientSecret: String? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class RustorePublishExtensionConfig(
* var param by GradleProperty(project, String::class.java)
*/
var credentialsPath: String? = null
var deployType = DeployType.PUBLISH
var publishType = PublishType.INSTANTLY
var requestTimeout: Long? = null
var mobileServicesType: MobileServicesType = MobileServicesType.UNKNOWN
var buildFormat: BuildFormat = BuildFormat.APK
Expand All @@ -52,7 +52,7 @@ class RustorePublishExtensionConfig(
return "RustorePublishExtensionConfig(" +
"name='$name', " +
"credentialsPath='$credentialsPath', " +
"deployType='$deployType', " +
"deployType='$publishType', " +
"requestTimeout='$requestTimeout', " +
"mobileServicesType='$mobileServicesType', " +
"buildFormat='$buildFormat', " +
Expand Down Expand Up @@ -111,19 +111,19 @@ enum class MobileServicesType(val value: String) {
UNKNOWN("Unknown"),
}

enum class DeployType {
enum class PublishType {
/**
* Deploy without draft saving and submit on users;
* Manual publication. After review you should publish it manually;
*/
UPLOAD_ONLY,
MANUAL,

/**
* Deploy and save as draft without submit on users;
* Automatically publish on all users after reviewing store approve;
*/
DRAFT,
INSTANTLY,

/**
* Deploy, save as draft and submit build on users;
* Delayed publication. You should set publishDateTime;
*/
PUBLISH,
// DELAYED, // FIXME: Implement delayed publication after adding of `publishDateTime` API param;
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,6 @@ open class RustorePublishTask

private val logger by lazy { Logger(project) }

@get:Internal
@set:Option(
option = "deployType",
description = "How to deploy build: 'publish' to all users or create 'draft' " +
"without publishing or 'upload-only' without draft creation"
)
var deployType: DeployType? = null

@get:Internal
@set:Option(
option = "credentialsPath",
Expand Down Expand Up @@ -126,6 +118,13 @@ open class RustorePublishTask
)
var releaseNotes: String? = null

@get:Internal
@set:Option(
option = "publishType",
description = "How to publish build file. Available values: ['manual', 'instantly']."
)
var publishType: PublishType? = null

@get:Internal
@set:Option(option = "apiStub", description = "Use RestAPI stub instead of real RestAPI requests")
var apiStub: Boolean? = false
Expand All @@ -149,7 +148,7 @@ open class RustorePublishTask
)

val cli = RustorePublishCli(
deployType = deployType,
publishType = publishType,
credentialsPath = credentialsPath,
keyId = keyId,
clientSecret = clientSecret,
Expand Down Expand Up @@ -212,6 +211,7 @@ open class RustorePublishTask
token = token,
applicationId = config.applicationId,
whatsNew = config.releaseNotes?.first()?.newFeatures ?: "",
publishType = config.publishType.name,
)

logger.v("5/6. Upload build file '${config.artifactFile}'")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ import com.google.gson.annotations.SerializedName
internal data class AppDraftRequest(
@SerializedName("whatsNew")
val whatsNew: String,
@SerializedName("publishType")
val publishType: String,
)
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ internal interface RustoreService {
token: String,
applicationId: String,
whatsNew: String,
publishType: String,
): Int

@Suppress("LongParameterList")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ internal class RustoreServiceImpl(
token: String,
applicationId: String,
whatsNew: String,
publishType: String,
): Int {
val bodyRequest = AppDraftRequest(
whatsNew = whatsNew,
publishType = publishType,
)

logger.i("""
Expand All @@ -72,7 +74,8 @@ internal class RustoreServiceImpl(
--header 'Content-Type: application/json' \
--header 'Public-Token: $token' \
--data-raw '{
"whatsNew": "$whatsNew"
"whatsNew": "$whatsNew",
"publishType": "$publishType"
}'
""".trimIndent())

Expand Down Expand Up @@ -111,10 +114,11 @@ internal class RustoreServiceImpl(
token = token,
applicationId = applicationId,
whatsNew = whatsNew,
publishType = publishType,
)
}

logger.v("response=$response")
logger.i("response=$response")
return response.body
}

Expand Down Expand Up @@ -180,7 +184,7 @@ internal class RustoreServiceImpl(
headers = headers
)

logger.v("response=$response")
logger.i("response=$response")

check(response.code == "OK") {
"Build file uploading is failed! " +
Expand Down Expand Up @@ -234,7 +238,7 @@ internal class RustoreServiceImpl(
),
)

logger.v("response=$response")
logger.i("response=$response")

return response.code == "OK"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal class ConfigProvider(

val requestTimeout = cli.requestTimeout?.toLongOrNull() ?: extension.requestTimeout
val mobileServicesType = cli.mobileServicesType ?: extension.mobileServicesType
val deployType = cli.deployType ?: extension.deployType
val publishType = cli.publishType ?: extension.publishType
val artifactFormat = cli.buildFormat ?: extension.buildFormat
val customBuildFilePath: String? = cli.buildFile ?: extension.buildFile
val releaseTime: String? = cli.releaseTime ?: extension.releaseTime
Expand All @@ -44,7 +44,7 @@ internal class ConfigProvider(

return PluginConfig(
credentials = credentialsConfig,
deployType = deployType,
publishType = publishType,
requestTimeout = requestTimeout,
mobileServicesType = mobileServicesType,
artifactFormat = actualArtifactFormat,
Expand Down
Loading

0 comments on commit cc9846d

Please sign in to comment.