Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configure CI #1

Merged
merged 3 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Main Branch Build
on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-20.04

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Java 17 for Gradle
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'

- name: Gradle Cache
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
key: ${{runner.os}}-build-gradle-${{hashFiles('**/gradle-wrapper.properties')}}

- name: Prepare parameters
run: |
git log --pretty=format:"%H - %an, %aI : %s" -5
mkdir -p ~/.gradle
echo "GITHUB_TOKEN=${{secrets.PACKAGES_TOKEN}}" > ~/.gradle/gradle.properties
echo "GITHUB_USERNAME=Robothy" >> ~/.gradle/gradle.properties
chmod +x gradlew
pwd
ls -l

- name: Build
run: ./gradlew mergeReports

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: ./build/reports/jacoco/mergeReports/mergeReports.xml
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
44 changes: 44 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: PR Build
on:
pull_request

jobs:
pr-build:
runs-on: ubuntu-20.04

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Java 17 for Gradle
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'

- name: Gradle Cache
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
key: ${{runner.os}}-build-gradle-${{hashFiles('**/gradle-wrapper.properties')}}

- name: Prepare parameters
run: |
git log --pretty=format:"%H - %an, %aI : %s" -5
mkdir -p ~/.gradle
echo "GITHUB_TOKEN=${{secrets.PACKAGES_TOKEN}}" > ~/.gradle/gradle.properties
echo "GITHUB_USERNAME=Robothy" >> ~/.gradle/gradle.properties
chmod +x gradlew
pwd
ls -l

- name: Build
run: ./gradlew mergeReports

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
files: ./build/reports/jacoco/mergeReports/mergeReports.xml
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
81 changes: 81 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Publish
on:
workflow_dispatch:
inputs:
gradleLogLevel:
description: 'Gradle logging level.'
required: false
default: None
type: choice
options:
- None
- Info
- Warn
- Debug
- Stacktrace

jobs:
release:
runs-on: ubuntu-20.04
env:
GITHUB_USERNAME: Robothy

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Java 17 for Gradle
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'

- name: Gradle Cache
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
key: ${{runner.os}}-build-gradle-${{hashFiles('**/gradle-wrapper.properties')}}

- name: Prepare parameters
run: |
git log --pretty=format:"%H - %an, %aI : %s" -5
mkdir -p ~/.gradle
echo "GITHUB_TOKEN=${{secrets.PACKAGES_TOKEN}}" > ~/.gradle/gradle.properties
echo "GITHUB_USERNAME=Robothy" >> ~/.gradle/gradle.properties
echo "signing.secretKey=${{ secrets.SING_SECRET_KEY }}" >> ~/.gradle/gradle.properties
echo "signing.password=${{ secrets.SING_PASSWORD }}" >> ~/.gradle/gradle.properties
echo "OSSRH_USERNAME=${{ secrets.OSSRH_USERNAME }}" >> ~/.gradle/gradle.properties
echo "OSSRH_PASSWORD=${{ secrets.OSSRH_PASSWORD }}" >> ~/.gradle/gradle.properties
chmod +x gradlew
pwd
ls -l

- name: Update release version
run: |
./gradlew releaseVersion

- name: Publish
if: ${{inputs.gradleLogLevel == 'None'}}
run: |
./gradlew check release

- name: Publish(Info)
if: ${{inputs.gradleLogLevel == 'Info'}}
run: .|
./gradlew check release --info

- name: Publish(Warn)
if: ${{inputs.gradleLogLevel == 'Warn'}}
run: .|
./gradlew check release --warn

- name: Publish(Debug)
if: ${{inputs.gradleLogLevel == 'Debug'}}
run: |
./gradlew check release --debug

- name: Publish(Stacktrace)
if: ${{inputs.gradleLogLevel == 'Stacktrace'}}
run: |
./gradlew check release --stacktrace
125 changes: 124 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import io.franzbecker.gradle.lombok.task.DelombokTask

import java.nio.file.Files


plugins {
id 'maven-publish'
id 'java-library'
id 'jacoco'
id 'maven-publish'
id 'io.franzbecker.gradle-lombok' version '5.0.0'
id 'com.robothy.github-repository-release-plugin' version '1.1'
id 'signing'
id 'com.robothy.cn-repo' version '1.8'
}

Expand Down Expand Up @@ -35,6 +44,120 @@ dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter'
}

java {
withSourcesJar()
withJavadocJar()
}

test {
useJUnitPlatform()
}

task mergeReports(type: JacocoReport, group: 'verification') {
executionData.from(project.fileTree(dir: '.', include: '**/build/jacoco/test.exec'))
sourceDirectories.from(project.fileTree(dir: '.', include: '**/src/main/java/**'))
classDirectories.from(project.fileTree(dir: '.', include: '**/build/classes/java/main/**'))
reports {
xml.required.set(true)
html.required.set(true)
//csv.required.set(true)
}
}

project.subprojects.each {
it.afterEvaluate {
mergeReports.dependsOn(it.tasks['test'])
}
}

publishing {

publications {
maven(MavenPublication) {
groupId = group
artifactId = project.name
from components.java

pom {
name = "sdwebui-java-sdk"
description = 'Stable Diffusion Web UI Java SDK'
url = 'https://github.com/Robothy/sdwebui-java-sdk'

licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}

developers {
developer {
id = 'robothy'
name = "Fuxiang Luo"
email = "[email protected]"
}
}

scm {
url = "https://github.com/Robothy/sdwebui-java-sdk.git"
}

}
}
}

repositories {
mavenLocal()

repositories {
mavenLocal()
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/Robothy/sdwebui-java-sdk")
credentials {
username = project.findProperty("GITHUB_USERNAME") ?: System.getenv("GITHUB_USERNAME")
password = project.findProperty("GITHUB_TOKEN") ?: System.getenv("GITHUB_TOKEN")
}
}

maven {
name = "MavenCentral"
url = uri('https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/')
credentials {
username = findProperty("OSSRH_USERNAME")
password = findProperty("OSSRH_PASSWORD")
}
}

}
}
}



task delombok(type: DelombokTask, dependsOn: compileJava) {
ext.outputDir = file("$buildDir/delombok")
outputs.dir(outputDir)
sourceSets.main.java.srcDirs.each {
inputs.dir(it)
args(it, "-d", outputDir)
}
}

javadoc {
dependsOn delombok
source = delombok.outputDir
//failOnError = false
}

signing {
def signingKey
if (findProperty("signingKeyRingFile") != null) {
signingKey = Files.readString(file(findProperty("signing.secretKeyRingFile")).toPath())
} else {
signingKey = findProperty("signing.secretKey")
}
def signingPassword = findProperty("signing.password")
useInMemoryPgpKeys(signingKey, signingPassword)
sign publishing.publications.maven
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.github.robothy.sdwebui.sdk.enums.HiResUpscaler;
import java.util.ArrayList;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
Expand Down Expand Up @@ -62,7 +64,7 @@ public class Txt2ImageOptions {

@Builder.Default
@JsonProperty("styles")
private String[] styles = new String[]{};
private List<String> styles = new ArrayList<>();

@Builder.Default
@JsonProperty("seed")
Expand Down Expand Up @@ -162,7 +164,7 @@ public class Txt2ImageOptions {

@Builder.Default
@JsonProperty("script_args")
private String[] scriptArgs = new String[]{};
private List<String> scriptArgs = new ArrayList<>();

@Builder.Default
@JsonProperty("script_name")
Expand Down
Loading