Skip to content

Commit

Permalink
issue152 - Fix CI so it can be required (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
isuPatches committed Dec 26, 2022
1 parent 5c2269f commit 831c378
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 56 deletions.
71 changes: 60 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,68 @@ version: 2.1
orbs:
android: circleci/android@1.0.3

commands:
write-keystore-files:
steps:
- run:
name: Write Wisefy release keystore
command: echo "$WISEFY_RELEASE_KEYSTORE" | base64 --decode > keystores/wisefy-release.jks
- run:
name: Write Wisefy sample release keystore
command: echo "$WISEFY_SAMPLE_RELEASE_KEYSTORE" | base64 --decode > keystores/wisefy-sample-release.jks
import-gpg-key:
steps:
- run:
name: Write Wisefy GPG Key
command: echo -e $GPG_KEY > wisefy-gpg-key.asc
- run:
name: Import GPG Key
command: gpg --import --no-tty --batch --yes wisefy-gpg-key.asc
publish-to-maven-local:
steps:
- run:
name: Publish wisefy:core to Maven Local
command: ./gradlew wisefy:core:publishToMavenLocal
- run:
name: Pulblish wisefy:accesspoints to Maven Local
command: ./gradlew wisefy:accesspoints:publishToMavenLocal
- run:
name: Pulblish wisefy:addnetwork to Maven Local
command: ./gradlew wisefy:addnetwork:publishToMavenLocal
- run:
name: Pulblish wisefy:networkconnection to Maven Local
command: ./gradlew wisefy:networkconnection:publishToMavenLocal
- run:
name: Pulblish wisefy:networkinfo to Maven Local
command: ./gradlew wisefy:networkinfo:publishToMavenLocal
- run:
name: Pulblish wisefy:removenetwork to Maven Local
command: ./gradlew wisefy:removenetwork:publishToMavenLocal
- run:
name: Pulblish wisefy:savednetworks to Maven Local
command: ./gradlew wisefy:savednetworks:publishToMavenLocal
- run:
name: Pulblish wisefy:signal to Maven Local
command: ./gradlew wisefy:signal:publishToMavenLocal
- run:
name: Pulblish wisefy:wifi to Maven Local
command: ./gradlew wisefy:wifi:publishToMavenLocal
- run:
name: Pulblish wisefy to Maven Local
command: ./gradlew wisefy:publishToMavenLocal
- run:
name: Pulblish wisefy:ktx to Maven Local
command: ./gradlew wisefy:ktx:publishToMavenLocal

jobs:
static-analysis:
build-and-test:
executor:
name: android/android-machine
steps:
- checkout
- write-keystore-files
- import-gpg-key
- publish-to-maven-local
- run:
name: Run lint
command: ./gradlew lintDebug
Expand All @@ -21,21 +77,14 @@ jobs:
- run:
name: Run CPD
command: ./gradlew cpdCheck

build:
executor:
name: android/android-machine
steps:
- checkout
- run:
name: Assemble debug build
name: Assemble debug build
command: ./gradlew assembleDebug
- run:
name: Assemble release build
command: ./gradlew assembleRelease

workflows:
ci:
wisefy-ci-cd:
jobs:
- static-analysis
- build
- build-and-test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
/.idea/libraries/*
/.idea/codestyles/*
keystore.properties
*.jks
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ A Wifi configuration and util library built in Kotlin for Android.
[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-WiseFy-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/6011) [![Android Weekly](https://img.shields.io/badge/Android%20Weekly-%23230-blue.svg)](http://androidweekly.net/issues/issue-230)

[![CircleCI](https://dl.circleci.com/status-badge/img/gh/isuPatches/android-wisefy/tree/develop.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/isuPatches/android-wisefy/tree/develop)

- [Installation](#installation)
- [KTX Artifact](#ktx-artifact)
- [5.0 Rewrite](#50-rewrite)
Expand Down
29 changes: 8 additions & 21 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.isupatches.android.wisefy.build.Versions
import com.isupatches.android.wisefy.build.compose
import com.isupatches.android.wisefy.build.dagger
import com.isupatches.android.wisefy.build.navigation
import java.util.*

plugins {
id("com.android.application")
Expand All @@ -13,12 +12,6 @@ plugins {
id("dagger.hilt.android.plugin")
}

val keystoreProperties: Properties = Properties()
val keystoreFile: File = rootProject.file("keystore.properties")
if (keystoreFile.exists()) {
keystoreFile.inputStream().use { keystoreProperties.load(it) }
}

android {
namespace = "com.isupatches.android.wisefy.sample"
testNamespace = "com.isupatches.android.wisefy.sample.test"
Expand All @@ -39,37 +32,31 @@ android {
}

signingConfigs {
getByName("debug") {
storeFile = file(keystoreProperties.getProperty("app.debug.keystore_location"))
keyAlias = keystoreProperties.getProperty("app.debug.key_alias")
storePassword = System.getenv("APP_DEBUG_PASSWORD") ?: keystoreProperties.getProperty("app.debug.password")
keyPassword = System.getenv("APP_DEBUG_PASSWORD") ?: keystoreProperties.getProperty("app.debug.password")
}

create("release") {
storeFile = file(keystoreProperties.getProperty("app.release.keystore_location"))
keyAlias = keystoreProperties.getProperty("app.release.key_alias")
storePassword = keystoreProperties.getProperty("app.release.password")
keyPassword = keystoreProperties.getProperty("app.release.password")
storeFile = File("$rootDir/keystores/wisefy-sample-release.jks")
keyAlias = System.getenv("WISEFY_SAMPLE_RELEASE_KEY_ALIAS")
storePassword = System.getenv("WISEFY_SAMPLE_RELEASE_PASSWORD")
keyPassword = System.getenv("WISEFY_SAMPLE_RELEASE_PASSWORD")
}
}

buildTypes {
debug {
applicationIdSuffix = ".debug"
isTestCoverageEnabled = true
enableUnitTestCoverage = true
enableAndroidTestCoverage = true
isMinifyEnabled = false
isShrinkResources = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"$rootDir/proguard/r8-app-debug.pro"
)
testProguardFile(file("$rootDir/proguard/r8-app-test.pro"))
signingConfig = signingConfigs.getByName("debug")
}

release {
isTestCoverageEnabled = false
enableUnitTestCoverage = false
enableAndroidTestCoverage = false
isMinifyEnabled = false
isShrinkResources = false
proguardFiles(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package com.isupatches.android.wisefy.build

object BuildVersions {
const val BUILD_TOOLS: String = "33.0.0-rc4"
const val BUILD_TOOLS: String = "33.0.1"

const val COMPILE_SDK: Int = 33
const val TARGET_SDK: Int = 33
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ import com.isupatches.android.wisefy.build.Dependencies
import com.isupatches.android.wisefy.build.DependencyConstants.IMPLEMENTATION
import com.isupatches.android.wisefy.build.Versions
import java.io.File
import java.io.FileInputStream
import java.util.Locale
import java.util.Properties
import org.gradle.api.JavaVersion
import org.gradle.api.Plugin
import org.gradle.api.Project
Expand All @@ -44,12 +42,6 @@ class BaseGradleModulePlugin : Plugin<Project> {

target.configure<LibraryExtension> {

val keystorePropertiesFile = target.file("../keystore.properties")
val keystoreProperties = Properties()
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(FileInputStream(keystorePropertiesFile))
}

compileSdk = BuildVersions.COMPILE_SDK
buildToolsVersion = BuildVersions.BUILD_TOOLS

Expand All @@ -63,18 +55,11 @@ class BaseGradleModulePlugin : Plugin<Project> {
}

signingConfigs {
create("debug${target.name.capitalize(Locale.ROOT)}") {
storeFile = File(System.getenv("WISEFY_DEBUG_KEYSTORE_LOCATION") ?: keystoreProperties["wisefy.debug.keystore_location"].toString())
storePassword = System.getenv("WISEFY_DEBUG_PASSWORD") ?: keystoreProperties["wisefy.debug.password"].toString()
keyPassword = System.getenv("WISEFY_DEBUG_PASSWORD") ?: keystoreProperties["wisefy.debug.password"].toString()
keyAlias = System.getenv("WISEFY_DEBUG_KEY_ALIAS") ?: keystoreProperties["wisefy.debug.key_alias"].toString()
}

create("release${target.name.capitalize(Locale.ROOT)}") {
storeFile = File(System.getenv("WISEFY_RELEASE_KEYSTORE_LOCATION") ?: keystoreProperties["wisefy.release.keystore_location"].toString())
storePassword = System.getenv("WISEFY_RELEASE_PASSWORD") ?: keystoreProperties["wisefy.release.password"].toString()
keyPassword = System.getenv("WISEFY_RELEASE_PASSWORD") ?: keystoreProperties["wisefy.release.password"].toString()
keyAlias = System.getenv("WISEFY_RELEASE_KEY_ALIAS") ?: keystoreProperties["wisefy.release.key_alias"].toString()
storeFile = File("${target.rootDir}/keystores/wisefy-release.jks")
keyAlias = System.getenv("WISEFY_RELEASE_KEY_ALIAS")
storePassword = System.getenv("WISEFY_RELEASE_PASSWORD")
keyPassword = System.getenv("WISEFY_RELEASE_PASSWORD")
}
}

Expand All @@ -90,7 +75,6 @@ class BaseGradleModulePlugin : Plugin<Project> {
)
testProguardFile("${target.rootDir}/proguard/r8-lib-test.pro")
consumerProguardFile("${target.rootDir}/proguard/r8-lib-consumer.pro")
signingConfig = signingConfigs.getByName("debug${target.name.capitalize(Locale.ROOT)}")
}

release {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.isupatches.android.wisefy.build.plugins

import com.android.build.gradle.LibraryExtension
import com.isupatches.android.wisefy.build.PublishingConstants
import java.io.File
import java.net.URI
import java.util.Properties
Expand Down Expand Up @@ -74,7 +75,9 @@ class PublishingPlugin : Plugin<Project> {
publishing {
singleVariant("debug") {
withSourcesJar()
withJavadocJar()
if (System.getenv("GENERATE_DOCS_FOR_DEBUG_PUBLICATIONS") != null) {
withJavadocJar()
}
}

singleVariant("release") {
Expand All @@ -88,7 +91,7 @@ class PublishingPlugin : Plugin<Project> {
configure<PublishingExtension> {
publications {
create<MavenPublication>("debug") {
groupId = com.isupatches.android.wisefy.build.PublishingConstants.GROUP_ID
groupId = PublishingConstants.GROUP_ID
artifactId = project.name
version = project.version.toString()

Expand Down Expand Up @@ -120,7 +123,7 @@ class PublishingPlugin : Plugin<Project> {
}

create<MavenPublication>("release") {
groupId = com.isupatches.android.wisefy.build.PublishingConstants.GROUP_ID
groupId = PublishingConstants.GROUP_ID
artifactId = project.name
version = project.version.toString()

Expand Down
Empty file added keystores/.keep
Empty file.

0 comments on commit 831c378

Please sign in to comment.