Skip to content

Commit 52f01b5

Browse files
committed
Migrating to Maven Central
1 parent b17df1e commit 52f01b5

File tree

8 files changed

+127
-40
lines changed

8 files changed

+127
-40
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Publish to Maven Central
2+
on:
3+
release:
4+
types: [ released ]
5+
jobs:
6+
build:
7+
runs-on: ubuntu-20.04
8+
9+
steps:
10+
- uses: actions/checkout@v2
11+
with:
12+
submodules: true
13+
14+
- name: Set up JDK 11
15+
uses: actions/setup-java@v2
16+
with:
17+
distribution: adopt
18+
java-version: 11
19+
20+
- name: Setup the environment
21+
run: |
22+
sudo pip3 install meson==0.58.2
23+
sudo apt-get install nasm ninja-build
24+
25+
- name: Assembling the ffmpeg-android-maker
26+
run: ffmpeg-android-maker/ffmpeg-android-maker.sh -dav1d
27+
env:
28+
ANDROID_SDK_HOME: $ANDROID_HOME
29+
30+
- name: Building the library, preparing sources and docs
31+
run: ./gradlew assembleRelease androidSourcesJar javadocJar
32+
33+
- name: Pushing the library to Maven Central
34+
run: ./gradlew publishReleasePublicationToSonatypeRepository closeAndReleaseSonatypeStagingRepository --max-workers 1
35+
env:
36+
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
37+
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
38+
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
39+
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
40+
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
41+
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Publish to Maven Central (SNAPSHOT)
2+
on:
3+
push:
4+
branches:
5+
- develop
6+
jobs:
7+
build:
8+
runs-on: ubuntu-20.04
9+
10+
steps:
11+
- uses: actions/checkout@v2
12+
with:
13+
submodules: true
14+
15+
- name: Set up JDK 11
16+
uses: actions/setup-java@v2
17+
with:
18+
distribution: adopt
19+
java-version: 11
20+
21+
- name: Setup the environment
22+
run: |
23+
sudo pip3 install meson==0.58.2
24+
sudo apt-get install nasm ninja-build
25+
26+
- name: Assembling the ffmpeg-android-maker
27+
run: ffmpeg-android-maker/ffmpeg-android-maker.sh -dav1d
28+
env:
29+
ANDROID_SDK_HOME: $ANDROID_HOME
30+
31+
- name: Building the library, preparing sources and docs
32+
run: ./gradlew assembleRelease androidSourcesJar javadocJar
33+
34+
- name: Pushing the library to Maven Central (SNAPSHOT)
35+
run: ./gradlew publishReleasePublicationToSonatypeRepository --max-workers 1
36+
env:
37+
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
38+
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
39+
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
40+
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
41+
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
42+
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
43+
VERSION_SUFFIX: -SNAPSHOT

README.md

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Library tries to recreate a raw file path from a Uri and pass it to FFmpeg. If i
3838

3939
## Using
4040

41-
The library is published on Github Packages, so you are able to use it as a dependency:
41+
The library is available via Maven Central, so you are able to use it as a dependency:
4242

4343
```groovy
4444
dependencies {
@@ -47,26 +47,17 @@ dependencies {
4747
4848
repositories {
4949
// ...
50-
maven {
51-
name = "GitHubPackages"
52-
url = uri("https://maven.pkg.github.com/Javernaut/MediaFile")
53-
credentials {
54-
username = project.findProperty("gpr.user") ?: System.getenv("USERNAME")
55-
password = project.findProperty("gpr.key") ?: System.getenv("TOKEN")
56-
}
57-
}
50+
mavenCentral()
5851
}
5952
```
6053

61-
**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.
62-
6354
## Build on your own
6455

6556
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:
6657

6758
`git submodule update --init`
6859

69-
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:
60+
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:
7061

7162
`./ffmpeg-android-maker.sh -dav1d`
7263

