Skip to content
This repository has been archived by the owner on Jun 23, 2023. It is now read-only.

Enrich android play store upload #27

Open
wants to merge 19 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ target
.idea
readyci.iml
.scannerwork
.DS_Store
.DS_Store
9 changes: 7 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.squarepolka</groupId>
<artifactId>readyci</artifactId>
<version>0.6.1</version>
<version>0.6.3</version>

<parent>
<groupId>org.springframework.boot</groupId>
Expand All @@ -21,6 +21,11 @@
</properties>

<dependencies>
<dependency>
<groupId>net.dongliu</groupId>
<artifactId>apk-parser</artifactId>
<version>2.6.5</version>
</dependency>
<!-- Kotlin -->
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
Expand Down Expand Up @@ -136,7 +141,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.1</version>
<version>0.8.3</version>
<configuration>
<destFile>${basedir}/target/coverage-reports/jacoco-unit.exec</destFile>
<dataFile>${basedir}/target/coverage-reports/jacoco-unit.exec</dataFile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ private AndroidPropConstants() {

public static final String BUILD_PROP_SCHEME = "scheme";
public static final String BUILD_PROP_DEPLOY_TRACK = "deployTrack";
public static final String BUILD_PROP_PACKAGE_NAME = "packageName";
public static final String BUILD_PROP_SERVICE_ACCOUNT_FILE = "playStoreAuthCert";
public static final String BUILD_PROP_SERVICE_ACCOUNT_EMAIL = "playStoreEmail";
public static final String BUILD_PROP_JAVA_KEYSTORE_PATH = "javaKeystorePath";
Expand All @@ -19,5 +18,6 @@ private AndroidPropConstants() {
public static final String BUILD_PROP_HOCKEYAPP_TOKEN = "hockappToken";
public static final String BUILD_PROP_HOCKEYAPP_RELEASE_TAGS = "hockeyappReleaseTags";
public static final String BUILD_PROP_HOCKEYAPP_RELEASE_NOTES = "hockeyappReleaseNotes";
public static final String BUILD_PROP_FILENAME_FILTERS = "fileNameFilters";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @timmutton , do you mind adding some documentation for the new fileNameFilters parameter on the Github wiki and example config file?


}
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,20 @@ public List<String> getProperties(String propertyName) {
return values;
}

/**
* Fetch a list of environment properties
* @param propertyName
* @return list of String property values
* @throws PropertyMissingException if the property does not exist
*/
public List<String> getProperties(String propertyName, List<String> defaultValues) {
List<String> values = (List<String>) buildParameters.get(propertyName);
if (null == values || values.isEmpty()) {
return defaultValues;
}
return values;
}

/**
* Fetch a single environment property
* @param propertyName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public void performTask(BuildEnvironment buildEnvironment) throws TaskFailedExce
String scheme = buildEnvironment.getProperty(BUILD_PROP_SCHEME);
String keystorePath = buildEnvironment.getProperty(BUILD_PROP_JAVA_KEYSTORE_PATH);
String storePass = buildEnvironment.getProperty(BUILD_PROP_STOREPASS);

// TODO: these are likely to be incorrect
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to clean this one up before we merge?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be a separate fix, this is just something while i was digging around

String unsignedApkPath = String.format("%s/app/build/outputs/apk/%s/app-%s-unsigned.apk", buildEnvironment.getProjectPath(), scheme.toLowerCase(), scheme.toLowerCase());
String signedApkPath = String.format("%s/app/build/outputs/apk/%s/app-%s.apk", buildEnvironment.getProjectPath(), scheme.toLowerCase(), scheme.toLowerCase());

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package com.squarepolka.readyci.tasks.app.android

import com.squarepolka.readyci.configuration.AndroidPropConstants
import com.squarepolka.readyci.configuration.ReadyCIConfiguration
import com.squarepolka.readyci.taskrunner.BuildEnvironment
import com.squarepolka.readyci.tasks.Task
import com.squarepolka.readyci.tasks.app.android.extensions.isDebuggable
import com.squarepolka.readyci.tasks.app.android.extensions.isSigned
import com.squarepolka.readyci.util.Util
import net.dongliu.apk.parser.ApkFile
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.stereotype.Component

import java.io.File

@Component
class AndroidUploadHockeyapp : Task() {

companion object {
private const val TASK_UPLOAD_HOCKEYAPP = "android_upload_hockeyapp"
}

override fun taskIdentifier(): String = TASK_UPLOAD_HOCKEYAPP

override fun performTask(buildEnvironment: BuildEnvironment) {
val hockappToken = buildEnvironment.getProperty(AndroidPropConstants.BUILD_PROP_HOCKEYAPP_TOKEN)
val releaseTags = buildEnvironment.getProperty(AndroidPropConstants.BUILD_PROP_HOCKEYAPP_RELEASE_TAGS, "")
val releaseNotes = buildEnvironment.getProperty(AndroidPropConstants.BUILD_PROP_HOCKEYAPP_RELEASE_NOTES, "")
val filenameFilters = buildEnvironment.getProperties(AndroidPropConstants.BUILD_PROP_FILENAME_FILTERS,
listOf("zipaligned", "unsigned"))

if(hockappToken == null) {
throw RuntimeException("AndroidUploadStore: Missing vital details for play store deployment:\n- hockappToken is required")
}

val filteredApks = AndroidUtil.findAllApkOutputs(buildEnvironment.projectPath)
.filter { file ->
filenameFilters.none { file.nameWithoutExtension.contains(it) }
}
.map { Pair(it, ApkFile(it)) }
.filter { it.second.isSigned }

when(filteredApks.size) {
0 -> throw RuntimeException("Could not find the signed APK")
1 -> {} // do nothing
else -> throw RuntimeException("There are too many valid APKs that we can upload, please provide a more specific scheme for this pipeline ")
}

val rawFile = filteredApks.first().first

executeCommand(arrayOf("/usr/bin/curl", "https://rink.hockeyapp.net/api/2/apps/upload",
"-H", "X-HockeyAppToken: $hockappToken",
"-F", "ipa=@${rawFile.absolutePath}",
"-F", "notes=$releaseNotes",
"-F", "tags=$releaseTags",
"-F", "notes_type=0", // Textual release notes
"-F", "status=2", // Make this version available for download
"-F", "notify=1", // Notify users who can install the app
"-F", "strategy=add", // Add the build if one with the same build number exists
"-F", "mandatory=1" // Download is mandatory
), buildEnvironment.projectPath)
}
}

This file was deleted.

Loading