Skip to content

Commit 9fdb11f

Browse files
committed
Initial publishing workflow
1 parent 19c390f commit 9fdb11f

File tree

2 files changed

+112
-2
lines changed

2 files changed

+112
-2
lines changed

.github/workflows/publish.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Publish
2+
3+
on:
4+
push:
5+
branches: [ main, hotfix , add-publish ]
6+
tags:
7+
- '**'
8+
workflow_dispatch:
9+
10+
jobs:
11+
publish:
12+
if: ${{ github.repository == 'JabRef/mslinks' }}
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v6
18+
19+
- name: Set up JDK
20+
uses: actions/setup-java@v5
21+
with:
22+
distribution: 'temurin' # See 'Supported distributions' for available options
23+
java-version: '11'
24+
25+
- name: Setup Gradle
26+
uses: gradle/actions/setup-gradle@v5
27+
with:
28+
gradle-home-cache-cleanup: true
29+
30+
- name: Build
31+
run: ./gradlew build
32+
33+
- name: Publish to Sonatype (for snapshots) or to Maven Central
34+
run: ./gradlew publish closeAndReleaseStagingRepositories
35+
env:
36+
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
37+
OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }}
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
SIGNING_KEY: ${{ secrets.SIGNING_KEY }}
40+
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}

build.gradle

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,15 @@ plugins {
22
id 'java-library'
33
id 'com.adarshr.test-logger' version '4.0.0'
44
id 'eclipse'
5+
6+
id 'maven-publish'
7+
id 'signing'
8+
id 'io.github.gradle-nexus.publish-plugin' version '2.0.0'
59
}
610

7-
version = '1.1.0'
11+
group = "org.jabref"
12+
version = '1.1.0-SNAPSHOT'
13+
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
814

915
java {
1016
sourceCompatibility = JavaVersion.VERSION_11
@@ -33,6 +39,18 @@ dependencies {
3339
testImplementation 'junit:junit:4.13.2'
3440
}
3541

42+
java {
43+
withJavadocJar()
44+
withSourcesJar()
45+
}
46+
tasks.withType(JavaCompile).configureEach {
47+
options.encoding = 'UTF-8'
48+
}
49+
tasks.withType(Javadoc).configureEach {
50+
// Ignore warnings because of missing elements
51+
options.addStringOption('Xdoclint:all,-missing', '-quiet')
52+
}
53+
3654
test {
3755
useJUnit {
3856
excludeCategories = ['mslinks.ReadTestData', 'mslinks.WriteTestData', 'mslinks.Examples']
@@ -55,4 +73,56 @@ eclipse {
5573
}
5674
}
5775
}
58-
}
76+
}
77+
78+
publishing {
79+
publications {
80+
mavenJava(MavenPublication) {
81+
artifactId = 'mslinks'
82+
from components.java
83+
pom {
84+
name = 'mslinks'
85+
description = 'Library for parsing and creating Windows shortcut files (.lnk)'
86+
url = 'https://github.com/JabRef/mslinks'
87+
88+
licenses {
89+
license {
90+
name = 'WTFPL'
91+
url = 'http://www.wtfpl.net/about/'
92+
distribution = 'repo'
93+
}
94+
}
95+
96+
developers {
97+
developer {
98+
id = 'DmitriiShamrikov'
99+
}
100+
}
101+
102+
scm {
103+
url = 'https://github.com/JabRef/mslinks'
104+
connection = 'scm:git:git://github.com/JabRef/mslinks.git'
105+
developerConnection = 'scm:git:git@github.com:JabRef/mslinks.git'
106+
}
107+
}
108+
}
109+
}
110+
}
111+
112+
signing {
113+
required = isReleaseVersion
114+
useInMemoryPgpKeys(System.getenv("SIGNING_KEY"), System.getenv("SIGNING_PASSWORD"))
115+
sign publishing.publications.mavenJava
116+
}
117+
118+
nexusPublishing {
119+
repositories {
120+
// see https://central.sonatype.org/publish/publish-portal-ossrh-staging-api/#configuration
121+
sonatype {
122+
username = System.getenv("OSSRH_USERNAME")
123+
password = System.getenv("OSSRH_TOKEN")
124+
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
125+
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
126+
}
127+
}
128+
}

0 commit comments

Comments
 (0)