build.gradle

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
1-
// Top-level build file where you can add configuration options common to all sub-projects/modules.
1+
apply plugin: 'io.github.gradle-nexus.publish-plugin'
2+
apply from: "${rootDir}/scripts/publish-root.gradle"
3+
4+
// The gradle-nexus.publish-plugin considers the Project.version to pick the repository url (staging or snapshot)
5+
group = PUBLISH_GROUP_ID
6+
version = PUBLISH_VERSION
7+
28
buildscript {
39
repositories {
410
google()
511
mavenCentral()
12+
maven {
13+
url "https://plugins.gradle.org/m2/"
14+
}
615
}
716
dependencies {
8-
classpath "com.android.tools.build:gradle:7.0.0"
17+
classpath "com.android.tools.build:gradle:7.0.1"
918
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21"
1019
classpath "org.jetbrains.dokka:dokka-gradle-plugin:1.5.0"
11-
12-
// NOTE: Do not place your application dependencies here; they belong
13-
// in the individual module build.gradle files
20+
classpath 'io.github.gradle-nexus:publish-plugin:1.1.0'
1421
}
1522
}
1623

1724
task clean(type: Delete) {
1825
delete rootProject.buildDir
19-
}
20-
21-
apply from: "${rootDir}/scripts/publish-root.gradle"
26+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Sun Aug 01 14:10:35 EEST 2021
22
distributionBase=GRADLE_USER_HOME
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
44
distributionPath=wrapper/dists
55
zipStorePath=wrapper/dists
66
zipStoreBase=GRADLE_USER_HOME

media-file/build.gradle

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ plugins {
44
}
55

66
ext {
7-
PUBLISH_GROUP_ID = 'io.github.javernaut'
87
PUBLISH_ARTIFACT_ID = 'mediafile'
9-
PUBLISH_VERSION = '0.4.0'
108
}
119

1210
apply from: "${rootDir}/scripts/publish-module.gradle"

scripts/publish-module.gradle

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,8 @@ artifacts {
2323
archives javadocJar
2424
}
2525

26-
group = PUBLISH_GROUP_ID
27-
version = PUBLISH_VERSION
28-
2926
afterEvaluate {
3027
publishing {
31-
repositories {
32-
maven {
33-
name = "GitHubPackages"
34-
url = uri("https://maven.pkg.github.com/Javernaut/MediaFile")
35-
credentials {
36-
username = rootProject.ext["gihtubPackages.user"]
37-
password = rootProject.ext["gihtubPackages.token"]
38-
}
39-
}
40-
}
4128
publications {
4229
release(MavenPublication) {
4330
groupId PUBLISH_GROUP_ID

scripts/publish-root.gradle

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
// Create variables with empty default values
2+
ext["ossrhUsername"] = ''
3+
ext["ossrhPassword"] = ''
4+
ext["sonatypeStagingProfileId"] = ''
5+
ext["versionSuffix"] = ''
26
ext["signing.keyId"] = ''
37
ext["signing.password"] = ''
48
ext["signing.key"] = ''
5-
ext["gihtubPackages.user"] = ''
6-
ext["gihtubPackages.token"] = ''
79

810
File secretPropsFile = project.rootProject.file('local.properties')
911
if (secretPropsFile.exists()) {
@@ -13,9 +15,29 @@ if (secretPropsFile.exists()) {
1315
p.each { name, value -> ext[name] = value }
1416
} else {
1517
// Use system environment variables
18+
ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME')
19+
ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD')
20+
ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID')
21+
ext["versionSuffix"] = System.getenv('VERSION_SUFFIX')
1622
ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID')
1723
ext["signing.password"] = System.getenv('SIGNING_PASSWORD')
1824
ext["signing.key"] = System.getenv('SIGNING_KEY')
19-
ext["gihtubPackages.user"] = System.getenv('GITHUB_USERNAME')
20-
ext["gihtubPackages.token"] = System.getenv('GITHUB_TOKEN')
25+
}
26+
27+
// Set up Sonatype repository
28+
nexusPublishing {
29+
repositories {
30+
sonatype {
31+
stagingProfileId = sonatypeStagingProfileId
32+
username = ossrhUsername
33+
password = ossrhPassword
34+
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
35+
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
36+
}
37+
}
38+
}
39+
40+
ext {
41+
PUBLISH_GROUP_ID = 'io.github.javernaut'
42+
PUBLISH_VERSION = '1.0.0' + versionSuffix
2143
}

0 commit comments

Comments
 (0)