From eac7436b18669e9b4906cd29b18baafb2db5803a Mon Sep 17 00:00:00 2001 From: Aria Moradi Date: Fri, 22 Jan 2021 01:37:24 +0330 Subject: [PATCH] clean up bulid file name --- .github/scripts/commit-repo.sh | 11 ----------- .github/scripts/create-repo.sh | 12 ++++++++---- .github/workflows/build.yml | 2 +- server/build.gradle.kts | 20 +++++++++++++++++++- 4 files changed, 28 insertions(+), 17 deletions(-) diff --git a/.github/scripts/commit-repo.sh b/.github/scripts/commit-repo.sh index d81bcd7e..6930ff1c 100755 --- a/.github/scripts/commit-repo.sh +++ b/.github/scripts/commit-repo.sh @@ -4,17 +4,6 @@ cp ../master/repo/server-r* . new_build=$(ls | tail -1) echo "New build file name: $new_build" -# every build generates different jar even if same code, so comment this out. -#diff $new_build server-latest.jar > /dev/null -#if [ $? -eq 1 ]; then -# echo "This is different to latest, replace latest." -# cp -f $new_build server-latest.jar -#else -# echo "This is the same as latest, throw it away." -# rm $new_build -#fi - - git config --global user.email "github-actions[bot]@users.noreply.github.com" git config --global user.name "github-actions[bot]" git status diff --git a/.github/scripts/create-repo.sh b/.github/scripts/create-repo.sh index 0d7ef387..048d83ed 100755 --- a/.github/scripts/create-repo.sh +++ b/.github/scripts/create-repo.sh @@ -3,8 +3,12 @@ set -e mkdir -p repo/ -revision=$(git rev-list master --count) -# add zero padding -revision=$(printf %04d $revision) +# Get last commit message +last_commit_log=$(git log -1 --pretty=format:"%s") +echo "last commit log: $last_commit_log" -cp server/build/server-1.0-all.jar "repo/server-r$revision.jar" \ No newline at end of file +filter_count=$(echo "$last_commit_log" | grep -c "[RELEASE CI]" ) + +if [ "$filter_count" -gt 0 ]; then + cp server/build/Tachidesk-*.jar repo/ +fi \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 096e479a..3796a8b6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -65,7 +65,7 @@ jobs: configuration-cache-enabled: true - name: Create repo artifacts - if: github.event_name == 'push' && github.repository == 'AriaMoradi/Tachidesk' && "startsWith(github.event.head_commit.message, '[RELEASE CI]')" + if: github.event_name == 'push' && github.repository == 'AriaMoradi/Tachidesk' run: | cd master ./.github/scripts/create-repo.sh diff --git a/server/build.gradle.kts b/server/build.gradle.kts index 41dcb09f..dc78cf0b 100644 --- a/server/build.gradle.kts +++ b/server/build.gradle.kts @@ -1,4 +1,5 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar +import java.io.BufferedReader plugins { // id("org.jetbrains.kotlin.jvm") version "1.4.21" @@ -6,6 +7,8 @@ plugins { id("com.github.johnrengelman.shadow") version "6.1.0" } +val TachideskVersion = "v0.0.1" + repositories { mavenCentral() @@ -102,6 +105,19 @@ sourceSets { } } +val TachideskRevision = Runtime + .getRuntime() + .exec("git rev-list master --count") + .let { process -> + process.waitFor() + val output = process.inputStream.use { + it.bufferedReader().use(BufferedReader::readText) + } + process.destroy() + "r"+output.trim() + + } + tasks { jar { manifest { @@ -115,12 +131,14 @@ tasks { } shadowJar { manifest.inheritFrom(jar.get().manifest) //will make your shadowJar (produced by jar task) runnable + archiveBaseName.set("Tachidesk") + archiveVersion.set(TachideskVersion) + archiveClassifier.set(TachideskRevision) } } tasks.withType { destinationDir = File("$rootDir/server/build") - //dependsOn(":webUI:copyBuild") } tasks.named("processResources") {