Skip to content
This repository has been archived by the owner on Feb 18, 2025. It is now read-only.

Commit

Permalink
CI: Switch to MavenCentral for publishing (#84)
Browse files Browse the repository at this point in the history
* switch to MavenCentral publishing

* fix version.sh

* Update README.md
  • Loading branch information
jordond authored Dec 19, 2023
1 parent c966bae commit 1f8e620
Show file tree
Hide file tree
Showing 8 changed files with 175 additions and 78 deletions.
4 changes: 4 additions & 0 deletions .github/ci-gradle.properties
Original file line number Diff line number Diff line change
@@ -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
50 changes: 50 additions & 0 deletions .github/version.sh
Original file line number Diff line number Diff line change
@@ -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
37 changes: 0 additions & 37 deletions .github/workflows/documentation.yml

This file was deleted.

81 changes: 81 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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
35 changes: 10 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
27 changes: 26 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down Expand Up @@ -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" }
17 changes: 2 additions & 15 deletions transformerkt/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -54,17 +54,4 @@ dependencies {

/* Misc */
dokkaPlugin(libs.dokka.android)
}

publishing {
publications {
register<MavenPublication>("release") {
groupId = "dev.transformerkt"
artifactId = "transformerkt"

afterEvaluate {
from(components["release"])
}
}
}
}
}

0 comments on commit 1f8e620

Please sign in to comment.