From 6e5db9439266946b81e838e26ee92a4ffc6c19fb Mon Sep 17 00:00:00 2001 From: FalsePattern <30945458+FalsePattern@users.noreply.github.com> Date: Fri, 6 May 2022 12:44:03 +0200 Subject: [PATCH] update buildscript for deployment --- .github/workflows/release-tags.yml | 8 +++++++- build.gradle | 32 ++++++++++++++++++++---------- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/.github/workflows/release-tags.yml b/.github/workflows/release-tags.yml index 22ddea3..4ffdc90 100644 --- a/.github/workflows/release-tags.yml +++ b/.github/workflows/release-tags.yml @@ -11,6 +11,9 @@ on: jobs: build: runs-on: ubuntu-latest + env: + MAVEN_DEPLOY_USER: ${{ secrets.MAVEN_DEPLOY_USER }} + MAVEN_DEPLOY_PASSWORD: ${{ secrets.MAVEN_DEPLOY_PASSWORD }} steps: - uses: actions/checkout@v2 with: @@ -42,4 +45,7 @@ jobs: automatic_release_tag: "${{ env.RELEASE_VERSION }}" prerelease: false title: "${{ env.RELEASE_VERSION }}" - files: build/libs/*.jar \ No newline at end of file + files: build/libs/*.jar + + - name: Publish to maven + run: ./gradlew publish \ No newline at end of file diff --git a/build.gradle b/build.gradle index 119dfdd..e245554 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,4 @@ -//version: 1641429628falsepattern12 +//version: 1641429628falsepattern16 /* DO NOT CHANGE THIS FILE! @@ -545,8 +545,16 @@ def getCredentials = { return [username: entry.username.text(), password: entry.password.text()] } } + throw new Exception(); } catch (Exception ignored) { - return [username: "none", password: "none"] + //Try from environment variables if file does not exist + String username = System.getenv("MAVEN_DEPLOY_USER") + String password = System.getenv("MAVEN_DEPLOY_PASSWORD") + if (username == null || password == null) { + return [username: null, password: null] + } else { + return [username: username, password: password] + } } } @@ -554,9 +562,9 @@ def getCredentials = { publishing { publications { maven(MavenPublication) { - artifact source: jar + artifact source: (jar.enabled ? jar : shadowJar) artifact source: sourcesJar, classifier: "src" - artifact source: devJar, classifier: "dev" + artifact source: (devJar.enabled ? devJar : shadowDevJar), classifier: "dev" if (apiPackage) { artifact source: apiJar, classifier: "api" } @@ -568,13 +576,15 @@ publishing { } repositories { - maven { - name = repositoryName - url = repositoryURL - def creds = getCredentials() - credentials { - username = creds == null ? "none" : creds.username - password = creds == null ? "none" : creds.password + if (repositoryURL.trim() != "") { + maven { + name = repositoryName + url = repositoryURL + def creds = getCredentials() + credentials { + username = creds == null ? "none" : creds.username + password = creds == null ? "none" : creds.password + } } } }