Skip to content

Commit 209f292

Browse files
authored
Create workflow to publish to maven central (#2)
Created workflow to publish to maven central
1 parent 4a669d1 commit 209f292

File tree

4 files changed

+144
-148
lines changed

4 files changed

+144
-148
lines changed

.github/workflows/gradle.yml

Lines changed: 65 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,70 @@ jobs:
2828
with:
2929
java-version: 1.8
3030
- name: Build with Gradle
31-
run: gradle build
32-
- uses: actions/upload-artifact@v2
31+
shell: bash
32+
run: ./gradlew build
33+
- name: Upload artifact
34+
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macOS-latest'
35+
uses: actions/upload-artifact@v2
3336
with:
3437
name: Package-${{ matrix.os }}
35-
path: build/libs
38+
path: build/natives/lib/Release
39+
- name: Upload artifact
40+
if: matrix.os == 'windows-latest'
41+
uses: actions/upload-artifact@v2
42+
with:
43+
name: Package-${{ matrix.os }}
44+
path: build/natives/bin/Release
45+
46+
combine:
47+
name: Download platform-specific binaries and combine into single JAR
48+
needs: [build]
49+
runs-on: ubuntu-latest
50+
steps:
51+
- name: Install CMake
52+
shell: bash
53+
run: sudo apt-get install cmake
54+
- uses: actions/checkout@v2
55+
with:
56+
submodules: 'recursive'
57+
- name: Set up JDK 1.8
58+
uses: actions/setup-java@v1
59+
with:
60+
java-version: 1.8
61+
- name: Build with Gradle
62+
shell: bash
63+
run: ./gradlew build -x test
64+
- name: Create directory
65+
shell: bash
66+
run: |
67+
mkdir -p ./build/natives/downloads
68+
- name: Download Linux binaries
69+
uses: actions/download-artifact@v2
70+
with:
71+
name: Package-ubuntu-latest
72+
path: ./build/natives/downloads/
73+
- name: Download Darwin binaries
74+
uses: actions/download-artifact@v2
75+
with:
76+
name: Package-macos-latest
77+
path: ./build/natives/downloads/
78+
- name: Download Windows binaries
79+
uses: actions/download-artifact@v2
80+
with:
81+
name: Package-windows-latest
82+
path: ./build/natives/downloads/
83+
- name: Repackage JAR with all binaries
84+
shell: bash
85+
run: ./gradlew build -x test
86+
- name: Create pom file for maven
87+
run: ./gradlew createPom
88+
- name: Upload pom file
89+
uses: actions/upload-artifact@v2
90+
with:
91+
name: PomFile
92+
path: ./build/pom/
93+
- name: Upload final JAR
94+
uses: actions/upload-artifact@v2
95+
with:
96+
name: FinalJAR
97+
path: build/libs

.github/workflows/publish.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Publish
2+
on:
3+
release:
4+
types: [published]
5+
6+
jobs:
7+
publish:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Download JAR
12+
uses: dawidd6/action-download-artifact@v2
13+
with:
14+
workflow: gradle.yml
15+
workflow_conclusion: success
16+
commit: ${{ github.sha }}
17+
name: FinalJAR
18+
path: ./downloads
19+
- name: Download POM file
20+
uses: dawidd6/action-download-artifact@v2
21+
with:
22+
workflow: gradle.yml
23+
commit: ${{ github.sha }}
24+
name: PomFile
25+
path: ./downloads
26+
- name: Upload setup
27+
working-directory: downloads
28+
shell: bash
29+
env:
30+
secret_key: ${{ secrets.SECRET_KEY }}
31+
settings_xml: ${{ secrets.SETTINGS_XML }}
32+
run: |
33+
sudo apt install gnupg2
34+
sudo apt install maven
35+
gpg --import <(printenv secret_key | base64 --decode)
36+
touch settings.xml && chmod 0600 settings.xml && printenv settings_xml > settings.xml
37+
echo "sources_jar=$(find . -type f -name "*-sources.jar")" >> $GITHUB_ENV
38+
echo "javadoc_jar=$(find . -type f -name "*-javadoc.jar")" >> $GITHUB_ENV
39+
echo "lib_jar=$(find . -type f -name "*.[0-9].jar")" >> $GITHUB_ENV
40+
echo "pom_file=$(find . -type f -name "*.pom")" >> $GITHUB_ENV
41+
42+
- name: Upload
43+
working-directory: downloads
44+
shell: bash
45+
env:
46+
secret_key: ${{ secrets.SECRET_KEY }}
47+
settings_xml: ${{ secrets.SETTINGS_XML }}
48+
run: |
49+
{
50+
mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=ossrh -DpomFile=$pom_file -Dfile=$lib_jar -Dpackaging=jar -s ./settings.xml &&
51+
mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=ossrh -DpomFile=$pom_file -Dfile=$javadoc_jar -Dpackaging=jar -Dclassifier=javadoc -s ./settings.xml &&
52+
mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=ossrh -DpomFile=$pom_file -Dfile=$sources_jar -Dpackaging=jar -Dclassifier=sources -s ./settings.xml;
53+
} || { rm settings.xml; exit 1}
54+
rm settings.xml

build.gradle

Lines changed: 25 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,16 @@ buildscript {
88
}
99
dependencies {
1010
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.+'
11-
classpath 'net.anshulverma.gradle:gradle-fileupload-plugin:1.0.4'
1211
}
1312
}
1413

