Skip to content

Commit

Permalink
Fix workflow build_release
Browse files Browse the repository at this point in the history
  • Loading branch information
justmangoou committed Jan 28, 2023
1 parent cb16163 commit 0527d80
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/build_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
options: --user root
steps:
- run: apt update && apt install git -y && git --version
- run: git config --global --add safe.directory /__w/fabric/fabric
- run: git config --global --add safe.directory /__w/smp/smp
- uses: actions/checkout@v2
with:
fetch-depth: 0
Expand All @@ -25,4 +25,6 @@ jobs:
context: changelog
workflow_id: build_release.yml
- uses: gradle/wrapper-validation-action@v1
- run: ./gradlew build github --stacktrace -Porg.gradle.parallel.threads=4
- run: ./gradlew build github --stacktrace -Porg.gradle.parallel.threads=4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17 changes: 14 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import org.kohsuke.github.GHRelease
import org.kohsuke.github.GHReleaseBuilder
import org.kohsuke.github.GitHub
import java.time.LocalDate
import java.time.format.DateTimeFormatter

buildscript {
dependencies {
Expand Down Expand Up @@ -73,17 +76,25 @@ tasks {
}

doLast {
val date = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy.MM.dd"))

val github = GitHub.connectUsingOAuth(ENV["GITHUB_TOKEN"] as String)
val repository = github.getRepository(ENV["GITHUB_REPOSITORY"])

val releaseBuilder = GHReleaseBuilder(repository, "latest")
releaseBuilder.name("[$project.minecraft_version] Fabric API $project.version")
repository.listReleases().forEach {
if (it.tagName == date) {
it.delete()
}
}

val releaseBuilder = GHReleaseBuilder(repository, date)
releaseBuilder.name("[$project.minecraft_version] MangoPlex SMP $project.version")
releaseBuilder.body(ENV["CHANGELOG"] ?: "No changelog provided")
releaseBuilder.commitish("main")

val ghRelease = releaseBuilder.create()
ghRelease.uploadAsset(remapJar.get().archiveFile.get().asFile, "application/java-archive");
ghRelease.uploadAsset(buildDir.resolve("build/resources/main/docker-compose.yml"), "application/x-yaml");
ghRelease.uploadAsset(buildDir.resolve("resources/main/docker-compose.yml"), "application/x-yaml");
}
}
}

0 comments on commit 0527d80

Please sign in to comment.