Skip to content

Commit

Permalink
build: dependencies management and publishing workflow updates (#21)
Browse files Browse the repository at this point in the history
* chore: Dependencies management and publishing workflow updates (#20)

* chore: updated dependencies management

* chore: updated process to upload artifacts

* chore: added ci workflow for snapshot

* chore: ignore idea file changes

* chore: updated git ignore to cater idea files

* chore: fixed untracked files

* chore: added missing dependencies

* fix: workflow wrong assemble command

* Added staging profile id in secrets

* Updated signing keys secrets

* Updated signing id secrets

* Added semantic versioning to snapshots

* Added missing plugins to dry run

* Added all missing plugins for snapshot release

* Updated CI workflow for publishing snapshots

* Updated semantic release config

* Version issue in snapshot deployment

* Versioning error on sonar type

* Switching back to commit hash as version number

* Lowercased snapshot for possible bad request fix

* Snapshot failing possible fix

* Snapshot test

- Checking if same snapshot artifact gets updated

* Updated workflow for release artifact

* Code cleanup

- Lint
- Documentation

* Removed Kotlin reflect library

* Renamed artifact id to be consistent with iOS
  • Loading branch information
Shahroz16 authored Sep 29, 2021
1 parent f6c1844 commit 1f40ba2
Show file tree
Hide file tree
Showing 27 changed files with 373 additions and 355 deletions.
40 changes: 23 additions & 17 deletions .github/workflows/deploy-sdk.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
name: Deploy SDK
name: Deploy SDK
on:
push:
branches: [main, beta, alpha]
branches: [ main, beta, alpha ]

jobs:
deploy-sdk:
name: Deploy SDK
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK
- name: Check out code
uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '11' # Robolectric requires v9, but we choose LTS: https://adoptopenjdk.net/
- name: Setup Android SDK
uses: android-actions/setup-android@v2

distribution: adopt
java-version: 11
- name: Release build
# assembleRelease for all modules, excluding non-library modules: app, docs
run: ./gradlew assembleRelease -x :app:assembleRelease
- name: Source jar and dokka
run: ./gradlew androidSourcesJar javadocJar

# Perform git related tasks inside of semantic-release because `git config user...` is already setup. It's easier to run commands in there with exec plugin.
- name: Deploy via semantic release
- name: Deploy via semantic release
uses: cycjimmy/semantic-release-action@v2
with:
with:
# version numbers below can be in many forms: M, M.m, M.m.p
semantic_version: 17
dry_run: false
extra_plugins: |
@semantic-release/commit-analyzer@8
@semantic-release/release-notes-generator@9
Expand All @@ -31,9 +36,10 @@ jobs:
@semantic-release/github@7
@semantic-release/exec@5
env:
GITHUB_TOKEN: ${{ secrets.REPO_PUSH_TOKEN }}
GRADLE_PUBLISH_USERNAME: ${{ secrets.GRADLE_PUBLISH_USERNAME }}
GRADLE_PUBLISH_PASSWORD: ${{ secrets.GRADLE_PUBLISH_PASSWORD }}
ORG_GRADLE_PROJECT_signingKeyId: ${{ secrets.GRADLE_SIGNING_KEYID }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GRADLE_SIGNING_PRIVATE_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GRADLE_SIGNING_PASSPHRASE }}
OSSRH_USERNAME: ${{ secrets.GRADLE_PUBLISH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.GRADLE_PUBLISH_PASSWORD }}
SIGNING_KEY_ID: ${{ secrets.GRADLE_SIGNING_KEYID }}
SIGNING_PASSWORD: ${{ secrets.GRADLE_SIGNING_PASSPHRASE }}
SIGNING_KEY: ${{ secrets.GRADLE_SIGNING_PRIVATE_KEY }}
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
GITHUB_TOKEN: ${{ secrets.REPO_PUSH_TOKEN }}
57 changes: 57 additions & 0 deletions .github/workflows/snapshot-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Publish Snapshot builds

on:
push:
branches:
- develop

jobs:
publish:
name: Snapshot build and publish
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
distribution: adopt
java-version: 11

# Get just version number for semantic snapshot release. It would just dry run and not publish, release
- name: Run semantic release to get version
uses: cycjimmy/semantic-release-action@v2
id: semantic
with:
# version numbers below can be in many forms: M, M.m, M.m.p
semantic_version: 17
branch: develop
extra_plugins: |
@semantic-release/commit-analyzer@8
@semantic-release/release-notes-generator@9
@semantic-release/changelog@5
@semantic-release/git@9
@semantic-release/github@7
@semantic-release/exec@5
env:
GITHUB_TOKEN: ${{ secrets.REPO_PUSH_TOKEN }}

- name: Release build
# assembleRelease for all modules, excluding non-library modules: app, docs
run: ./gradlew assembleRelease -x :app:assembleRelease
- name: Source jar and dokka
run: ./gradlew androidSourcesJar javadocJar

- name: Add MODULE_VERSION env property
run: echo "MODULE_VERSION=`echo ${{ steps.semantic.outputs.new_release_version }}`-SNAPSHOT" >> $GITHUB_ENV

- name: Publish to MavenCentral
run: ./gradlew publishReleasePublicationToSonatypeRepository
env:
OSSRH_USERNAME: ${{ secrets.GRADLE_PUBLISH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.GRADLE_PUBLISH_PASSWORD }}
SIGNING_KEY_ID: ${{ secrets.GRADLE_SIGNING_KEYID }}
SIGNING_PASSWORD: ${{ secrets.GRADLE_SIGNING_PASSPHRASE }}
SIGNING_KEY: ${{ secrets.GRADLE_SIGNING_PRIVATE_KEY }}
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
SNAPSHOT: true
15 changes: 4 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,10 @@ captures/

# IntelliJ
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
# Android Studio 3 in .gitignore file.
.idea/caches
.idea/modules.xml
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
.idea/navEditor.xml
/.idea/*
!/.idea/codeInsightSettings.xml
!/.idea/codeStyles/
!/.idea/inspectionProfiles/

# Keystore files
# Uncomment the following lines if you do not want to check your keystore files in.
Expand Down
3 changes: 0 additions & 3 deletions .idea/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion .idea/.name

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/compiler.xml

This file was deleted.

30 changes: 0 additions & 30 deletions .idea/jarRepositories.xml

This file was deleted.

14 changes: 0 additions & 14 deletions .idea/misc.xml

This file was deleted.

10 changes: 0 additions & 10 deletions .idea/runConfigurations.xml

This file was deleted.

47 changes: 30 additions & 17 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,33 @@
{
"tagFormat": "${version}",
"branches": [
"main",
{ "name": "beta", "prerelease": true },
{ "name": "alpha", "prerelease": true }
"tagFormat": "${version}",
"branches": [
"main",
{
"name": "beta",
"prerelease": true
},
{
"name": "alpha",
"prerelease": true
}
],
"dryRun": true,
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
[
"@semantic-release/exec",
{
"prepareCmd": "MODULE_VERSION=${nextRelease.version} ./gradlew publishReleasePublicationToSonatypeRepository --max-workers 1 closeAndReleaseSonatypeStagingRepository"
}
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
["@semantic-release/exec", {
"prepareCmd": "MODULE_VERSION=${nextRelease.version} ./gradlew :sdk:uploadArchives"
}],
["@semantic-release/changelog",{
"changelogFile": "CHANGELOG.md"
}],
"@semantic-release/git",
"@semantic-release/github"
]
[
"@semantic-release/changelog",
{
"changelogFile": "CHANGELOG.md"
}
],
"@semantic-release/git",
"@semantic-release/github"
]
}
85 changes: 13 additions & 72 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
import customerio.android.Dependencies

plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
}

hilt {
enableTransformForLocalTests = true // to get unit tests (robolectric) working: https://developer.android.com/training/dependency-injection/hilt-testing
}
apply from: "${rootDir}/scripts/android-config.gradle"

android {
compileSdkVersion 30
buildToolsVersion "30.0.3"

defaultConfig {
applicationId "io.customer.example"
minSdkVersion 16
targetSdkVersion 30
versionCode 1
versionName "1.0"

Expand All @@ -43,72 +37,19 @@ android {
unitTests {
// From: http://robolectric.org/getting-started/
includeAndroidResources = true
returnDefaultValues = true
}
}
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'

// Navigation
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'

// Hilt
implementation "com.google.dagger:hilt-android:$hilt_version"
kapt "com.google.dagger:hilt-compiler:$hilt_version"

// Truth
testImplementation "com.google.truth:truth:1.0.1"
androidTestImplementation "com.google.truth:truth:1.0.1"
androidTestImplementation 'androidx.test.ext:truth:1.3.0'
testImplementation 'androidx.test.ext:truth:1.3.0'

// Mockito
def mockitoVersion = '3.3.3'
def mockitoKotlinVersion = '2.2.0'
testImplementation "org.mockito:mockito-core:$mockitoVersion"
testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:$mockitoKotlinVersion", {
exclude group: 'org.jetbrains.kotlin'
exclude group: 'org.mockito'
}
androidTestImplementation "org.mockito:mockito-android:$mockitoVersion"
androidTestImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:$mockitoKotlinVersion", {
exclude group: 'org.jetbrains.kotlin'
exclude group: 'org.mockito'
}

// JUnit
def junitVersion = '4.13.2'
testImplementation "junit:junit:$junitVersion"
androidTestImplementation "junit:junit:$junitVersion"
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
testImplementation 'androidx.test.ext:junit:1.1.2'

// Robolectric
testImplementation "org.robolectric:robolectric:4.5.1"

// Android Testing Support Library's runner and rules
def androidTestLibVersion = "1.3.0"
androidTestImplementation "androidx.test:core-ktx:$androidTestLibVersion"
androidTestImplementation "androidx.test:runner:$androidTestLibVersion"
androidTestImplementation "androidx.test:rules:$androidTestLibVersion"
testImplementation "androidx.test:core-ktx:$androidTestLibVersion"
testImplementation "androidx.test:runner:$androidTestLibVersion"
testImplementation "androidx.test:rules:$androidTestLibVersion"
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

// Espresso UI Testing
def espressoVersion = '3.3.0'
androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVersion"
androidTestImplementation "androidx.test.espresso.idling:idling-concurrent:$espressoVersion"
androidTestImplementation "androidx.test.espresso:espresso-idling-resource:$espressoVersion"
testImplementation "androidx.test.espresso:espresso-core:$espressoVersion"
testImplementation "androidx.test.espresso.idling:idling-concurrent:$espressoVersion"
testImplementation "androidx.test.espresso:espresso-idling-resource:$espressoVersion"
implementation project(":sdk")
implementation Dependencies.androidxAppCompat
implementation Dependencies.androidxCoreKtx
implementation Dependencies.materialComponents

androidTestImplementation Dependencies.junit4
testImplementation Dependencies.junit4
testImplementation Dependencies.androidxTestJunit
testImplementation Dependencies.robolectric
}
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
android:supportsRtl="true"
android:name=".MainApplication"
android:theme="@style/Theme.App">
<activity android:name="io.customer.example.MainActivity">
<activity android:name="io.customer.example.MainActivity"
android:exported="false">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
2 changes: 0 additions & 2 deletions app/src/main/java/io/customer/example/MainApplication.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package io.customer.example

import android.app.Application
import dagger.hilt.android.HiltAndroidApp

@HiltAndroidApp
class MainApplication : Application()
Loading

0 comments on commit 1f40ba2

Please sign in to comment.