Skip to content

Commit

Permalink
[Change] Gradle + Publishing Data
Browse files Browse the repository at this point in the history
  • Loading branch information
CDAGaming committed May 31, 2024
1 parent f9ca31c commit 9afead1
Show file tree
Hide file tree
Showing 11 changed files with 593 additions and 104 deletions.
18 changes: 18 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
* text=auto eol=lf
*.java text eol=lf
*.groovy text eol=lf
*.scala text eol=lf
*.sh text eol=lf
*.bat text eol=crlf
*.md text
*.properties text

*.dat binary
*.bin binary
*.png binary
*.exe binary
*.dll binary
*.zip binary
*.jar binary
*.7z binary
*.db binary
51 changes: 51 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build Release
on:
release:
types: [ created ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Import GPG Key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.MAVEN_TOKEN }}

- name: update cache
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Set up Build JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '8'

- name: Set up Gradle JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Publish
run: ./gradlew publish -Pmvn.user=${{ secrets.MAVEN_USER }} -Pmvn.key=${{ secrets.MAVEN_TOKEN }}

- uses: actions/upload-artifact@v4
with:
name: DiscordIPC Artifacts
path: ./build/libs/

- name: stop daemon
run: ./gradlew --stop
54 changes: 54 additions & 0 deletions .github/workflows/build_snapshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build Snapshot

on:
push:
branches-ignore:
- 'feature/**'

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Import GPG Key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.MAVEN_TOKEN }}

- name: update cache
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Set up Build JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '8'

- name: Set up Gradle JDK
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Publish
run: ./gradlew publish -Pversion_snapshot -Pmvn.user=${{ secrets.MAVEN_USER }} -Pmvn.key=${{ secrets.MAVEN_TOKEN }} -x test

- uses: actions/upload-artifact@v4
with:
name: DiscordIPC Snapshot Artifacts
path: ./build/libs/

- name: stop daemon
run: ./gradlew --stop
44 changes: 16 additions & 28 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,31 +1,19 @@
# Compiled class file
*.class
#General
/repo
/.gradle
/build

# Log file
*.log
#Eclipse
.settings
.metadata
.classpath
.project
/bin

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# Intellij Project Files
/.idea/
/out/
#IntelliJ Idea
/out
/.idea
*.iml

# Testing
/src/test/
/target/
*.iws
*.ipr
s101plugin.state
101 changes: 101 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
plugins {
id 'java'
id 'signing'
id 'maven-publish'
}

version = '0.9.0' + (project.hasProperty("version_snapshot") ? "-SNAPSHOT" : "")
group = 'io.github.CDAGaming'
description = 'Connect locally to the Discord client using IPC for a subset of RPC features like Rich Presence and Activity Join/Spectate'
base.archivesName = 'DiscordIPC'

JavaVersion targetVersion = JavaVersion.VERSION_1_8
int targetVersionInt = Integer.parseInt(targetVersion.majorVersion)

[java].each {
it.toolchain {
languageVersion.set(JavaLanguageVersion.of(targetVersionInt))
}
it.withSourcesJar()
it.withJavadocJar()
}

repositories {
mavenCentral()
}

dependencies {
implementation group: 'com.google.code.gson', name: 'gson', version: '2.11.0'
implementation group: 'org.slf4j', name: 'slf4j-api', version: '2.0.13'
implementation group: 'com.kohlschutter.junixsocket', name: 'junixsocket-common', version: '2.9.1'
implementation group: 'com.kohlschutter.junixsocket', name: 'junixsocket-native-common', version: '2.9.1'
implementation group: 'net.lenni0451', name: 'Reflect', version: '1.3.4'
}

jar.manifest.mainAttributes([
'Implementation-Title' : project.name,
'Implementation-Version': project.version
])

[compileJava].each {
it.options.encoding = 'UTF-8'
it.options.deprecation = true
it.options.fork = true
}

publishing {
publications {
mavenJava(MavenPublication) {
from components.java

pom {
name = rootProject.name
artifactId = rootProject.name
packaging = 'jar'
description = project.description
url = 'https://github.com/CDAGaming/DiscordIPC'

scm {
connection = 'scm:git:git://github.com/CDAGaming/DiscordIPC.git'
developerConnection = 'scm:git:ssh://github.com/CDAGaming/DiscordIPC.git'
url = 'https://github.com/CDAGaming/DiscordIPC'
}
licenses {
license {
name = 'Apache License 2.0'
url = 'https://github.com/CDAGaming/DiscordIPC/blob/master/LICENSE'
}
}
developers {
developer {
id = 'cdagaming'
name = 'CDAGaming'
email = '[email protected]'
}
developer {
id = 'jagrosh'
name = 'John Grosh'
email = '[email protected]'
}
}
}
}
}
repositories {
maven {
credentials {
username = project.findProperty("mvn.user") ?: System.getenv("OSSRH_USERNAME")
password = project.findProperty("mvn.key") ?: System.getenv("OSSRH_PASSWORD")
}

def releasesRepoUrl = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshotsRepoUrl = "https://s01.oss.sonatype.org/content/repositories/snapshots/"
url = version.endsWith('-SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
}
}
}

signing {
useGpgCmd()
sign publishing.publications.mavenJava
}
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 9afead1

Please sign in to comment.