Skip to content

Commit

Permalink
Fix espresso release (#177)
Browse files Browse the repository at this point in the history
Co-authored-by: sauce-visual-bot <[email protected]>
  • Loading branch information
kb-kerem and sauce-visual-bot authored Dec 12, 2024
1 parent 8cb1026 commit bc9e061
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 87 deletions.
24 changes: 9 additions & 15 deletions .github/workflows/espresso-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
releaseType:
description: 'Release type - major, minor or patch'
required: true
default: 'minor'
default: 'patch'
options:
- 'major'
- 'minor'
Expand All @@ -28,8 +28,6 @@ jobs:
java-version: '17'
distribution: 'temurin'
server-id: ossrh
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }}

- name: Set up Git
if: ${{ steps.prep.outputs.tag_name == '' }}
Expand All @@ -43,20 +41,16 @@ jobs:
- name: Bump version
id: upgrade
run: |
./gradlew -q bumpVersion -PreleaseType=${{ github.event.inputs.releaseType }}
new_version=$(./gradlew -q bumpVersion -PreleaseType=${{ github.event.inputs.releaseType }})
echo "version=$new_version" >> "$GITHUB_OUTPUT"
- name: Publish to Sonatype OSSRH (staging)
run: ./gradlew publish
- name: Build, publish and release artifact
run: ./gradlew build publishAndReleaseToMavenCentral --no-configuration-cache
env:
OSSRH_USERNAME: ${{ secrets.MVN_CENTRAL_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.MVN_CENTRAL_PASSWORD }}

- name: Close and release the repository
run: ./gradlew nexusStagingRelease
env:
OSSRH_USERNAME: ${{ secrets.MVN_CENTRAL_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.MVN_CENTRAL_PASSWORD }}
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MVN_CENTRAL_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MVN_CENTRAL_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.MVN_CENTRAL_GPG_PRIVATE_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.MVN_CENTRAL_GPG_PASSPHRASE }}

- name: Push new version to Git
id: push_to_git
Expand All @@ -75,5 +69,5 @@ jobs:
with:
fail_on_unmatched_files: true
tag_name: ${{ steps.push_to_git.outputs.tag_name }}
files: visual-espresso/target/visual-release.aar
files: visual-espresso/visual/build/outputs/aar/visual-release.aar
generate_release_notes: true
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ This repository contains the SDKs for Sauce Labs Visual.
- [Java](./visual-java)
- [JavaScript/TypeScript](./visual-js)
- [Python](./visual-python)
- [Espresso](./visual-espresso/)
34 changes: 34 additions & 0 deletions visual-espresso/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Sauce Labs Visual for Espresso

Sauce Labs Visual for Espresso exposes Sauce Labs Visual Testing for your Android apps.

## Installation & Usage

