diff --git a/.github/ci-gradle.properties b/.github/ci-gradle.properties new file mode 100644 index 0000000..bd882fd --- /dev/null +++ b/.github/ci-gradle.properties @@ -0,0 +1,4 @@ +org.gradle.daemon=false +org.gradle.parallel=true +org.gradle.jvmargs=-Xmx4608m -XX:MaxMetaspaceSize=1536m -XX:+HeapDumpOnOutOfMemoryError +kotlin.compiler.execution.strategy=in-process \ No newline at end of file diff --git a/.github/version.sh b/.github/version.sh new file mode 100755 index 0000000..4fbe36a --- /dev/null +++ b/.github/version.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +CWD="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" +PARENT="$(cd "$CWD"/.. >/dev/null 2>&1 && pwd)" + +set -e + +SEMVER_REG="([[:digit:]]+(\.[[:digit:]]+)+)" + +README_FILE="$PARENT/README.md" +VERSION_FILE="$PARENT/gradle/libs.versions.toml" + +NEW_VERSION="$ORG_GRADLE_PROJECT_VERSION_NAME" +if [ -z "$NEW_VERSION" ]; then + NEW_VERSION="$1" + if [ -n "$NEW_VERSION" ]; then + echo "Update README with version: '$NEW_VERSION'" + + if [[ "$OSTYPE" == "darwin"* ]]; then + # Update artifact versions in README.md + sed -i '' -E "s/\:$SEMVER_REG\"\)/\:$NEW_VERSION\"\)/" "$README_FILE" + + # Update version catalog in README.md + sed -i '' -E "s/transformerkt = \"$SEMVER_REG\"/transformerkt = \"$NEW_VERSION\"/" "$README_FILE" + else + sed -i -E "s/\:$SEMVER_REG\"/\:$NEW_VERSION\"/g" "$README_FILE" + sed -i -E "s/transformerkt = \"$SEMVER_REG\"/transformerkt = \"$NEW_VERSION\"/g" "$README_FILE" + fi + fi +fi + +# Update Kotlin badge in README.md +LIBS_KOTLIN_VERSION=$(grep "kotlin = " "$VERSION_FILE" | cut -d= -f2 | tr -d ' "') +if [ -z "$LIBS_KOTLIN_VERSION" ]; then + echo "Unable to find Kotlin version in '$VERSION_FILE'" +else + echo "Updating Kotlin version: '$LIBS_KOTLIN_VERSION'" + sed -i '' -E "s/kotlin-v$SEMVER_REG/kotlin-v$LIBS_KOTLIN_VERSION/" "$README_FILE" +fi + +# Update Media3 badge in README.md +LIBS_MEDIA3_VERSION=$(grep "androidx-media3 = " "$VERSION_FILE" | cut -d= -f2 | tr -d ' "') +if [ -z "$LIBS_MEDIA3_VERSION" ]; then + echo "Unable to find Media3 version in '$VERSION_FILE'" +else + echo "Updating Media3 version: '$LIBS_MEDIA3_VERSION'" + sed -i '' -E "s/media3#$SEMVER_REG/media3#$LIBS_MEDIA3_VERSION/" "$README_FILE" + sed -i '' -E "s/media3-$SEMVER_REG/media3-$LIBS_MEDIA3_VERSION/" "$README_FILE" + sed -i '' -E "s/version \`$SEMVER_REG/version \`$LIBS_MEDIA3_VERSION/" "$README_FILE" +fi diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml deleted file mode 100644 index e0b3799..0000000 --- a/.github/workflows/documentation.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: Documentation - -on: - workflow_dispatch: - push: - branches: - - main - -permissions: - contents: write - -jobs: - generate: - name: "Generate Documentation" - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 - - - name: setup-java - uses: actions/setup-java@v4 - with: - java-version: 17 - distribution: adopt - - - name: Gradle Wrapper Validation - uses: gradle/wrapper-validation-action@v1 - - - name: Generate documentation - uses: gradle/gradle-build-action@v2 - with: - arguments: :transformerkt:dokkaHtml - - - name: Deploy - uses: JamesIves/github-pages-deploy-action@v4 - with: - folder: transformerkt/build/dokka/html diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..7a2e8f6 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,81 @@ +name: Publish +on: + workflow_dispatch: + release: + types: [ prereleased, released ] + +permissions: + contents: write + +jobs: + release: + name: Publish library + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ github.event.release.tag_name }} + + - name: Copy CI gradle.properties + run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties + + - name: setup-java + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: adopt + + - name: Gradle Wrapper Validation + uses: gradle/wrapper-validation-action@v1 + + - name: Deploy to Sonatype + run: | + NEW_VERSION=$(echo "${GITHUB_REF}" | cut -d "/" -f3) + echo "New version: ${NEW_VERSION}" + export ORG_GRADLE_PROJECT_VERSION_NAME=${NEW_VERSION} + echo "RELEASE_VERSION=$NEW_VERSION" >> "$GITHUB_ENV" + ./gradlew publishAllPublicationsToMavenCentral --no-configuration-cache --stacktrace + env: + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_PASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKeyId: ${{ secrets.SIGNING_KEY_ID }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }} + + - name: Update README for ${{ env.RELEASE_VERSION }} + run: ./.github/version.sh "${RELEASE_VERSION}" + + - name: Commit changes to README to ${{ env.branch }} + uses: EndBug/add-and-commit@v9 + with: + add: "./README.md" + message: "Update README.md with version ${{env.RELEASE_VERSION}}" + new_branch: main + + documentation: + name: "Generate Documentation" + runs-on: ubuntu-latest + needs: release + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Java + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: adopt + + - name: Gradle Wrapper Validation + uses: gradle/wrapper-validation-action@v1 + + - name: Generate documentation + uses: gradle/gradle-build-action@v2 + with: + arguments: :transformerkt:dokkaHtml + + - name: Deploy + uses: JamesIves/github-pages-deploy-action@v4 + with: + folder: transformerkt/build/dokka/html \ No newline at end of file diff --git a/README.md b/README.md index 92be98f..d9ac486 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,7 @@ around [media3.transformer](https://developer.android.com/guide/topics/media/tra You can view the TransformerKt KDocs at [docs.transformerkt.dev](https://docs.transformerkt.dev) -- Using `media3.transformer` - version [`1.2.0`](https://github.com/androidx/media/releases) +- Using `media3.transformer` [version `1.2.0`](https://github.com/androidx/media/releases) ## Table of Contents @@ -48,35 +47,23 @@ for more information. ## Getting Started -First you need to add jitpack to either your root level `build.gradle.kts` or -your `settings.gradle.kts` file: - -In `build.gradle.kts`: +Add the dependency to your app level `build.gradle.kts` file: ```kotlin -allprojects { - repositories { - maven { url = uri("https://jitpack.io") } - } +dependencies { + implementation("dev.transformerkt:transformerkt:3.3.2") } ``` -Or `settings.gradle.kts`: +Or using Version Catalogs: -```kotlin -dependencyResolutionManagement { - repositories { - maven { url = uri("https://jitpack.io") } - } -} -``` +```toml +[versions] +transformerkt = "3.3.2" -Then add the dependency to your app level `build.gradle.kts` file: +[libraries] +transformerkt = { group = "dev.transformerkt", name = "transformerkt", version.ref = "transformerkt" } -```kotlin -dependencies { - implementation("dev.transformerkt:transformerkt::3.3.2") -} ``` ## Usage @@ -90,8 +77,6 @@ Then you need an input video or image file. `TransformerKt` supports the followi - [MediaItem](https://developer.android.com/reference/androidx/media3/common/MediaItem). - [EditedMediaItem](https://github.com/androidx/media/blob/0fce8f416b54124605c1ed8aa72af98c94602834/libraries/transformer/src/main/java/androidx/media3/transformer/EditedMediaItem.java). - - Note this class is new as of `media3` version `1.1.0-alpha01`. The library changed the way you - apply effects and customizations to the MediaItem. - A `Uri` pointing to somewhere on the device. - A `File` object pointing to a file in the _app's_ sand-boxed storage. - Warning: Getting a `File` object to a file outside of the app's storage will probably cause a diff --git a/gradle.properties b/gradle.properties index 3c5031e..3d2a514 100644 --- a/gradle.properties +++ b/gradle.properties @@ -20,4 +20,29 @@ kotlin.code.style=official # Enables namespacing of each library's R class so that its R class includes only the # resources declared in the library itself and none from the library's dependencies, # thereby reducing the size of the R class for that library -android.nonTransitiveRClass=true \ No newline at end of file +android.nonTransitiveRClass=true + +# Maven +SONATYPE_HOST=S01 +SONATYPE_AUTOMATIC_RELEASE=true +RELEASE_SIGNING_ENABLED=true + +GROUP=dev.transformerkt + +POM_NAME=transformerkt +POM_DESCRIPTION=A Kotlin coroutine wrapper around Media3's Transformer API. +POM_INCEPTION_YEAR=2023 +POM_URL=https://github.com/jordond/transformerkt + +POM_LICENCE_NAME=The MIT License +POM_LICENCE_URL=https://github.com/jordond/transformerkt/blob/master/LICENSE +POM_LICENCE_DIST=repo + +POM_SCM_URL=https://github.com/jordond/kmpalette +POM_SCM_CONNECTION=scm:git:https://github.com/jordond/transformerkt.git +POM_SCM_DEV_CONNECTION=scm:git:git@github.com:jordond/transformerkt.git + +POM_DEVELOPER_ID=jordond +POM_DEVELOPER_NAME=Jordon de Hoog +POM_DEVELOPER_URL=https://github.com/jordond +POM_DEVELOPER_EMAIL=jordon.dehoog@gmail.com \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index f23728d..570399a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -26,6 +26,7 @@ napier = "2.6.1" binaryCompatibility = "0.13.2" poko = "0.15.1" coil = "2.5.0" +publish = "0.26.0" [libraries] coil-compose = { module = "io.coil-kt:coil-compose", version.ref = "coil" } @@ -71,3 +72,4 @@ dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" } hilt = { id = "com.google.dagger.hilt.android", version.ref = "dagger" } binaryCompatibility = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "binaryCompatibility" } poko = { id = "dev.drewhamilton.poko", version.ref = "poko" } +publish = { id = "com.vanniktech.maven.publish", version.ref = "publish" } diff --git a/transformerkt/build.gradle.kts b/transformerkt/build.gradle.kts index 921d04e..5703fea 100644 --- a/transformerkt/build.gradle.kts +++ b/transformerkt/build.gradle.kts @@ -3,7 +3,7 @@ plugins { alias(libs.plugins.kotlinAndroid) alias(libs.plugins.dokka) alias(libs.plugins.poko) - id("maven-publish") + alias(libs.plugins.publish) } android { @@ -54,17 +54,4 @@ dependencies { /* Misc */ dokkaPlugin(libs.dokka.android) -} - -publishing { - publications { - register("release") { - groupId = "dev.transformerkt" - artifactId = "transformerkt" - - afterEvaluate { - from(components["release"]) - } - } - } -} +} \ No newline at end of file