Skip to content

Commit 2eaf0d8

Browse files
authored
Add release workflow using Github Actions (#43)
* Proposal for a release workflow using Gradle and GH Actions. Similar to transloadit Java SDK * Implement requested changes * Delete version.txt * Requested Changes
1 parent 9213a1f commit 2eaf0d8

3 files changed

Lines changed: 102 additions & 36 deletions

File tree

.github/workflows/release.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Publish to Maven Repository
2+
on:
3+
release:
4+
types: [published]
5+
6+
jobs:
7+
publish_to_maven:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout Repository
11+
uses: actions/checkout@v2
12+
- name: Set up JDK
13+
uses: actions/setup-java@v2
14+
with:
15+
java-version: '8'
16+
distribution: 'adopt'
17+
- name: Grant execute permission for gradlew
18+
run: chmod +x gradlew
19+
- name: Publish package to Maven Repository
20+
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
21+
env:
22+
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
23+
SONATYPE_KEY: ${{ secrets.SONATYPE_KEY }}
24+
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
25+
SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
26+
SIGNING_KEY_AMORED: ${{ secrets.SIGNING_KEY_AMORED }}

build.gradle

Lines changed: 75 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
plugins {
2+
id 'signing'
3+
id('io.github.gradle-nexus.publish-plugin') version '1.1.0'
4+
id 'maven-publish'
5+
}
6+
17
apply plugin: 'java'
28
apply plugin: 'maven'
39

@@ -14,6 +20,10 @@ allprojects {
1420
sourceCompatibility = 1.6
1521
targetCompatibility = 1.6
1622

23+
// load version number from file
24+
def config = new ConfigSlurper().parse(new File("${projectDir}/src/main/resources/version.properties").toURI().toURL())
25+
version = config.versionNumber
26+
1727
dependencies {
1828
compile 'org.jetbrains:annotations:13.0'
1929
testCompile 'junit:junit:4.12'
@@ -22,49 +32,78 @@ dependencies {
2232
}
2333

2434
task sourcesJar(type: Jar, dependsOn: classes) {
25-
classifier = 'sources'
35+
archiveClassifier.set('sources')
2636
from sourceSets.main.allSource
2737
}
2838

2939
task javadocJar(type: Jar, dependsOn: javadoc) {
30-
classifier = 'javadoc'
40+
archiveClassifier.set('javadoc')
3141
from javadoc.destinationDir
3242
}
3343

34-
task createPom {
35-
doLast {
36-
pom {
37-
project {
38-
groupId 'io.tus.java.client'
39-
artifactId 'tus-java-client'
40-
name 'tus-java-client'
41-
version project.getProperties().get('pomVersion')
42-
packaging 'pom'
43-
description 'Java client for tus, the resumable file uploading protocol.'
44-
url 'http://tus.io'
45-
46-
scm {
47-
url 'https://github.com/tus/tus-java-client'
48-
connection 'https://github.com/tus/tus-java-client'
49-
developerConnection 'https://github.com/tus/tus-java-client'
50-
}
51-
52-
developers {
53-
developer {
54-
id 'acconut'
55-
name 'Marius Kleidl'
56-
email 'maerious@gmail.com'
57-
}
58-
}
59-
60-
inceptionYear '2015'
61-
licenses {
62-
license {
63-
name 'The MIT License (MIT)'
64-
url 'http://opensource.org/licenses/MIT'
65-
}
66-
}
44+
artifacts {
45+
archives sourcesJar, javadocJar
46+
}
47+
48+
49+
def pomConfig = {
50+
name 'tus-java-client'
51+
url 'https://tus.io'
52+
53+
scm {
54+
url 'https://github.com/tus/tus-java-client'
55+
connection 'https://github.com/tus/tus-java-client'
56+
developerConnection 'https://github.com/tus/tus-java-client'
57+
}
58+
59+
developers {
60+
developer {
61+
id 'acconut'
62+
name 'Marius Kleidl'
63+
email 'maerious@gmail.com'
64+
}
65+
}
66+
67+
inceptionYear '2015'
68+
licenses {
69+
license {
70+
name 'The MIT License (MIT)'
71+
url 'http://opensource.org/licenses/MIT'
72+
}
73+
}
74+
}
75+
76+
publishing {
77+
publications {
78+
mavenJava(MavenPublication) {
79+
groupId = 'io.tus.java.client'
80+
artifactId = 'tus-java-client'
81+
version
82+
artifact sourcesJar
83+
artifact javadocJar
84+
85+
pom.withXml {
86+
def root = asNode()
87+
root.appendNode('description', 'Java client for tus, the resumable file uploading protocol.')
88+
root.children().last() + pomConfig
6789
}
68-
}.writeTo("build/libs/pom.xml")
90+
}
91+
}
92+
}
93+
94+
signing {
95+
def signingKeyId = System.getenv("SIGNING_KEY_ID")
96+
def signingPassword = System.getenv("SIGNING_KEY_PASSWORD")
97+
def signingKey = System.getenv("SIGNING_KEY_AMORED")
98+
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
99+
sign publishing.publications.mavenJava
100+
}
101+
102+
nexusPublishing {
103+
repositories {
104+
sonatype {
105+
username = System.getenv("SONATYPE_USER")
106+
password = System.getenv("SONATYPE_KEY")
107+
}
69108
}
70109
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
versionNumber='0.4.4'

0 commit comments

Comments
 (0)