View installation and usage instructions on the [Sauce Docs website](https://docs.saucelabs.com/visual-testing/integrations/espresso/).

## Building

Sauce Visual Java SDK uses [Gradle](https://gradle.org/).

`gradlew` binary, that is included in the source, can be used as a replacement if you don't have Maven.

You'll also need [Android command line tools](https://developer.android.com/tools/).

It can be setup either using [Android Studio](https://developer.android.com/studio) or using [homebrew](https://formulae.brew.sh/cask/android-commandlinetools).

```sh
./gradlew build
```

## Running the tests

To run the smoke test you'll need a running Android Emulator.

You can either start an emulator from Android Studio or using [command line](https://developer.android.com/studio/run/emulator-commandline).

Then you can run the smoke test using the following command. Make sure that SAUCE_USERNAME and SAUCE_ACCESS_KEY environment variables
are in place before running the test.

```sh
./gradlew connectedAndroidTest
```
3 changes: 1 addition & 2 deletions visual-espresso/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.android.library) apply false
alias(libs.plugins.gradle.nexus.publish)
}
}
4 changes: 2 additions & 2 deletions visual-espresso/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ espressoCore = "3.6.1"
appcompat = "1.7.0"
material = "1.12.0"
uiautomator = "2.2.0"
gradleNexusPublish = "2.0.0"
vanniktechMavenPublish = "0.30.0"

[libraries]
jsoup = { group = "org.jsoup", name = "jsoup", version.ref = "jsoup" }
Expand All @@ -25,4 +25,4 @@ apollo-rx3-support = { group = "com.apollographql.apollo3", name = "apollo-rx3-s
android-application = { id = "com.android.application", version.ref = "agp" }
android-library = { id = "com.android.library", version.ref = "agp" }
apollographql = { id = "com.apollographql.apollo3", version.ref = "apolloGraphQL" }
gradle-nexus-publish = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "gradleNexusPublish"}
vanniktech-maven-publish = { id = "com.vanniktech.maven.publish", version.ref = "vanniktechMavenPublish"}
106 changes: 38 additions & 68 deletions visual-espresso/visual/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import com.vanniktech.maven.publish.AndroidSingleVariantLibrary
import com.vanniktech.maven.publish.SonatypeHost

plugins {
alias libs.plugins.android.library
alias libs.plugins.apollographql
id 'maven-publish'
id 'signing'
alias libs.plugins.vanniktech.maven.publish
}

android {
Expand All @@ -12,7 +14,7 @@ android {
defaultConfig {
minSdk 21
versionCode 1
versionName "0.0.0"
versionName "0.0.1"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"

Expand All @@ -27,16 +29,12 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
publishing {
singleVariant("release") {
withSourcesJar()
withJavadocJar()
}
}

buildFeatures {
buildConfig = true
}
Expand Down Expand Up @@ -73,53 +71,34 @@ ext {
artifactName = 'visual-espresso'
}

publishing {
publications {
release(MavenPublication) {
groupId = android.namespace
artifactId = "${artifactName}"
version = android.defaultConfig.versionName
afterEvaluate {
from components.release
}
pom {
name = "${artifactName}"
description = 'Sauce Visual Espresso SDK'
url = 'https://github.com/saucelabs/visual-sdks'
scm {
connection = "scm:git:${scmUrl}"
developerConnection = "scm:git:${scmUrl}"
url = "${scmUrl}"
}
licenses {
license {
name = 'Apache-2.0'
url = 'https://github.com/saucelabs/visual-sdks/blob/main/LICENSE'
}
}
developers {
developer {
name = 'Sauce Labs Visual Team'
email = '[email protected]'
organization = 'Sauce Labs'
organizationUrl = 'https://saucelabs.com/'
}
}
mavenPublishing {
configure(new AndroidSingleVariantLibrary("release", true, true))
publishToMavenCentral(SonatypeHost.DEFAULT)
signAllPublications()
coordinates(android.namespace, "${artifactName}", android.defaultConfig.versionName)

pom {
name = "${artifactName}"
description = 'Sauce Visual Espresso SDK'
url = 'https://github.com/saucelabs/visual-sdks'
scm {
connection = "scm:git:${scmUrl}"
developerConnection = "scm:git:${scmUrl}"
url = "${scmUrl}"
}
licenses {
license {
name = 'Apache-2.0'
url = 'https://github.com/saucelabs/visual-sdks/blob/main/LICENSE'
}
}
}
repositories {
mavenLocal()
}
}

nexusPublishing {
repositories {
sonatype {
nexusUrl = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
snapshotRepositoryUrl = uri("https://oss.sonatype.org/content/repositories/snapshots/")
username = project.findProperty("ossrhUsername") ?: System.getenv("OSSRH_USERNAME")
password = project.findProperty("ossrhPassword") ?: System.getenv("OSSRH_PASSWORD")
developers {
developer {
name = 'Sauce Labs Visual Team'
email = '[email protected]'
organization = 'Sauce Labs'
organizationUrl = 'https://saucelabs.com/'
}
}
}
}
Expand All @@ -132,26 +111,17 @@ apollo {
}
}

signing {
useInMemoryPgpKeys(
project.findProperty("signingKey") ?: System.getenv("GPG_PRIVATE_KEY"),
project.findProperty("signingPassword") ?: System.getenv("GPG_PASSPHRASE")
)
sign publishing.publications
}

tasks.register('bumpVersion') {
doLast {
def releaseType = project.hasProperty("releaseType") ? project.releaseType : null
if (!releaseType) {
throw new GradleException("Please provide a release type using -PreleaseType=<major|minor|patch>")
}

def currentVersionName = android.defaultConfig.versionName
def newVersionName = calculateNewVersion(currentVersionName, releaseType)
persistVersionName(newVersionName)
def newVersion = calculateNewVersion(android.defaultConfig.versionName, releaseType)
persistNewVersion(newVersion)

println "$newVersionName"
print "$newVersion"
}
}

Expand Down Expand Up @@ -182,8 +152,8 @@ static def calculateNewVersion(currentVersion, releaseType) {
return "$major.$minor.$patch"
}

def persistVersionName(newVersionName) {
def persistNewVersion(newVersion) {
def buildFile = file("build.gradle")
def buildFileContent = buildFile.text.replaceAll(/versionName\s+"[^"]+"/, "versionName \"$newVersionName\"")
def buildFileContent = buildFile.text.replaceAll(/versionName\s+"[^"]+"/, "versionName \"$newVersion\"")
buildFile.text = buildFileContent
}

0 comments on commit bc9e061

Please sign in to comment.