From 23dc607b003567ddbc0dbcbf27c3a4d8ccf04f74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnold=20Szab=C3=B3?= Date: Tue, 17 Dec 2024 11:17:45 +0100 Subject: [PATCH] Change publish maven repo to s3 bucket (#31) * Change publish maven repo to s3 bucket * Remove mavenLocal from plugin repos, and set as last for dependency repos * bump version * bump to 1.2.1-dr-9 * Change groupd id * Add publish script * rename publish script * Add -x test to gradle publish --- build.gradle | 4 ++- common_library_config.gradle | 2 +- constants.gradle | 2 +- missing_aar_type_workaround.gradle | 2 +- publish-s3-maven.sh | 57 ++++++++++++++++++++++++++++++ publish.gradle | 9 +++-- 6 files changed, 70 insertions(+), 6 deletions(-) create mode 100755 publish-s3-maven.sh diff --git a/build.gradle b/build.gradle index 3d792da33f..173e0e9b4b 100644 --- a/build.gradle +++ b/build.gradle @@ -32,12 +32,14 @@ allprojects { includeGroup "com.github.philburk" } } + mavenLocal() } + if (it.hasProperty('externalBuildDir')) { if (!new File(externalBuildDir).isAbsolute()) { externalBuildDir = new File(rootDir, externalBuildDir) } buildDir = "${externalBuildDir}/${project.name}" } - group = 'androidx.media3' + group = 'com.endeavorstreaming.androidx-media' } diff --git a/common_library_config.gradle b/common_library_config.gradle index 6799dc1dfc..115a450e2d 100644 --- a/common_library_config.gradle +++ b/common_library_config.gradle @@ -14,7 +14,7 @@ apply from: "$gradle.ext.androidxMediaSettingsDir/constants.gradle" apply plugin: 'com.android.library' -group='com.github.DiceTechnology' +group='com.endeavorstreaming.androidx-media' android { compileSdkVersion project.ext.compileSdkVersion diff --git a/constants.gradle b/constants.gradle index c4831f6854..634b3e8536 100644 --- a/constants.gradle +++ b/constants.gradle @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. project.ext { - releaseVersion = '1.2.1' + releaseVersion = '1.2.1-dr9' releaseVersionCode = 1_002_001_3_00 minSdkVersion = 16 // See https://developer.android.com/training/cars/media/automotive-os#automotive-module diff --git a/missing_aar_type_workaround.gradle b/missing_aar_type_workaround.gradle index 7df1ade0fe..ddcd1b798c 100644 --- a/missing_aar_type_workaround.gradle +++ b/missing_aar_type_workaround.gradle @@ -75,7 +75,7 @@ def addMissingAarTypeToXml(xml) { .children()[0] String dependencyName = groupId + ":" + artifactId boolean isProjectLibrary = - groupId == 'androidx.media3' + groupId == 'com.endeavorstreaming.androidx-media' boolean hasJar = jar_only_dependencies.contains(dependencyName) boolean hasAar = diff --git a/publish-s3-maven.sh b/publish-s3-maven.sh new file mode 100755 index 0000000000..312d3ce6e6 --- /dev/null +++ b/publish-s3-maven.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +# Check if a profile argument is provided +if [[ -z "$1" ]]; then + echo "Usage: $0 " + exit 1 +fi + +# AWS profile to use for fetching credentials +AWS_PROFILE="$1" + +# Fetch credentials using AWS SSO and configure +echo "Logging in to AWS SSO..." +aws sso login --profile "$AWS_PROFILE" + +# Fetch and export credentials in environment variable format +echo "Fetching temporary AWS credentials..." +credentials=$(aws configure export-credentials --profile "$AWS_PROFILE" --format env-no-export) + +if [[ $? -ne 0 ]]; then + echo "Failed to fetch credentials. Please ensure your profile is correctly configured." + exit 1 +fi + +# Parse and export the credentials as environment variables +eval "$credentials" + +# Confirm the variables are set +echo "AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID" +echo "AWS_SECRET_ACCESS_KEY: [hidden]" +echo "AWS_SESSION_TOKEN: [hidden]" + +# Optionally, verify with a simple AWS command +aws sts get-caller-identity --profile "$AWS_PROFILE" +if [[ $? -eq 0 ]]; then + echo "AWS authentication successful." +else + echo "AWS authentication failed." + exit 1 +fi + +# Run Gradle publish task, passing AWS environment variables +echo "Running Gradle publish task..." + +# Pass the environment variables to the Gradle process +AWS_ACCESS_KEY_ID="$AWS_ACCESS_KEY_ID" \ +AWS_SECRET_ACCESS_KEY="$AWS_SECRET_ACCESS_KEY" \ +AWS_SESSION_TOKEN="$AWS_SESSION_TOKEN" \ +./gradlew publish -x test + +# Check for success or failure of the gradle publish task +if [[ $? -eq 0 ]]; then + echo "Gradle publish completed successfully." +else + echo "Gradle publish failed." + exit 1 +fi \ No newline at end of file diff --git a/publish.gradle b/publish.gradle index 79130e049b..0e2f2c323c 100644 --- a/publish.gradle +++ b/publish.gradle @@ -20,13 +20,18 @@ afterEvaluate { publishing { repositories { maven { - url = findProperty('mavenRepo') ?: "${buildDir}/repo" + url = System.getenv('AWS_S3_BUCKET_URL') + credentials(AwsCredentials) { + accessKey = System.getenv('AWS_ACCESS_KEY_ID') + secretKey = System.getenv('AWS_SECRET_ACCESS_KEY') + sessionToken = System.getenv('AWS_SESSION_TOKEN') + } } } publications { release(MavenPublication) { from components.release - groupId = 'androidx.media3' + groupId = 'com.endeavorstreaming.androidx-media' artifactId = findProperty('releaseArtifactId') ?: '' version = findProperty('releaseVersion') ?: '' pom {