-
Notifications
You must be signed in to change notification settings - Fork 5
RMET-3983 - Add workflow to publish library under io.ionic.libs in Maven #46
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
58323d5
feat: add `publish-android.yml` workflow to publish library in Maven
alexgerardojacinto 5cd7dc9
feat: add `publish-android.yml` workflow to publish library in Maven
alexgerardojacinto 0b925ed
refactor: remove spaces from branch name
alexgerardojacinto c74dcba
fix: apply publish-root.gradle file in build.gradle
alexgerardojacinto 40184a9
fix: add missing apply in build.gradle
alexgerardojacinto b938589
chore: set JVM to 17
alexgerardojacinto 3ca7d71
Revert "chore: set JVM to 17"
alexgerardojacinto 803b2d2
fix: add missing entries in build.gradle
alexgerardojacinto aa12dbe
test: test publish-android workflow
alexgerardojacinto 696b531
chore: revert changes on AGP version and JVM version
alexgerardojacinto 8234627
chore: update changelog and set workflow to only run on manual trigger
alexgerardojacinto 82d35c4
chore: remove lintOptions from build.gradle
alexgerardojacinto 9787e50
chore: set workflow to run only on manual triggers
alexgerardojacinto 572443c
Merge pull request #45 from OutSystems/feat/RMET-3983/add-publish-wor…
alexgerardojacinto a3a6f78
chore: add date to changelog entry
alexgerardojacinto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| name: Publish Native Android Library | ||
|
|
||
| on: workflow_dispatch | ||
|
|
||
| jobs: | ||
| publish-android: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| packages: write | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: set up JDK 17 | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| java-version: '17' | ||
| distribution: 'adopt' | ||
| - name: Grant execute permission for gradlew | ||
| run: chmod +x ./gradlew | ||
| - name: Grant execute permission for publishing script | ||
| run: chmod +x ./scripts/publish-android.sh | ||
| - name: Make local props | ||
| run: | | ||
| cat << EOF > "local.properties" | ||
| ossrhUsername=${{ secrets.ANDROID_OSSRH_USERNAME }} | ||
| ossrhPassword=${{ secrets.ANDROID_OSSRH_PASSWORD }} | ||
| sonatypeStagingProfileId=${{ secrets.ANDROID_SONATYPE_STAGING_PROFILE_ID }} | ||
| signing.keyId=${{ secrets.ANDROID_SIGNING_KEY_ID }} | ||
| signing.password=${{ secrets.ANDROID_SIGNING_PASSWORD }} | ||
| signing.key=${{ secrets.ANDROID_SIGNING_KEY }} | ||
| EOF | ||
| echo "local.properties file has been created successfully." | ||
| - name: Run publish script | ||
| working-directory: ./scripts | ||
| run: ./publish-android.sh |
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| ANDROID_PATH=../ | ||
| LOG_OUTPUT=./tmp/publish-android.txt | ||
| THE_VERSION=`sed -n 's/.*<version>\(.*\)<\/version>.*/\1/p' ../pom.xml` | ||
|
|
||
| # Get latest io.ionic:portals XML version info | ||
| PUBLISHED_URL="https://repo1.maven.org/maven2/io/ionic/libs/ionbarcode-android/maven-metadata.xml" | ||
| PUBLISHED_DATA=$(curl -s $PUBLISHED_URL) | ||
| PUBLISHED_VERSION="$(perl -ne 'print and last if s/.*<latest>(.*)<\/latest>.*/\1/;' <<< $PUBLISHED_DATA)" | ||
|
|
||
| if [[ "$THE_VERSION" == "$PUBLISHED_VERSION" ]]; then | ||
| printf %"s\n\n" "Duplicate: a published version exists for $THE_VERSION, skipping..." | ||
| else | ||
| # Make log dir if doesnt exist | ||
| mkdir -p ./tmp | ||
|
|
||
| # Export ENV variable used by Gradle for Versioning | ||
| export THE_VERSION | ||
| export SHOULD_PUBLISH=true | ||
|
|
||
| printf %"s\n" "Attempting to build and publish version $THE_VERSION" | ||
| # Publish a release to the Maven repo | ||
| "$ANDROID_PATH"/gradlew clean build publishReleasePublicationToSonatypeRepository closeAndReleaseSonatypeStagingRepository --no-daemon --max-workers 1 -b "$ANDROID_PATH"/build.gradle -Pandroid.useAndroidX=true > $LOG_OUTPUT 2>&1 | ||
| # Stage a version | ||
| # "$ANDROID_PATH"/gradlew clean build publishReleasePublicationToSonatypeRepository --no-daemon --max-workers 1 -b "$ANDROID_PATH"/build.gradle -Pandroid.useAndroidX=true > $LOG_OUTPUT 2>&1 | ||
|
|
||
| echo $RESULT | ||
|
|
||
| if grep --quiet "BUILD SUCCESSFUL" $LOG_OUTPUT; then | ||
| printf %"s\n" "Success: Published to MavenCentral." | ||
| else | ||
| printf %"s\n" "Error publishing, check $LOG_OUTPUT for more info! Manually review and release from the Sonatype Repository Manager may be necessary https://s01.oss.sonatype.org/" | ||
| cat $LOG_OUTPUT | ||
| exit 1 | ||
| fi | ||
|
|
||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| apply plugin: 'maven-publish' | ||
| apply plugin: 'signing' | ||
|
|
||
| def LIB_VERSION = System.getenv('THE_VERSION') | ||
|
|
||
| task androidSourcesJar(type: Jar) { | ||
| archiveClassifier.set('sources') | ||
| from android.sourceSets.main.java.srcDirs | ||
| from android.sourceSets.main.kotlin.srcDirs | ||
| } | ||
|
|
||
| artifacts { | ||
| archives androidSourcesJar | ||
| } | ||
|
|
||
| group = 'io.ionic.libs' | ||
| version = LIB_VERSION | ||
|
|
||
| afterEvaluate { | ||
| publishing { | ||
| publications { | ||
| release(MavenPublication) { | ||
| // Coordinates | ||
| groupId 'io.ionic.libs' | ||
| artifactId 'ionbarcode-android' | ||
| version LIB_VERSION | ||
|
|
||
| // Two artifacts, the `aar` (or `jar`) and the sources | ||
| if (project.plugins.findPlugin("com.android.library")) { | ||
| from components.release | ||
| } else { | ||
| artifact("$buildDir/libs/${project.getName()}-${version}.jar") | ||
| } | ||
|
|
||
| artifact androidSourcesJar | ||
|
|
||
| // POM Data | ||
| pom { | ||
| name = 'ionbarcode-android' | ||
| description = 'Barcode Android Lib' | ||
| url = 'https://github.com/OutSystems/OSBarcodeLib-Android' | ||
| licenses { | ||
| license { | ||
| name = 'License' | ||
| url = 'https://github.com/OutSystems/OSBarcodeLib-Android/blob/main/LICENSE' | ||
| } | ||
| } | ||
| developers { | ||
| developer { | ||
| name = 'Ionic' | ||
| email = 'hi@ionic.io' | ||
| } | ||
| } | ||
|
|
||
| // Version Control Info | ||
| scm { | ||
| connection = 'scm:git:github.com:OutSystems/OSBarcodeLib-Android.git' | ||
| developerConnection = 'scm:git:ssh://github.com:OutSystems/OSBarcodeLib-Android.git' | ||
| url = 'https://github.com/OutSystems/OSBarcodeLib-Android/tree/main' | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| signing { | ||
| useInMemoryPgpKeys( | ||
| rootProject.ext["signing.keyId"], | ||
| rootProject.ext["signing.key"], | ||
| rootProject.ext["signing.password"], | ||
| ) | ||
| sign publishing.publications | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| // Create variables with empty default values | ||
| ext["signing.keyId"] = '' | ||
| ext["signing.key"] = '' | ||
| ext["signing.password"] = '' | ||
| ext["ossrhUsername"] = '' | ||
| ext["ossrhPassword"] = '' | ||
| ext["sonatypeStagingProfileId"] = '' | ||
|
|
||
| File secretPropsFile = file('./local.properties') | ||
| if (secretPropsFile.exists()) { | ||
| // Read local.properties file first if it exists | ||
| Properties p = new Properties() | ||
| new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) } | ||
| p.each { name, value -> ext[name] = value } | ||
| } else { | ||
| // Use system environment variables | ||
| ext["ossrhUsername"] = System.getenv('ANDROID_OSSRH_USERNAME') | ||
| ext["ossrhPassword"] = System.getenv('ANDROID_OSSRH_PASSWORD') | ||
| ext["sonatypeStagingProfileId"] = System.getenv('ANDROID_SONATYPE_STAGING_PROFILE_ID') | ||
| ext["signing.keyId"] = System.getenv('ANDROID_SIGNING_KEY_ID') | ||
| ext["signing.key"] = System.getenv('ANDROID_SIGNING_KEY') | ||
| ext["signing.password"] = System.getenv('ANDROID_SIGNING_PASSWORD') | ||
| } | ||
|
|
||
| // Set up Sonatype repository | ||
| nexusPublishing { | ||
| repositories { | ||
| sonatype { | ||
| stagingProfileId = sonatypeStagingProfileId | ||
| username = ossrhUsername | ||
| password = ossrhPassword | ||
| nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) | ||
| snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) | ||
| } | ||
| } | ||
| repositoryDescription = 'OSBarcode Android Lib v' + System.getenv('THE_VERSION') | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.