diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml new file mode 100644 index 0000000..0a78b72 --- /dev/null +++ b/.github/workflows/publish-release.yml @@ -0,0 +1,41 @@ +name: Publish to Maven Central +on: + release: + types: [ released ] +jobs: + build: + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v2 + with: + submodules: true + + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + distribution: adopt + java-version: 11 + + - name: Setup the environment + run: | + sudo pip3 install meson==0.58.2 + sudo apt-get install nasm ninja-build + + - name: Assembling the ffmpeg-android-maker + run: ffmpeg-android-maker/ffmpeg-android-maker.sh -dav1d + env: + ANDROID_SDK_HOME: $ANDROID_HOME + + - name: Building the library, preparing sources and docs + run: ./gradlew assembleRelease androidSourcesJar javadocJar + + - name: Pushing the library to Maven Central + run: ./gradlew publishReleasePublicationToSonatypeRepository closeAndReleaseSonatypeStagingRepository --max-workers 1 + env: + SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} + SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} + SIGNING_KEY: ${{ secrets.SIGNING_KEY }} + OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} + OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} + SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} \ No newline at end of file diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml new file mode 100644 index 0000000..b459fe4 --- /dev/null +++ b/.github/workflows/publish-snapshot.yml @@ -0,0 +1,43 @@ +name: Publish to Maven Central (SNAPSHOT) +on: + push: + branches: + - develop +jobs: + build: + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v2 + with: + submodules: true + + - name: Set up JDK 11 + uses: actions/setup-java@v2 + with: + distribution: adopt + java-version: 11 + + - name: Setup the environment + run: | + sudo pip3 install meson==0.58.2 + sudo apt-get install nasm ninja-build + + - name: Assembling the ffmpeg-android-maker + run: ffmpeg-android-maker/ffmpeg-android-maker.sh -dav1d + env: + ANDROID_SDK_HOME: $ANDROID_HOME + + - name: Building the library, preparing sources and docs + run: ./gradlew assembleRelease androidSourcesJar javadocJar + + - name: Pushing the library to Maven Central (SNAPSHOT) + run: ./gradlew publishReleasePublicationToSonatypeRepository --max-workers 1 + env: + SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} + SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} + SIGNING_KEY: ${{ secrets.SIGNING_KEY }} + OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} + OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} + SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} + VERSION_SUFFIX: -SNAPSHOT \ No newline at end of file diff --git a/README.md b/README.md index 5f21c44..cacbf69 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ Library tries to recreate a raw file path from a Uri and pass it to FFmpeg. If i ## Using -The library is published on Github Packages, so you are able to use it as a dependency: +The library is available via Maven Central, so you are able to use it as a dependency: ```groovy dependencies { @@ -47,26 +47,17 @@ dependencies { repositories { // ... - maven { - name = "GitHubPackages" - url = uri("https://maven.pkg.github.com/Javernaut/MediaFile") - credentials { - username = project.findProperty("gpr.user") ?: System.getenv("USERNAME") - password = project.findProperty("gpr.key") ?: System.getenv("TOKEN") - } - } + mavenCentral() } ``` -**Attention:** since the Github Packages are used, in order to get access to it you have to generate a Personal Access Token on Github and setup your environment with it. See [here](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-gradle-registry) for more information. Migrating to somethings simpler is planned. - ## Build on your own In order to compile the library yourself, you have to get [ffmpeg-android-maker](https://github.com/Javernaut/ffmpeg-android-maker) source code and compile it. It is already added as a submodule. So the first thing to do is to load it: `git submodule update --init` -Then you need to setup and execute the ffmpeg-android-maker's script. The command used to generate the artifacts for Github Packages looks like this: +Then you need to setup and execute the ffmpeg-android-maker's script. The command used to generate the artifacts for Maven Central looks like this: `./ffmpeg-android-maker.sh -dav1d` diff --git a/build.gradle b/build.gradle index 3d48a74..f54a17c 100644 --- a/build.gradle +++ b/build.gradle @@ -1,21 +1,26 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. +apply plugin: 'io.github.gradle-nexus.publish-plugin' +apply from: "${rootDir}/scripts/publish-root.gradle" + +// The gradle-nexus.publish-plugin considers the Project.version to pick the repository url (staging or snapshot) +group = PUBLISH_GROUP_ID +version = PUBLISH_VERSION + buildscript { repositories { google() mavenCentral() + maven { + url "https://plugins.gradle.org/m2/" + } } dependencies { - classpath "com.android.tools.build:gradle:7.0.0" + classpath "com.android.tools.build:gradle:7.0.1" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21" classpath "org.jetbrains.dokka:dokka-gradle-plugin:1.5.0" - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files + classpath 'io.github.gradle-nexus:publish-plugin:1.1.0' } } task clean(type: Delete) { delete rootProject.buildDir -} - -apply from: "${rootDir}/scripts/publish-root.gradle" \ No newline at end of file +} \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 5757565..13855f1 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Sun Aug 01 14:10:35 EEST 2021 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/media-file/build.gradle b/media-file/build.gradle index 859979f..cf9a9d2 100644 --- a/media-file/build.gradle +++ b/media-file/build.gradle @@ -4,9 +4,7 @@ plugins { } ext { - PUBLISH_GROUP_ID = 'io.github.javernaut' PUBLISH_ARTIFACT_ID = 'mediafile' - PUBLISH_VERSION = '0.4.0' } apply from: "${rootDir}/scripts/publish-module.gradle" diff --git a/scripts/publish-module.gradle b/scripts/publish-module.gradle index 8662cfe..df9211a 100644 --- a/scripts/publish-module.gradle +++ b/scripts/publish-module.gradle @@ -23,21 +23,8 @@ artifacts { archives javadocJar } -group = PUBLISH_GROUP_ID -version = PUBLISH_VERSION - afterEvaluate { publishing { - repositories { - maven { - name = "GitHubPackages" - url = uri("https://maven.pkg.github.com/Javernaut/MediaFile") - credentials { - username = rootProject.ext["gihtubPackages.user"] - password = rootProject.ext["gihtubPackages.token"] - } - } - } publications { release(MavenPublication) { groupId PUBLISH_GROUP_ID diff --git a/scripts/publish-root.gradle b/scripts/publish-root.gradle index 6b0222f..459fc64 100644 --- a/scripts/publish-root.gradle +++ b/scripts/publish-root.gradle @@ -1,9 +1,11 @@ // Create variables with empty default values +ext["ossrhUsername"] = '' +ext["ossrhPassword"] = '' +ext["sonatypeStagingProfileId"] = '' +ext["versionSuffix"] = '' ext["signing.keyId"] = '' ext["signing.password"] = '' ext["signing.key"] = '' -ext["gihtubPackages.user"] = '' -ext["gihtubPackages.token"] = '' File secretPropsFile = project.rootProject.file('local.properties') if (secretPropsFile.exists()) { @@ -13,9 +15,29 @@ if (secretPropsFile.exists()) { p.each { name, value -> ext[name] = value } } else { // Use system environment variables + ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME') + ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD') + ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID') + ext["versionSuffix"] = System.getenv('VERSION_SUFFIX') ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID') ext["signing.password"] = System.getenv('SIGNING_PASSWORD') ext["signing.key"] = System.getenv('SIGNING_KEY') - ext["gihtubPackages.user"] = System.getenv('GITHUB_USERNAME') - ext["gihtubPackages.token"] = System.getenv('GITHUB_TOKEN') +} + +// 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/")) + } + } +} + +ext { + PUBLISH_GROUP_ID = 'io.github.javernaut' + PUBLISH_VERSION = '1.0.0' + versionSuffix } \ No newline at end of file