From 27dc6b4b5e8d1dd1e72d762983631bff90dabd59 Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Sat, 19 Oct 2024 12:29:42 -0400 Subject: [PATCH] Setup maven publishing --- .github/workflows/build-snapshot.yml | 33 ++++++++++++++++++++++++++++ build.gradle | 25 ++++++++++++++++++--- 2 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/build-snapshot.yml diff --git a/.github/workflows/build-snapshot.yml b/.github/workflows/build-snapshot.yml new file mode 100644 index 0000000..8c904b0 --- /dev/null +++ b/.github/workflows/build-snapshot.yml @@ -0,0 +1,33 @@ +# Used when a commit is pushed to the repository +name: build-snapshot + +on: [ push ] + +env: + MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} + MAVEN_SECRET: ${{ secrets.MAVEN_SECRET }} + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Extract current branch name + shell: bash + # bash pattern expansion to grab branch name without slashes + run: ref="${GITHUB_REF#refs/heads/}" && echo "branch=${ref////-}" >> $GITHUB_OUTPUT + id: ref + - name: Checkout sources + uses: actions/checkout@v4 + - name: Set up JDK + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: 21 + - name: Build artifacts + run: ./gradlew build publish + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: Taufuscator + path: build/libs diff --git a/build.gradle b/build.gradle index cbe991c..b48a06a 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,7 @@ plugins { id 'antlr' id 'java-library' + id 'maven-publish' } group = 'org.taumc' @@ -18,15 +19,33 @@ dependencies { testImplementation 'org.junit.jupiter:junit-jupiter' } - - generateGrammarSource { arguments += ["-visitor", '-package', 'org.taumc.glsl.grammar'] outputDirectory = new File(buildDir.toString() + "/generated-src/antlr/main/org/taumc/glsl/grammar/") } - test { useJUnitPlatform() +} + +publishing { + publications { + mavenJava(MavenPublication) { + from components.java + } + } + repositories { + maven { + name = "taumcRepository" + url = uri("https://maven.taumc.org/releases") + credentials { + username = System.getenv("MAVEN_USERNAME") + password = System.getenv("MAVEN_SECRET") + } + authentication { + basic(BasicAuthentication) + } + } + } } \ No newline at end of file