Skip to content

Commit 6e5db94

Browse files
committed
update buildscript for deployment
1 parent db1354f commit 6e5db94

File tree

2 files changed

+28
-12
lines changed

2 files changed

+28
-12
lines changed

.github/workflows/release-tags.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ on:
1111
jobs:
1212
build:
1313
runs-on: ubuntu-latest
14+
env:
15+
MAVEN_DEPLOY_USER: ${{ secrets.MAVEN_DEPLOY_USER }}
16+
MAVEN_DEPLOY_PASSWORD: ${{ secrets.MAVEN_DEPLOY_PASSWORD }}
1417
steps:
1518
- uses: actions/checkout@v2
1619
with:
@@ -42,4 +45,7 @@ jobs:
4245
automatic_release_tag: "${{ env.RELEASE_VERSION }}"
4346
prerelease: false
4447
title: "${{ env.RELEASE_VERSION }}"
45-
files: build/libs/*.jar
48+
files: build/libs/*.jar
49+
50+
- name: Publish to maven
51+
run: ./gradlew publish

build.gradle

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//version: 1641429628falsepattern12
1+
//version: 1641429628falsepattern16
22
/*
33
DO NOT CHANGE THIS FILE!
44
@@ -545,18 +545,26 @@ def getCredentials = {
545545
return [username: entry.username.text(), password: entry.password.text()]
546546
}
547547
}
548+
throw new Exception();
548549
} catch (Exception ignored) {
549-
return [username: "none", password: "none"]
550+
//Try from environment variables if file does not exist
551+
String username = System.getenv("MAVEN_DEPLOY_USER")
552+
String password = System.getenv("MAVEN_DEPLOY_PASSWORD")
553+
if (username == null || password == null) {
554+
return [username: null, password: null]
555+
} else {
556+
return [username: username, password: password]
557+
}
550558
}
551559
}
552560

553561
//Publishing
554562
publishing {
555563
publications {
556564
maven(MavenPublication) {
557-
artifact source: jar
565+
artifact source: (jar.enabled ? jar : shadowJar)
558566
artifact source: sourcesJar, classifier: "src"
559-
artifact source: devJar, classifier: "dev"
567+
artifact source: (devJar.enabled ? devJar : shadowDevJar), classifier: "dev"
560568
if (apiPackage) {
561569
artifact source: apiJar, classifier: "api"
562570
}
@@ -568,13 +576,15 @@ publishing {
568576
}
569577

570578
repositories {
571-
maven {
572-
name = repositoryName
573-
url = repositoryURL
574-
def creds = getCredentials()
575-
credentials {
576-
username = creds == null ? "none" : creds.username
577-
password = creds == null ? "none" : creds.password
579+
if (repositoryURL.trim() != "") {
580+
maven {
581+
name = repositoryName
582+
url = repositoryURL
583+
def creds = getCredentials()
584+
credentials {
585+
username = creds == null ? "none" : creds.username
586+
password = creds == null ? "none" : creds.password
587+
}
578588
}
579589
}
580590
}

0 commit comments

Comments
 (0)