Skip to content

Commit

Permalink
VS Whoa
Browse files Browse the repository at this point in the history
  • Loading branch information
ewoudje committed Jan 23, 2024
1 parent 2ce1313 commit ecb33f7
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 3 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Build
on:
push:
branches:
- '*'
pull_request:
types: [ opened, synchronize, reopened ]
jobs:
validate-gradle:
name: "Validate Gradle wrapper"
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: gradle/wrapper-validation-action@v1
build:
name: Build
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Cache Gradle packages
uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Build and analyze
run: ./gradlew build --info
continue-on-error: true # still upload checkstyle report even if build fails
- uses: jwgmeligmeyling/checkstyle-github-action@master # show checkstyle/ktlint report
with:
path: |
build/reports/**/*.xml
60 changes: 60 additions & 0 deletions .github/workflows/gradle-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# 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#publishing-using-gradle

name: Gradle Package

on:
push:
branches:
- 'main'

jobs:
validate-gradle:
name: "Validate Gradle wrapper"
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: gradle/wrapper-validation-action@v1
build-and-publish:
name: "Build and Publish"
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17
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: Cache Gradle packages
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Build mod jar
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 and VS Maven
run: ./gradlew publish
env:
ORG_GRADLE_PROJECT_vs_maven_password: ${{ secrets.ORG_GRADLE_PROJECT_VS_MAVEN_PASSWORD }}
ORG_GRADLE_PROJECT_vs_maven_url: ${{ secrets.ORG_GRADLE_PROJECT_VS_MAVEN_URL }}
ORG_GRADLE_PROJECT_vs_maven_username: ${{ secrets.ORG_GRADLE_PROJECT_VS_MAVEN_USERNAME }}
- name: Cleanup Gradle Cache
# Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
# Restoring these files from a GitHub Actions cache might cause problems for future builds.
run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.gradle
.env
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
Expand Down
49 changes: 46 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
plugins {
kotlin("multiplatform") version "1.9.0"
id("io.kotest.multiplatform") version "5.7.2"
id("maven-publish")
}

val kotestVersion = "5.7.2"

group = "com.ewoudje"
version = "1.0-SNAPSHOT"


val gitRevision = "git rev-parse HEAD".execute()
version = "0.1.0+" + gitRevision.substring(0, 10)

repositories {
mavenCentral()
maven {
name = "VS Maven"
url = uri(project.findProperty("vs_maven_url") ?: "https://maven.valkyrienskies.org/")

val vsMavenUsername = project.findProperty("vs_maven_username") as String?
val vsMavenPassword = project.findProperty("vs_maven_password") as String?

if (vsMavenPassword != null && vsMavenUsername != null) {
credentials {
username = vsMavenUsername
password = vsMavenPassword
}
}
}
}

kotlin {
Expand Down Expand Up @@ -44,4 +58,33 @@ kotlin {

tasks.withType<Test>().configureEach {
useJUnitPlatform()
}

publishing {
repositories {
val vsMavenUsername = project.findProperty("vs_maven_username") as String?
val vsMavenPassword = project.findProperty("vs_maven_password") as String?
val vsMavenUrl = project.findProperty("vs_maven_url") as String?
if (vsMavenUrl != null && vsMavenPassword != null && vsMavenUsername != null) {
println("Publishing to VS Maven ($version)")
maven {
url = uri(vsMavenUrl)
credentials {
username = vsMavenUsername
password = vsMavenPassword
}
}
}
}

publications {
register<MavenPublication>("vsMaven") {
from(components["java"])
}
}
}

fun String.execute(envp: Array<String>? = null, dir: File = projectDir): String {
val process = Runtime.getRuntime().exec(this, envp, dir)
return process.inputStream.reader().readText()
}
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
kotlin.code.style=official
kotlin.js.compiler=ir
org.gradle.jvmargs=-Xmx4096M
org.gradle.parallel=true
org.gradle.caching=true

0 comments on commit ecb33f7

Please sign in to comment.