add package publishing and CI/CD using Gitea actions #5
47
.gitea/workflows/gradle-build.yaml
Normal file
47
.gitea/workflows/gradle-build.yaml
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
name: Build
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
Gradle-Build:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up JDK
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
java-version: '23'
|
||||||
|
check-latest: true
|
||||||
|
distribution: 'zulu'
|
||||||
|
|
||||||
|
- name: Setup Gradle
|
||||||
|
uses: gradle/actions/setup-gradle@v4
|
||||||
|
with:
|
||||||
|
add-job-summary: always
|
||||||
|
cache-cleanup: on-success
|
||||||
|
|
||||||
|
- name: Cache Gradle dependencies
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.gradle/caches
|
||||||
|
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-gradle-
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: chmod +x gradlew; ./gradlew assemble
|
||||||
|
|
||||||
|
- name: Move artifacts
|
||||||
|
run: mkdir artifacts; mv lib/build/libs/*.jar artifacts; mv wrapper/javacord/build/libs/*.jar artifacts;
|
||||||
|
|
||||||
|
- name: Upload artifact
|
||||||
|
uses: christopherhx/gitea-upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: artifacts
|
||||||
|
path: artifacts
|
40
.gitea/workflows/gradle-publish.yaml
Normal file
40
.gitea/workflows/gradle-publish.yaml
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
name: Test
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [master]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
Gradle-Test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up JDK
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
java-version: '23'
|
||||||
|
check-latest: true
|
||||||
|
distribution: 'zulu'
|
||||||
|
|
||||||
|
- name: Setup Gradle
|
||||||
|
uses: gradle/actions/setup-gradle@v4
|
||||||
|
with:
|
||||||
|
add-job-summary: always
|
||||||
|
cache-cleanup: on-success
|
||||||
|
|
||||||
|
- name: Cache Gradle dependencies
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.gradle/caches
|
||||||
|
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-gradle-
|
||||||
|
|
||||||
|
- name: Publish
|
||||||
|
env:
|
||||||
|
GITEA_TOKEN: ${{ secrets.PUBLISH_PACKAGE_TOKEN }}
|
||||||
|
run: chmod +x gradlew; ./gradlew publishAllPublicationsToGiteaRepository
|
53
.gitea/workflows/gradle-test.yaml
Normal file
53
.gitea/workflows/gradle-test.yaml
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
name: Test
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
Gradle-Test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up JDK
|
||||||
|
uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
java-version: '23'
|
||||||
|
check-latest: true
|
||||||
|
distribution: 'zulu'
|
||||||
|
|
||||||
|
- name: Setup Gradle
|
||||||
|
uses: gradle/actions/setup-gradle@v4
|
||||||
|
with:
|
||||||
|
add-job-summary: always
|
||||||
|
cache-cleanup: on-success
|
||||||
|
|
||||||
|
- name: Cache Gradle dependencies
|
||||||
|
uses: actions/cache@v4
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.gradle/caches
|
||||||
|
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-gradle-
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
env:
|
||||||
|
DISCORD_TEST_TOKEN: ${{ secrets.DISCORD_TOKEN }}
|
||||||
|
run: chmod +x gradlew; ./gradlew test
|
||||||
|
|
||||||
|
- name: Move Test Results
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
mkdir test-results/;
|
||||||
|
[ -d lib/build/test-results/test/ ] && mv lib/build/test-results/test/*.xml test-results/;
|
||||||
|
[ -d wrapper/javacord/build/test-results/test/ ] && mv wrapper/javacord/build/test-results/test/*.xml test-results/;
|
||||||
|
|
||||||
|
- name: Upload Test Result
|
||||||
|
uses: christopherhx/gitea-upload-artifact@v4
|
||||||
|
if: always()
|
||||||
|
with:
|
||||||
|
name: test-results
|
||||||
|
path: test-results/
|
50
build.gradle.kts
Normal file
50
build.gradle.kts
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
import java.io.ByteArrayOutputStream
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
`maven-publish`
|
||||||
|
}
|
||||||
|
|
||||||
|
allprojects {
|
||||||
|
group = "net.tomatentum.Marinara"
|
||||||
|
version = "1.0.0-RC1" + (if (!project.hasProperty("release")) ("-" + getGitHash()) else "")
|
||||||
|
description = "A simple but powerful, library-agnostic Discord Interaction Wrapper."
|
||||||
|
}
|
||||||
|
|
||||||
|
subprojects {
|
||||||
|
apply(plugin = "maven-publish")
|
||||||
|
apply(plugin = "java-library")
|
||||||
|
|
||||||
|
plugins.withType<MavenPublishPlugin> {
|
||||||
|
publishing {
|
||||||
|
publications {
|
||||||
|
create<MavenPublication>("maven") {
|
||||||
|
from(components["java"])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
name = "Gitea"
|
||||||
|
url = uri("https://git.tomatentum.net/api/packages/tueem/maven/")
|
||||||
|
|
||||||
|
credentials(HttpHeaderCredentials::class) {
|
||||||
|
name = "Authorization"
|
||||||
|
value = "token " + System.getenv("GITEA_TOKEN")
|
||||||
|
}
|
||||||
|
authentication {
|
||||||
|
create<HttpHeaderAuthentication>("header")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getGitHash(): String {
|
||||||
|
val output = ByteArrayOutputStream()
|
||||||
|
project.exec {
|
||||||
|
commandLine("git", "rev-parse", "--short", "HEAD")
|
||||||
|
standardOutput = output
|
||||||
|
}
|
||||||
|
return output.toString().trim()
|
||||||
|
}
|
1
gradle.properties
Normal file
1
gradle.properties
Normal file
@ -0,0 +1 @@
|
|||||||
|
org.gradle.caching=true
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,6 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
validateDistributionUrl=true
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
0
gradlew
vendored
Normal file → Executable file
0
gradlew
vendored
Normal file → Executable file
@ -11,5 +11,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
rootProject.name = "Marinara"
|
rootProject.name = "Marinara"
|
||||||
include("lib")
|
include(":lib")
|
||||||
include("wrapper:javacord")
|
include(":wrapper-javacord")
|
||||||
|
|
||||||
|
project(":wrapper-javacord").projectDir = file("wrapper/javacord")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user