Skip to content

Commit

Permalink
Migrating to Maven Central
Browse files Browse the repository at this point in the history
  • Loading branch information
Javernaut committed Aug 23, 2021
1 parent b17df1e commit 52f01b5
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 40 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
@@ -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 }}
43 changes: 43 additions & 0 deletions .github/workflows/publish-snapshot.yml
Original file line number Diff line number Diff line change
@@ -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
15 changes: 3 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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`

Expand Down
21 changes: 13 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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"
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
2 changes: 0 additions & 2 deletions media-file/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
13 changes: 0 additions & 13 deletions scripts/publish-module.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 26 additions & 4 deletions scripts/publish-root.gradle
Original file line number Diff line number Diff line change
@@ -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()) {
Expand All @@ -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
}

0 comments on commit 52f01b5

Please sign in to comment.