Skip to content

Commit

Permalink
Change publish maven repo to s3 bucket (#31)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
szaboa authored Dec 17, 2024
1 parent a3c9fcd commit 23dc607
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 6 deletions.
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
2 changes: 1 addition & 1 deletion common_library_config.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion constants.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion missing_aar_type_workaround.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
57 changes: 57 additions & 0 deletions publish-s3-maven.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash

# Check if a profile argument is provided
if [[ -z "$1" ]]; then
echo "Usage: $0 <aws-profile>"
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
9 changes: 7 additions & 2 deletions publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 23dc607

Please sign in to comment.