Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Streamline Android publishing #4541

Merged
merged 6 commits into from
Aug 18, 2020
Merged
Show file tree
Hide file tree
Changes from 5 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
57 changes: 57 additions & 0 deletions .pipelines/android-daily.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: $(Year:yyyy).$(Month).$(DayOfMonth)-$(rev:r)
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this file here?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is the yml version of the Android daily pipeline. It will not delete the existing pipeline, but once it is checked into main, we can see if it is working as expected.


pr: none
trigger: none

schedules:
- cron: "0 10 * * Mon-Fri"
displayName: 3:00 AM Pacific (UTC-8) Daily Build (M-F)
branches:
include:
- main

pool:
name: Hosted Ubuntu 1604
demands: java

#Your build pipeline references an undefined variable named ‘gradleprop.secureFilePath’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972

steps:
- task: DownloadSecureFile@1
name: gradleproperties
displayName: 'Download secure file'
inputs:
secureFile: gradle.properties.4

- bash: |
# Write your commands here

# Use the environment variables input below to pass secret variables to this script
cp -f $(gradleproperties.secureFilePath) ./source/android/adaptivecards/gradle.properties


displayName: 'Bash Script'

- bash: |
#!/usr/bin/env bash

# Starting from AGP 4.1+, the required NDK version will be retrieved automatically, so this script will not be needed. Please remove.

unset ANDROID_NDK_HOME
sudo ${ANDROID_HOME}/tools/bin/sdkmanager --verbose --install "ndk;21.0.6113669"
displayName: 'Get NDK (won''t be needed w/ Android Gradle Plugin 4.1+)'

- task: Gradle@2
displayName: 'gradlew adaptivecards:build'
inputs:
gradleWrapperFile: source/android/gradlew
workingDirectory: source/android
tasks: 'adaptivecards:build'

- task: Gradle@2
displayName: 'gradlew publish'
inputs:
gradleWrapperFile: source/android/gradlew
workingDirectory: source/android
tasks: 'adaptivecards:publish'
publishJUnitResults: false
120 changes: 41 additions & 79 deletions source/android/adaptivecards/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,103 +42,65 @@ task sourceJar(type: Jar) {
classifier "sources"
}

task createPom {
doLast {
pom {
project {
groupId 'io.adaptivecards'
artifactId 'adaptivecards-android'
version System.getenv('XES_PACKAGEVERSIONNUMBER') ?: '0.0.0'
name 'Android Adaptive Cards Library'
description 'Android Adaptive Cards Lib'
url 'https://github.com/Microsoft/AdaptiveCards'
packaging 'aar'
scm {
url 'https://github.com/Microsoft/AdaptiveCards'
}

licenses {
license {
name 'MIT'
url 'https://github.com/Microsoft/AdaptiveCards/blob/main/LICENSE'
distribution 'repo'
}
}
def projectInfo = {
name = 'Android Adaptive Cards Library'
description 'Android Adaptive Cards Lib'
url = 'https://github.com/Microsoft/AdaptiveCards'

developers {
developer {
id 'microsoft'
name 'adaptivecards'
}
}
}
}.writeTo("pom.xml")
scm {
url = 'https://github.com/Microsoft/AdaptiveCards'
}
}

publishing {
publications {
adaptivecards(MavenPublication) {
groupId 'io.adaptivecards'
version System.getenv('ACSDKVERSION') + '-' + System.getenv('BUILD_BUILDNUMBER')
artifact(sourceJar)
artifact("$buildDir/outputs/aar/adaptivecards-release.aar")
licenses {
license {
name = 'MIT'
url = 'https://github.com/Microsoft/AdaptiveCards/blob/main/LICENSE'
distribution = 'repo'
}
}

repositories {
maven {
url 'https://microsoft.pkgs.visualstudio.com/_packaging/AdaptiveCards/maven/v1'
credentials {
username "AZURE_ARTIFACTS"
password System.getenv("AZURE_ARTIFACTS_ENV_ACCESS_TOKEN") ?: "${azureArtifactsGradleAccessToken}"
}
}
organization {
name = 'Microsoft'
url = 'https://microsoft.com/'
}
}

uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
pom.artifactId ="adaptivecards-android"
afterEvaluate {
publishing {
publications {
release(MavenPublication) {
from components.release

repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2") {
authentication(userName: NexusUserName, password: NexusPassword)
}
pom {
setGroupId "io.adaptivecards"
setVersion System.getenv("XES_PACKAGEVERSIONNUMBER") ?:"0.0.0"
}
groupId = 'io.adaptivecards'
artifactId = 'adaptivecards-android'

pom.project {
name 'Android Adaptive Cards Library'
description 'Android Adaptive Cards Lib'
url 'https://github.com/Microsoft/AdaptiveCards'
// Get version from PackageES, or fallback to Azure Pipeline build number
version = System.getenv('XES_PACKAGEVERSIONNUMBER') ?: System.getenv('BUILD_BUILDNUMBER') ?: '0.0.0'

scm {
url 'https://github.com/Microsoft/AdaptiveCards'
}
pom projectInfo
}

licenses {
license {
name 'MIT'
url 'https://github.com/Microsoft/AdaptiveCards/blob/main/LICENSE'
distribution 'repo'
}
}
}

developers {
developer {
id 'microsoft'
name 'adaptivecards'
}
}
repositories {
// Publish to Azure Artifacts feed
maven {
name = 'azuredevops'
url = 'https://microsoft.pkgs.visualstudio.com/_packaging/AdaptiveCards/maven/v1'
credentials {
username "AZURE_ARTIFACTS"
password System.getenv("AZURE_ARTIFACTS_ENV_ACCESS_TOKEN") ?: "${azureArtifactsGradleAccessToken}"
}

}
// Save to local directory "artifact"
maven {
name = 'localArtifact'
url = "artifact"
}
// TODO: Add SonaType OSS repository to publish directly
}
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
Expand Down
2 changes: 1 addition & 1 deletion source/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.0.0'
classpath 'com.android.tools.build:gradle:4.0.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down