Skip to content

Commit

Permalink
Package publishing
Browse files Browse the repository at this point in the history
Automatic package building/publishing
  • Loading branch information
T14D3 authored Dec 31, 2024
2 parents b51c7c5 + d6bf4cf commit 2d41677
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 2 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/gradle-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle

name: Gradle Package

on: [push]

jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file

- name: Setup Gradle
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0

- name: Build with Gradle
run: ./gradlew build

# The USERNAME and TOKEN need to correspond to the credentials environment variables used in
# the publishing section of your build.gradle
- name: Publish to GitHub Packages
run: ./gradlew publish
env:
USERNAME: ${{ github.actor }}
TOKEN: ${{ secrets.GITHUB_TOKEN }}
21 changes: 20 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import xyz.jpenilla.runtask.task.AbstractRun

plugins {
id 'java'
id 'maven-publish'
id 'io.papermc.paperweight.userdev' version '1.7.3'
id 'xyz.jpenilla.run-paper' version '2.3.1'
}

group = 'de.t14d3'
version = '1.0-SNAPSHOT'
version = '1.0'

repositories {
mavenCentral()
Expand Down Expand Up @@ -66,3 +67,21 @@ tasks {
}
}

publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/t14d3/zones")
credentials {
username = project.findProperty("gpr.user") ?: System.getenv("USERNAME")
password = project.findProperty("gpr.key") ?: System.getenv("TOKEN")
}
}
}
publications {
gpr(MavenPublication) {
from(components.java)
}
}
}

Empty file modified gradlew
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.9.0'
}
rootProject.name = 'Zones'
rootProject.name = 'zones'

0 comments on commit 2d41677

Please sign in to comment.