From 4e1e6f84e6777ad0ddc0abe357c4727442171f09 Mon Sep 17 00:00:00 2001 From: Robin Date: Sun, 7 Jul 2024 11:18:17 +0200 Subject: [PATCH] releases --- .github/workflows/gradle.yml | 6 +++++ .github/workflows/release.yml | 43 +++++++++++++++++++++++++++++++++++ build.gradle.kts | 6 ++++- 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index f8689bd..c62cb85 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -43,6 +43,12 @@ jobs: - name: Build with Gradle Wrapper run: ./gradlew publish -ProbaertschiPassword=${{ secrets.REPOSILITE_SECRET }} -ProbaertschiUsername=${{ secrets.REPOSILITE_NAME }} + - name: Upload Artifact + uses: actions/upload-artifact@v2 + with: + name: Artifacts + path: build/libs + # NOTE: The Gradle Wrapper is the default and recommended way to run Gradle (https://docs.gradle.org/current/userguide/gradle_wrapper.html). # If your project does not have the Gradle Wrapper configured, you can use the following configuration to run Gradle with a specified version. # diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..3731bb6 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,43 @@ +name: Release + +on: + workflow_dispatch: + +jobs: + build: + strategy: + matrix: + java: [ 21 ] + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: setup JDK${{ matrix.java }} + uses: actions/setup-java@1 + with: + java-version: ${{ matrix.java }} + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 + + - name: Get Version + id: mod_version + run: echo "mod_version=""$(./gradlew printVersion | grep -E ^[0-9]+\.[0-9]+ -m 1)" >> $GITHUB_OUTPUT + + - name: Minecraft Version + id: minecraft_version + run: grep "minecraftVersion" gradle.properties -m 1 | sed "s/\s//g" >> $GITHUB_OUTPUT + + - name: Create Realease + id: create_release + uses: actions/release-action@1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag: ${{ steps.mod_version.outputs.mod_version }} + name: EnvironmentTech ${{ steps.mod_version.outputs.mod_version }} for ${{ steps.minecraft_version.outputs.minecraftVersion }} + draft: false + prerelease: false + generateReleaseNotes: true + artifacts: "build/libs" \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index 485bf39..f71e797 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -51,7 +51,11 @@ val noTag = !details.lastTag.contains(Regex("""\d+\.\d+""")) val end = if (noTag) snapshot else "${details.commitDistance}${snapshot}" val modVersion: String = "${details.lastTag}${if (details.commitDistance > 0 || noTag) end else ""}" +val release = details.commitDistance == 0 && !noTag println(modVersion) +if (release) { + println("Building in Release Mode") +} version = modVersion group = modGroupId @@ -308,7 +312,7 @@ publishing { val baseURL = "https://maven.robaertschi.xyz/" name = "robaertschi" - url = uri("${baseURL}${if (version.toString().endsWith("SNAPSHOT")) "snapshots" else "releases"}") + url = uri("${baseURL}${if (!release) "snapshots" else "releases"}") credentials(PasswordCredentials::class) authentication { register("basic")