1514
plugins {
1615
id 'java'
1716
id 'java-library'
1817
id 'maven-publish'
18+
id 'maven'
1919
}
2020
apply plugin: 'com.jfrog.bintray'
21-
apply plugin: 'net.anshulverma.gradle.fileupload'
2221

2322
repositories {
2423
// Use jcenter for resolving dependencies.
@@ -31,12 +30,6 @@ sourceCompatibility = 1.8
3130
targetCompatibility = 1.8
3231

3332
dependencies {
34-
// This dependency is exported to consumers, that is to say found on their compile classpath.
35-
api 'org.apache.commons:commons-math3:3.6.1'
36-
37-
// This dependency is used internally, and not exposed to consumers on their own compile classpath.
38-
implementation 'com.google.guava:guava:28.2-jre'
39-
4033
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.0'
4134
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.6.0'
4235
}
@@ -116,150 +109,37 @@ task javadocJar(type: Jar, dependsOn: javadoc) {
116109
from javadoc.destinationDir
117110
}
118111

119-
task nativeUpload {
120-
dependsOn compileJNI
121-
doLast {
122-
exec {
123-
if (OperatingSystem.current().isLinux()) {
124-
commandLine 'sh', '-c', 'curl -T build/natives/lib/Release/Linux/libjotio-' + version.toString() + '.so -u' + System.getProperty('bintray.user').toString() + ':' + System.getProperty('bintray.key').toString() + ' https://api.bintray.com/content/karthikriyer/java-opentimelineio/OpenTimelineIO-Linux/' + version.toString() + '/Linux/' + version.toString() + '/libjotio-' + version.toString() + '.so &&' +
125-
'curl -T build/natives/lib/Release/Linux/libopentime.so -u' + System.getProperty('bintray.user').toString() + ':' + System.getProperty('bintray.key').toString() + ' https://api.bintray.com/content/karthikriyer/java-opentimelineio/OpenTimelineIO-Linux/' + version.toString() + '/Linux/' + version.toString() + '/libopentime.so &&' +
126-
'curl -T build/natives/lib/Release/Linux/libopentimelineio.so -u' + System.getProperty('bintray.user').toString() + ':' + System.getProperty('bintray.key').toString() + ' https://api.bintray.com/content/karthikriyer/java-opentimelineio/OpenTimelineIO-Linux/' + version.toString() + '/Linux/' + version.toString() + '/libopentimelineio.so'
127-
} else if (OperatingSystem.current().isMacOsX()) {
128-
commandLine 'sh', '-c', "cmd", "/c", 'curl -T build/natives/lib/Release/Darwin/jotio-' + version.toString() + '.dylib -u' + System.getProperty('bintray.user').toString() + ':' + System.getProperty('bintray.key').toString() + ' https://api.bintray.com/content/karthikriyer/java-opentimelineio/OpenTimelineIO-Darwin/' + version.toString() + '/Darwin/' + version.toString() + '/libjotio-' + version.toString() + '.dylib &&' +
129-
'curl -T build/natives/lib/Release/Linux/opentime.dylib -u' + System.getProperty('bintray.user').toString() + ':' + System.getProperty('bintray.key').toString() + ' https://api.bintray.com/content/karthikriyer/java-opentimelineio/OpenTimelineIO-Linux/' + version.toString() + '/Linux/' + version.toString() + '/libopentime.dylib &&' +
130-
'curl -T build/natives/lib/Release/Linux/opentimelineio.dylib -u' + System.getProperty('bintray.user').toString() + ':' + System.getProperty('bintray.key').toString() + ' https://api.bintray.com/content/karthikriyer/java-opentimelineio/OpenTimelineIO-Linux/' + version.toString() + '/Linux/' + version.toString() + '/libopentimelineio.dylib'
131-
} else if (OperatingSystem.current().isWindows()) {
132-
commandLine "cmd", "/c", 'curl -T build\\natives\\bin\\Release\\Windows\\jotio-' + version.toString() + '.dll -u' + System.getProperty('bintray.user').toString() + ':' + System.getProperty('bintray.key').toString() + ' https://api.bintray.com/content/karthikriyer/java-opentimelineio/OpenTimelineIO-Windows/' + version.toString() + '/Windows/' + version.toString() + '/jotio-' + version.toString() + '.dll &&' +
133-
' curl -T build\\natives\\bin\\Release\\Windows\\opentime.dll -u' + System.getProperty('bintray.user').toString() + ':' + System.getProperty('bintray.key').toString() + ' https://api.bintray.com/content/karthikriyer/java-opentimelineio/OpenTimelineIO-Windows/' + version.toString() + '/Windows/' + version.toString() + '/opentime.dll &&' +
134-
' curl -T build\\natives\\bin\\Release\\Windows\\opentimelineio.dll -u' + System.getProperty('bintray.user').toString() + ':' + System.getProperty('bintray.key').toString() + ' https://api.bintray.com/content/karthikriyer/java-opentimelineio/OpenTimelineIO-Windows/' + version.toString() + '/Windows/' + version.toString() + '/opentimelineio.dll'
135-
}
136-
}
137-
}
138-
}
139-
140-
task nativeDownload {
141-
outputs.upToDateWhen { false }
142-
doLast {
143-
exec {
144-
if (OperatingSystem.current().isLinux()) {
145-
commandLine 'sh', '-c', 'mkdir -p build/natives/downloads/Linux &&' +
146-
'mkdir -p build/natives/downloads/Windows &&' +
147-
'mkdir -p build/natives/downloads/Darwin &&' +
148-
149-
'curl -L --fail "https://dl.bintray.com/karthikriyer/java-opentimelineio/Linux/' + version.toString() + '/libjotio-' + version.toString() + '.so" -o build/natives/downloads/Linux/libjotio-' + version.toString() + '.so && ' +
150-
'curl -L --fail "https://dl.bintray.com/karthikriyer/java-opentimelineio/Linux/' + version.toString() + '/libopentime.so" -o build/natives/downloads/Linux/libopentime.so && ' +
151-
'curl -L --fail "https://dl.bintray.com/karthikriyer/java-opentimelineio/Linux/' + version.toString() + '/libopentimelineio.so" -o build/natives/downloads/Linux/libopentimelineio.so &&' +
152-
153-
'curl -L --fail "https://dl.bintray.com/karthikriyer/java-opentimelineio/Windows/' + version.toString() + '/jotio-' + version.toString() + '.dll" > build/natives/downloads/Windows/jotio-' + version.toString() + '.dll && ' +
154-
'curl -L --fail "https://dl.bintray.com/karthikriyer/java-opentimelineio/Windows/' + version.toString() + '/opentime.dll" > build/natives/downloads/Windows/opentime.dll && ' +
155-
'curl -L --fail "https://dl.bintray.com/karthikriyer/java-opentimelineio/Windows/' + version.toString() + '/opentimelineio.dll" > build/natives/downloads/Windows/opentimelineio.dll'
156-
157-
// 'curl -L --fail "https://dl.bintray.com/karthikriyer/java-opentimelineio/Darwin/' + version.toString() + '/libjotio-' + version.toString() + '.dylib -o build/natives/downloads/Darwin/libjotio-' + version.toString() + '.dylib && ' +
158-
// 'curl -L --fail "https://dl.bintray.com/karthikriyer/java-opentimelineio/Darwin/' + version.toString() + '/libopentime.dylib -o build/natives/downloads/Darwin/libopentime.dylib && ' +
159-
// 'curl -L --fail "https://dl.bintray.com/karthikriyer/java-opentimelineio/Darwin/' + version.toString() + '/libopentimelineio.dylib -o build/natives/downloads/Darwin/libopentimelineio.dylib'
160-
} else if (OperatingSystem.current().isMacOsX()) {
161-
commandLine 'sh', '-c', 'mkdir -p build/natives/downloads/Linux &&' +
162-
'mkdir -p build/natives/downloads/Windows &&' +
163-
'mkdir -p build/natives/downloads/Darwin &&' +
164-
165-
'curl -L --fail "https://dl.bintray.com/karthikriyer/java-opentimelineio/Linux/' + version.toString() + '/libjotio-' + version.toString() + '.so" -o build/natives/downloads/Linux/libjotio-' + version.toString() + '.so && ' +
166-
'curl -L --fail "https://dl.bintray.com/karthikriyer/java-opentimelineio/Linux/' + version.toString() + '/libopentime.so" -o build/natives/downloads/Linux/libopentime.so && ' +
167-
'curl -L --fail "https://dl.bintray.com/karthikriyer/java-opentimelineio/Linux/' + version.toString() + '/libopentimelineio.so" -o build/natives/downloads/Linux/libopentimelineio.so &&' +
168-
169-
'curl -L --fail "https://dl.bintray.com/karthikriyer/java-opentimelineio/Windows/' + version.toString() + '/jotio-' + version.toString() + '.dll" > build/natives/downloads/Windows/jotio-' + version.toString() + '.dll && ' +
170-
'curl -L --fail "https://dl.bintray.com/karthikriyer/java-opentimelineio/Windows/' + version.toString() + '/opentime.dll" > build/natives/downloads/Windows/opentime.dll && ' +
171-
'curl -L --fail "https://dl.bintray.com/karthikriyer/java-opentimelineio/Windows/' + version.toString() + '/opentimelineio.dll" > build/natives/downloads/Windows/opentimelineio.dll'
172-
173-
// 'curl -L --fail "https://dl.bintray.com/karthikriyer/java-opentimelineio/Darwin/' + version.toString() + '/libjotio-' + version.toString() + '.dylib -o build/natives/downloads/Darwin/libjotio-' + version.toString() + '.dylib && ' +
174-
// 'curl -L --fail "https://dl.bintray.com/karthikriyer/java-opentimelineio/Darwin/' + version.toString() + '/libopentime.dylib -o build/natives/downloads/Darwin/libopentime.dylib && ' +
175-
// 'curl -L --fail "https://dl.bintray.com/karthikriyer/java-opentimelineio/Darwin/' + version.toString() + '/libopentimelineio.dylib -o build/natives/downloads/Darwin/libopentimelineio.dylib'
176-
} else if (OperatingSystem.current().isWindows()) {
177-
commandLine "cmd", "/c", 'if not exist build\\natives\\downloads\\Windows mkdir build\\natives\\downloads\\Windows &&' +
178-
'if not exist build\\natives\\downloads\\Linux mkdir build\\natives\\downloads\\Linux &&' +
179-
'if not exist build\\natives\\downloads\\Darwin mkdir build\\natives\\downloads\\Darwin &&' +
180-
181-
'curl -L --fail "https://dl.bintray.com/karthikriyer/java-opentimelineio/Windows/' + version.toString() + '/jotio-' + version.toString() + '.dll" -o build\\natives\\downloads\\Windows\\jotio-' + version.toString() + '.dll && ' +
182-
'curl -L --fail "https://dl.bintray.com/karthikriyer/java-opentimelineio/Windows/' + version.toString() + '/opentime.dll" -o build\\natives\\downloads\\Windows\\opentime.dll && ' +
183-
'curl -L --fail "https://dl.bintray.com/karthikriyer/java-opentimelineio/Windows/' + version.toString() + '/opentimelineio.dll" -o build\\natives\\downloads\\Windows\\opentimelineio.dll &&' +
184-
185-
'curl -L --fail "https://dl.bintray.com/karthikriyer/java-opentimelineio/Linux/' + version.toString() + '/jotio-' + version.toString() + '.so" -o build\\natives\\downloads\\Linux\\jotio-' + version.toString() + '.so && ' +
186-
'curl -L --fail "https://dl.bintray.com/karthikriyer/java-opentimelineio/Linux/' + version.toString() + '/opentime.so" -o build\\natives\\downloads\\Linux\\opentime.so && ' +
187-
'curl -L --fail "https://dl.bintray.com/karthikriyer/java-opentimelineio/Linux/' + version.toString() + '/opentimelineio.so" -o build\\natives\\downloads\\Linux\\opentimelineio.so '
188-
189-
// 'curl -L --fail "https://dl.bintray.com/karthikriyer/java-opentimelineio/Darwin/' + version.toString() + '/jotio-' + version.toString() + '.dylib" -o build\\natives\\downloads\\Darwin\\jotio-' + version.toString() + '.dylib && ' +
190-
// 'curl -L --fail "https://dl.bintray.com/karthikriyer/java-opentimelineio/Darwin/' + version.toString() + '/opentime.dylib" -o build\\natives\\downloads\\Darwin\\opentime.dylib && ' +
191-
// 'curl -L --fail "https://dl.bintray.com/karthikriyer/java-opentimelineio/Darwin/' + version.toString() + '/opentimelineio.dylib" -o build\\natives\\downloads\\Darwin\\opentimelineio.dylib'
192-
}
193-
}
194-
}
195-
}
196-
197112
artifacts {
198113
archives sourcesJar
199114
archives javadocJar
200115
}
201116

202-
def pomConfig = {
203-
licenses {
204-
license {
205-
name "Modified Apache 2.0 License"
206-
url "https://github.com/PixarAnimationStudios/OpenTimelineIO/blob/master/LICENSE.txt"
207-
distribution "repo"
208-
}
209-
}
210-
developers {
211-
developer {
212-
id "OpenTimelineIO"
213-
name "Contributors to the OpenTimelineIO project"
214-
email ""
215-
}
216-
}
217-
218-
scm {
219-
url "https://github.com/PixarAnimationStudios/OpenTimelineIO"
220-
}
221-
}
222-
223-
publishing {
224-
publications {
225-
mavenPublication(MavenPublication) {
226-
from components.java
227-
artifact sourcesJar {
228-
classifier "sources"
117+
task createPom {
118+
pom {
119+
project {
120+
groupId 'io.opentimeline'
121+
artifactId 'opentimelineio'
122+
version version.toString()
123+
description 'OpenTimelineIO is an interchange format and API for editorial cut information. OTIO is not a container format for media, rather it contains information about the order and length of cuts and references to external media.'
124+
url 'opentimeline.io'
125+
name 'OpenTimelineIO'
126+
licenses {
127+
license {
128+
name "Modified Apache 2.0 License"
129+
url "https://github.com/PixarAnimationStudios/OpenTimelineIO/blob/master/LICENSE.txt"
130+
distribution "repo"
131+
}
229132
}
230-
artifact javadocJar {
231-
classifier "javadoc"
133+
developers {
134+
developer {
135+
id "OpenTimelineIO"
136+
name "Contributors to the OpenTimelineIO project"
137+
138+
}
232139
}
233-
groupId 'io.opentimeline'
234-
artifactId 'java-opentimelineio'
235-
version '0.14.0'
236-
pom.withXml {
237-
def root = asNode()
238-
root.appendNode('description', 'OpenTimelineIO is an interchange format and API for editorial cut information. OTIO is not a container format for media, rather it contains information about the order and length of cuts and references to external media.')
239-
root.appendNode('name', 'OpenTimelineIO')
240-
root.appendNode('url', 'https://github.com/PixarAnimationStudios/OpenTimelineIO')
241-
root.children().last() + pomConfig
140+
scm {
141+
url "https://github.com/PixarAnimationStudios/OpenTimelineIO"
242142
}
243143
}
244-
}
144+
}.writeTo("build/pom/opentimelineio-" + version.toString() + ".pom")
245145
}
246-
247-
bintray {
248-
user = System.getProperty('bintray.user')
249-
key = System.getProperty('bintray.key')
250-
publications = ['mavenPublication']
251-
252-
pkg {
253-
repo = 'java-opentimelineio'
254-
name = 'OpenTimelineIO'
255-
userOrg = ''
256-
licenses = ['Apache-2.0']
257-
vcsUrl = 'https://github.com/KarthikRIyer/OpenTimelineIO'
258-
version {
259-
name = '0.14.0'
260-
desc = '0.14.0'
261-
released = new Date()
262-
}
263-
}
264-
265-
}

gradlew

100644100755
File mode changed.

0 commit comments

Comments
 (0)