Skip to content

Commit b4715ea

Browse files
committed
Add publish
1 parent 42dee2b commit b4715ea

File tree

2 files changed

+108
-2
lines changed

2 files changed

+108
-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: '17'
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 closeAndReleaseRepository
35+
env:
36+
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
37+
MAVEN_PASSWORD: ${{ 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: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ plugins {
22
id 'java-library'
33
id 'com.adarshr.test-logger' version '3.0.0'
44
id 'eclipse'
5+
id 'signing'
6+
id 'io.github.gradle-nexus.publish-plugin' version '2.0.0'
57
}
68

7-
version = '1.1.0'
9+
version = '1.1.0-SNAPSHOT'
810

911
sourceCompatibility = 11.0
1012
targetCompatibility = 11.0
@@ -31,6 +33,18 @@ dependencies {
3133
testImplementation 'junit:junit:4.13.2'
3234
}
3335

36+
java {
37+
withJavadocJar()
38+
withSourcesJar()
39+
}
40+
tasks.withType(JavaCompile).configureEach {
41+
options.encoding = 'UTF-8'
42+
}
43+
tasks.withType(Javadoc).configureEach {
44+
// Ignore warnings because of missing elements
45+
options.addStringOption('Xdoclint:all,-missing', '-quiet')
46+
}
47+
3448
test {
3549
useJUnit {
3650
excludeCategories = ['mslinks.ReadTestData', 'mslinks.WriteTestData', 'mslinks.Examples']
@@ -48,4 +62,56 @@ eclipse {
4862
}
4963
}
5064
}
51-
}
65+
}
66+
67+
publishing {
68+
publications {
69+
mavenJava(MavenPublication) {
70+
artifactId = 'mslinks'
71+
from components.java
72+
pom {
73+
name = 'mslinks'
74+
description = 'Library for parsing and creating Windows shortcut files (.lnk)'
75+
url = 'https://github.com/JabRef/mslinks'
76+
77+
licenses {
78+
license {
79+
name = 'WTFPL'
80+
url = 'http://www.wtfpl.net/about/'
81+
distribution = 'repo'
82+
}
83+
}
84+
85+
developers {
86+
developer {
87+
id = 'DmitriiShamrikov'
88+
}
89+
}
90+
91+
scm {
92+
url = 'https://github.com/JabRef/mslinks'
93+
connection = 'scm:git:git://github.com/JabRef/mslinks.git'
94+
developerConnection = 'scm:git:git@github.com:JabRef/mslinks.git'
95+
}
96+
}
97+
}
98+
}
99+
}
100+
101+
signing {
102+
required = isReleaseVersion
103+
useInMemoryPgpKeys(System.getenv("SIGNING_KEY"), System.getenv("SIGNING_PASSWORD"))
104+
sign publishing.publications.mavenJava
105+
}
106+
107+
nexusPublishing {
108+
repositories {
109+
// see https://central.sonatype.org/publish/publish-portal-ossrh-staging-api/#configuration
110+
sonatype {
111+
username = System.getenv("OSSRH_USERNAME")
112+
password = System.getenv("OSSRH_TOKEN")
113+
nexusUrl.set(uri("https://ossrh-staging-api.central.sonatype.com/service/local/"))
114+
snapshotRepositoryUrl.set(uri("https://central.sonatype.com/repository/maven-snapshots/"))
115+
}
116+
}
117+
}

0 commit comments

Comments
 (0)