From 4e0cefdde3aeede3b436a0007ac9b05a7f2bca5a Mon Sep 17 00:00:00 2001 From: Thom van den Akker Date: Sat, 24 Aug 2024 19:05:25 +0200 Subject: [PATCH 01/24] Port OPC changes to NG7 --- .github/workflows/gradle.build.yaml | 67 ++++++------------------ .github/workflows/gradle.prerelease.yaml | 66 +++++++++++++++++++++++ .github/workflows/gradle.publish.yaml | 55 +++++-------------- .github/workflows/gradle.version.yaml | 51 ++++++++++++++++++ gradle/mod.gradle | 4 ++ 5 files changed, 150 insertions(+), 93 deletions(-) create mode 100644 .github/workflows/gradle.prerelease.yaml create mode 100644 .github/workflows/gradle.version.yaml diff --git a/.github/workflows/gradle.build.yaml b/.github/workflows/gradle.build.yaml index 9e3a4d2..f28bbf3 100644 --- a/.github/workflows/gradle.build.yaml +++ b/.github/workflows/gradle.build.yaml @@ -5,53 +5,31 @@ on: workflow_call: inputs: java: - description: "The version of Java to use to run Gradle" # Note: Gradle's Java toolchains feature is used for compiling, which is separate from this + description: "The version of Java to use to run Gradle" required: false type: string default: "21" gradle_tasks: - description: "The Gradle task(s) to run at publication" + description: "The Gradle task(s) to run for building" required: false type: string - default: "publish" + default: "build" secrets: - CROWDIN_API_KEY: - required: true - GRADLE_ENCRYPTION_KEY: - required: true + description: The AES key to enable Gradle cache encryption + required: false permissions: contents: read - statuses: write - packages: write jobs: - compute-version: - name: Compute version + compute-suffix: runs-on: ubuntu-latest outputs: - version: ${{ steps.version.outputs.version }} - version_tag: ${{ steps.version.outputs.version_tag }} - minecraft_version: ${{ steps.minecraftVersion.outputs.minecraft_version }} + branch_suffix: ${{ steps.computeBranchSuffix.outputs.branch_suffix }} steps: - - id: checkout - name: "📦 Checkout" - uses: actions/checkout@v4 - with: - fetch-depth: 0 - fetch-tags: true - - - id: minecraftVersion - name: "📦 Extract Minecraft version" - run: | - cat gradle.properties | grep exactMinecraftVersion | cut -d "=" -f 2 > minecraft_version.txt - echo "Minecraft version: $(cat minecraft_version.txt)" - echo "minecraft_version=$(cat minecraft_version.txt)" >> "$GITHUB_OUTPUT" - - id: computeBranchSuffix name: "🔢 Compute branch suffix" - if: github.event_name == 'push' run: | gitRef="${{ github.ref }}" branchName=$(echo "${gitRef/refs\/heads\//}") @@ -62,31 +40,22 @@ jobs: echo "branch_suffix=$cleanedBranchName" >> "$GITHUB_OUTPUT" - - id: version - name: "🔢 Compute version" - uses: PaulHatch/semantic-version@v5.4.0 - with: - tag_prefix: "v" - search_commit_body: true - debug: true - bump_each_commit: true - version_format: "${major}.${minor}.${patch}-${{ steps.minecraftVersion.outputs.minecraft_version }}-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || format('branch-{0}', steps.computeBranchSuffix.outputs.branch_suffix) }}" + compute-version: + needs: [ "compute-suffix" ] + uses: ./.github/workflows/gradle.version.yaml + with: + suffix: ${{ format('branch-{0}', needs.compute-suffix.outputs.branch_suffix) }} - gradle: - needs: ["compute-version"] # Make sure we now the version before starting to build + build: + needs: [ "compute-version" ] runs-on: ubuntu-latest steps: - id: checkout name: "📦 Checkout" uses: actions/checkout@v4 - with: - fetch-depth: 1000 - fetch-tags: true - id: setupJava name: "🔧 Setup Java" - # https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md#java - # language=bash run: | echo "JAVA_HOME=$(echo $JAVA_HOME_${{ inputs.java }}_X64)" >> "$GITHUB_ENV" @@ -101,10 +70,4 @@ jobs: name: "🏗️ Build" run: ./gradlew --build-cache ${{ inputs.gradle_tasks }} env: - crowdinKey: ${{ secrets.CROWDIN_API_KEY }} - Version: "${{ needs.compute-version.outputs.version }}" - GITHUB_TOKEN: ${{ github.token }} - GITHUB_REPOSITORY: ${{ github.repository }} - GITHUB_USERNAME: ${{ github.actor }} - - + Version: "${{ needs.compute-version.outputs.version }}" \ No newline at end of file diff --git a/.github/workflows/gradle.prerelease.yaml b/.github/workflows/gradle.prerelease.yaml new file mode 100644 index 0000000..4517c8b --- /dev/null +++ b/.github/workflows/gradle.prerelease.yaml @@ -0,0 +1,66 @@ +# Based off https://github.com/MinecraftForge/SharedActions/blob/main/.github/workflows/gradle.yml +name: Gradle Pre-release CI + +on: + workflow_call: + inputs: + java: + description: "The version of Java to use to run Gradle" + required: false + type: string + default: "21" + gradle_tasks: + description: "The Gradle task(s) to run for building" + required: false + type: string + default: "publish" + secrets: + GRADLE_ENCRYPTION_KEY: + description: The AES key to enable Gradle cache encryption + required: true + CROWDIN_API_KEY: + required: true + +permissions: + contents: read + statuses: write + packages: write + +jobs: + compute-version: + uses: ./.github/workflows/gradle.version.yaml + with: + suffix: pre-release + + gradle: + needs: [ "compute-version" ] + runs-on: ubuntu-latest + steps: + - id: checkout + name: "📦 Checkout" + uses: actions/checkout@v4 + with: + fetch-depth: 1000 + fetch-tags: true + + - id: setupJava + name: "🔧 Setup Java" + run: | + echo "JAVA_HOME=$(echo $JAVA_HOME_${{ inputs.java }}_X64)" >> "$GITHUB_ENV" + + - id: setupGradle + name: "🔧 Setup Gradle" + uses: gradle/actions/setup-gradle@v4 + with: + gradle-version: wrapper + cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }} + + - id: build + name: "🏗️ Build" + run: ./gradlew --build-cache ${{ inputs.gradle_tasks }} + env: + GITHUB_TOKEN: ${{ github.token }} + GITHUB_REPOSITORY: ${{ github.repository }} + GITHUB_USERNAME: ${{ github.actor }} + crowdinKey: ${{ secrets.CROWDIN_API_KEY }} + Version: "${{ needs.compute-version.outputs.version }}" \ No newline at end of file diff --git a/.github/workflows/gradle.publish.yaml b/.github/workflows/gradle.publish.yaml index cbfd512..e7b67d0 100644 --- a/.github/workflows/gradle.publish.yaml +++ b/.github/workflows/gradle.publish.yaml @@ -5,7 +5,7 @@ on: workflow_call: inputs: java: - description: "The version of Java to use to run Gradle" # Note: Gradle's Java toolchains feature is used for compiling, which is separate from this + description: "The version of Java to use to run Gradle" required: false type: string default: "21" @@ -24,23 +24,19 @@ on: required: false type: number default: 100 - secrets: DISCORD_WEBHOOK: required: true - MAVEN_USER: required: true MAVEN_PASSWORD: required: true - CURSE_API_KEY: required: true - CROWDIN_API_KEY: required: true - GRADLE_ENCRYPTION_KEY: + description: The AES key to enable Gradle cache encryption required: true permissions: @@ -49,39 +45,12 @@ permissions: jobs: compute-version: - name: Compute version - runs-on: ubuntu-latest - outputs: - version: ${{ steps.version.outputs.version }} - version_tag: ${{ steps.version.outputs.version_tag }} - minecraft_version: ${{ steps.minecraftVersion.outputs.minecraft_version }} - steps: - - id: checkout - name: "📦 Checkout" - uses: actions/checkout@v4 - with: - fetch-depth: 0 - fetch-tags: true - - - id: minecraftVersion - name: "📦 Extract Minecraft version" - run: | - cat gradle.properties | grep exactMinecraftVersion | cut -d "=" -f 2 > minecraft_version.txt - echo "Minecraft version: $(cat minecraft_version.txt)" - echo "minecraft_version=$(cat minecraft_version.txt)" >> "$GITHUB_OUTPUT" - - - id: version - name: "🔢 Compute version" - uses: PaulHatch/semantic-version@v5.4.0 - with: - tag_prefix: "v" - search_commit_body: true - debug: true - bump_each_commit: true - version_format: "${major}.${minor}.${patch}-${{ steps.minecraftVersion.outputs.minecraft_version }}-${{ inputs.curse_release_type }}" + uses: ./.github/workflows/gradle.version.yaml + with: + suffix: ${{ inputs.curse_release_type }} notify-build-start: - needs: ["compute-version"] + needs: [ "compute-version" ] name: "🔴 Build notifications (start)" runs-on: ubuntu-latest steps: @@ -104,7 +73,7 @@ jobs: target_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} gradle: - needs: ["compute-version"] # Make sure we now the version before starting to build + needs: [ "compute-version" ] runs-on: ubuntu-latest steps: - id: checkout @@ -116,8 +85,6 @@ jobs: - id: setupJava name: "🔧 Setup Java" - # https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md#java - # language=bash run: | echo "JAVA_HOME=$(echo $JAVA_HOME_${{ inputs.java }}_X64)" >> "$GITHUB_ENV" @@ -146,6 +113,11 @@ jobs: onlyLastTag: true maxIssues: ${{ inputs.changelog_max_issues }} + - id: get-mod-name + name: Get mod name + run: | + echo "mod_name=$(./gradlew --build-cache projectName)" >> "$GITHUB_ENV" + - id: publish name: "🚀 Publish" run: ./gradlew --build-cache ${{ inputs.gradle_tasks }} @@ -154,6 +126,7 @@ jobs: LDTTeamJfrogPassword: ${{ secrets.MAVEN_PASSWORD }} CURSE_API_KEY: ${{ secrets.CURSE_API_KEY }} CURSE_RELEASE_TYPE: ${{ inputs.curse_release_type }} + CUSTOM_CURSE_FILENAME: "${{ steps.get-mod-name.outputs.mod_name }}" crowdinKey: ${{ secrets.CROWDIN_API_KEY }} Version: "${{ needs.compute-version.outputs.version }}" @@ -188,4 +161,4 @@ jobs: context: 'Publishing' state: ${{ needs.gradle.result }} description: "Version: ${{ needs.compute-version.outputs.version }}" - target_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + target_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} \ No newline at end of file diff --git a/.github/workflows/gradle.version.yaml b/.github/workflows/gradle.version.yaml new file mode 100644 index 0000000..2781537 --- /dev/null +++ b/.github/workflows/gradle.version.yaml @@ -0,0 +1,51 @@ +name: Common Version Determination CI + +on: + workflow_call: + inputs: + suffix: + description: "The suffix to finish the version string with" + required: false + type: string + default: "" + outputs: + version: + description: "The computed version" + value: ${{ jobs.compute-version.outputs.version }} + minecraft_version: + description: "The minecraft version" + value: ${{ jobs.compute-version.outputs.minecraft_version }} + +permissions: + contents: read + +jobs: + compute-version: + runs-on: ubuntu-latest + outputs: + version: ${{ steps.version.outputs.version }} + minecraft_version: ${{ steps.minecraftVersion.outputs.minecraft_version }} + steps: + - id: checkout + name: "📦 Checkout" + uses: actions/checkout@v4 + with: + fetch-depth: 0 + fetch-tags: true + + - id: minecraftVersion + name: "📦 Extract Minecraft version" + run: | + cat gradle.properties | grep exactMinecraftVersion | cut -d "=" -f 2 > minecraft_version.txt + echo "Minecraft version: $(cat minecraft_version.txt)" + echo "minecraft_version=$(cat minecraft_version.txt)" >> "$GITHUB_OUTPUT" + + - id: version + name: "🔢 Compute version" + uses: PaulHatch/semantic-version@v5.4.0 + with: + tag_prefix: "v" + search_commit_body: true + debug: true + bump_each_commit: true + version_format: "${major}.${minor}.${patch}-${{ inputs.suffix }}" \ No newline at end of file diff --git a/gradle/mod.gradle b/gradle/mod.gradle index 4e1491f..b543c59 100644 --- a/gradle/mod.gradle +++ b/gradle/mod.gradle @@ -1154,6 +1154,10 @@ tasks.withType(Jar.class, {task -> task.duplicatesStrategy 'exclude' }) +tasks.named('projectName', Task.class, { task -> + print rootProject.name +}) + if (opc.isFeatureEnabled("mergableTranslations") && opc.hasPropertySet("translationMergeSources") && opc.hasPropertySet("translationMergeDestination")) { task mergeTranslations { doLast { From 33f086b7f870f2ad6036d4a60af5127dbd352aed Mon Sep 17 00:00:00 2001 From: Thom van den Akker Date: Sat, 24 Aug 2024 19:07:36 +0200 Subject: [PATCH 02/24] Use MC version --- .github/workflows/gradle.publish.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gradle.publish.yaml b/.github/workflows/gradle.publish.yaml index e7b67d0..17d8cd5 100644 --- a/.github/workflows/gradle.publish.yaml +++ b/.github/workflows/gradle.publish.yaml @@ -126,7 +126,7 @@ jobs: LDTTeamJfrogPassword: ${{ secrets.MAVEN_PASSWORD }} CURSE_API_KEY: ${{ secrets.CURSE_API_KEY }} CURSE_RELEASE_TYPE: ${{ inputs.curse_release_type }} - CUSTOM_CURSE_FILENAME: "${{ steps.get-mod-name.outputs.mod_name }}" + CUSTOM_CURSE_FILENAME: "${{ steps.get-mod-name.outputs.mod_name }} - ${{ needs.compute-version.outputs.minecraft_version }}" crowdinKey: ${{ secrets.CROWDIN_API_KEY }} Version: "${{ needs.compute-version.outputs.version }}" From 8d61d63b5c413425f78de8d8fdbfe1310abdbde1 Mon Sep 17 00:00:00 2001 From: Thom van den Akker Date: Sat, 24 Aug 2024 19:12:45 +0200 Subject: [PATCH 03/24] Test code --- .github/workflows/gradle.build.yaml | 3 ++- .github/workflows/gradle.publish.yaml | 2 +- gradle/mod.gradle | 7 ++++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/gradle.build.yaml b/.github/workflows/gradle.build.yaml index f28bbf3..f057231 100644 --- a/.github/workflows/gradle.build.yaml +++ b/.github/workflows/gradle.build.yaml @@ -68,6 +68,7 @@ jobs: - id: build name: "🏗️ Build" - run: ./gradlew --build-cache ${{ inputs.gradle_tasks }} + run: ./gradlew --build-cache ${{ inputs.gradle_tasks }} testArtifactName # TODO: REMOVE env: + CUSTOM_CURSE_FILE_NAME: "Minecolonies - ${{ needs.compute-version.outputs.minecraft_version }}" # TODO: REMOVE Version: "${{ needs.compute-version.outputs.version }}" \ No newline at end of file diff --git a/.github/workflows/gradle.publish.yaml b/.github/workflows/gradle.publish.yaml index 17d8cd5..838926c 100644 --- a/.github/workflows/gradle.publish.yaml +++ b/.github/workflows/gradle.publish.yaml @@ -126,7 +126,7 @@ jobs: LDTTeamJfrogPassword: ${{ secrets.MAVEN_PASSWORD }} CURSE_API_KEY: ${{ secrets.CURSE_API_KEY }} CURSE_RELEASE_TYPE: ${{ inputs.curse_release_type }} - CUSTOM_CURSE_FILENAME: "${{ steps.get-mod-name.outputs.mod_name }} - ${{ needs.compute-version.outputs.minecraft_version }}" + CUSTOM_CURSE_FILE_NAME: "${{ steps.get-mod-name.outputs.mod_name }} - ${{ needs.compute-version.outputs.minecraft_version }}" crowdinKey: ${{ secrets.CROWDIN_API_KEY }} Version: "${{ needs.compute-version.outputs.version }}" diff --git a/gradle/mod.gradle b/gradle/mod.gradle index b543c59..92fa4cc 100644 --- a/gradle/mod.gradle +++ b/gradle/mod.gradle @@ -1154,10 +1154,15 @@ tasks.withType(Jar.class, {task -> task.duplicatesStrategy 'exclude' }) -tasks.named('projectName', Task.class, { task -> +tasks.named('getProjectName', Task.class, { task -> print rootProject.name }) +// TODO: REMOVE +tasks.named('testArtifactName', Task.class, { task -> + println opc.getProperty('customCurseFileName') + " - " + project.version +}) + if (opc.isFeatureEnabled("mergableTranslations") && opc.hasPropertySet("translationMergeSources") && opc.hasPropertySet("translationMergeDestination")) { task mergeTranslations { doLast { From 0dfb25e4b13fc453321affd8f950f5468271e2d1 Mon Sep 17 00:00:00 2001 From: Thom van den Akker Date: Sat, 24 Aug 2024 19:32:04 +0200 Subject: [PATCH 04/24] Register, not named --- gradle/mod.gradle | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gradle/mod.gradle b/gradle/mod.gradle index 92fa4cc..45841c8 100644 --- a/gradle/mod.gradle +++ b/gradle/mod.gradle @@ -1154,14 +1154,14 @@ tasks.withType(Jar.class, {task -> task.duplicatesStrategy 'exclude' }) -tasks.named('getProjectName', Task.class, { task -> +tasks.register('getProjectName', Task.class) { print rootProject.name -}) +} // TODO: REMOVE -tasks.named('testArtifactName', Task.class, { task -> +tasks.register('testArtifactName', Task.class) { println opc.getProperty('customCurseFileName') + " - " + project.version -}) +} if (opc.isFeatureEnabled("mergableTranslations") && opc.hasPropertySet("translationMergeSources") && opc.hasPropertySet("translationMergeDestination")) { task mergeTranslations { From 332f3d2959ed8d57942537306f058bae6b07b2ae Mon Sep 17 00:00:00 2001 From: Thom van den Akker Date: Sat, 24 Aug 2024 19:39:01 +0200 Subject: [PATCH 05/24] DoLast --- gradle/mod.gradle | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gradle/mod.gradle b/gradle/mod.gradle index 45841c8..ced7098 100644 --- a/gradle/mod.gradle +++ b/gradle/mod.gradle @@ -1155,12 +1155,16 @@ tasks.withType(Jar.class, {task -> }) tasks.register('getProjectName', Task.class) { - print rootProject.name + doLast { + print rootProject.name + } } // TODO: REMOVE tasks.register('testArtifactName', Task.class) { - println opc.getProperty('customCurseFileName') + " - " + project.version + doLast { + println opc.getProperty('customCurseFileName') + " - " + project.version + } } if (opc.isFeatureEnabled("mergableTranslations") && opc.hasPropertySet("translationMergeSources") && opc.hasPropertySet("translationMergeDestination")) { From 7f619e335e0ab3f01c7a532c8104bca97d18c044 Mon Sep 17 00:00:00 2001 From: Thom van den Akker Date: Sat, 24 Aug 2024 19:46:46 +0200 Subject: [PATCH 06/24] Remove test code --- .github/workflows/gradle.build.yaml | 3 +-- gradle/mod.gradle | 7 ------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/.github/workflows/gradle.build.yaml b/.github/workflows/gradle.build.yaml index f057231..f28bbf3 100644 --- a/.github/workflows/gradle.build.yaml +++ b/.github/workflows/gradle.build.yaml @@ -68,7 +68,6 @@ jobs: - id: build name: "🏗️ Build" - run: ./gradlew --build-cache ${{ inputs.gradle_tasks }} testArtifactName # TODO: REMOVE + run: ./gradlew --build-cache ${{ inputs.gradle_tasks }} env: - CUSTOM_CURSE_FILE_NAME: "Minecolonies - ${{ needs.compute-version.outputs.minecraft_version }}" # TODO: REMOVE Version: "${{ needs.compute-version.outputs.version }}" \ No newline at end of file diff --git a/gradle/mod.gradle b/gradle/mod.gradle index ced7098..4f4b30c 100644 --- a/gradle/mod.gradle +++ b/gradle/mod.gradle @@ -1160,13 +1160,6 @@ tasks.register('getProjectName', Task.class) { } } -// TODO: REMOVE -tasks.register('testArtifactName', Task.class) { - doLast { - println opc.getProperty('customCurseFileName') + " - " + project.version - } -} - if (opc.isFeatureEnabled("mergableTranslations") && opc.hasPropertySet("translationMergeSources") && opc.hasPropertySet("translationMergeDestination")) { task mergeTranslations { doLast { From 42a3ffbdc240672e87015a2349da6360c653e102 Mon Sep 17 00:00:00 2001 From: Thom van den Akker Date: Sat, 24 Aug 2024 22:35:42 +0200 Subject: [PATCH 07/24] Remove some needless version info --- .github/workflows/gradle.build.yaml | 20 -------------------- .github/workflows/gradle.prerelease.yaml | 2 -- .github/workflows/gradle.publish.yaml | 2 -- .github/workflows/gradle.version.yaml | 8 +------- 4 files changed, 1 insertion(+), 31 deletions(-) diff --git a/.github/workflows/gradle.build.yaml b/.github/workflows/gradle.build.yaml index f28bbf3..b12914c 100644 --- a/.github/workflows/gradle.build.yaml +++ b/.github/workflows/gradle.build.yaml @@ -23,28 +23,8 @@ permissions: contents: read jobs: - compute-suffix: - runs-on: ubuntu-latest - outputs: - branch_suffix: ${{ steps.computeBranchSuffix.outputs.branch_suffix }} - steps: - - id: computeBranchSuffix - name: "🔢 Compute branch suffix" - run: | - gitRef="${{ github.ref }}" - branchName=$(echo "${gitRef/refs\/heads\//}") - echo "Branch name: $branchName" - - cleanedBranchName=$(echo $branchName | sed 's/[^a-zA-Z0-9]/-/g') - echo "Cleaned branch name: $cleanedBranchName" - - echo "branch_suffix=$cleanedBranchName" >> "$GITHUB_OUTPUT" - compute-version: - needs: [ "compute-suffix" ] uses: ./.github/workflows/gradle.version.yaml - with: - suffix: ${{ format('branch-{0}', needs.compute-suffix.outputs.branch_suffix) }} build: needs: [ "compute-version" ] diff --git a/.github/workflows/gradle.prerelease.yaml b/.github/workflows/gradle.prerelease.yaml index 4517c8b..e817e9a 100644 --- a/.github/workflows/gradle.prerelease.yaml +++ b/.github/workflows/gradle.prerelease.yaml @@ -29,8 +29,6 @@ permissions: jobs: compute-version: uses: ./.github/workflows/gradle.version.yaml - with: - suffix: pre-release gradle: needs: [ "compute-version" ] diff --git a/.github/workflows/gradle.publish.yaml b/.github/workflows/gradle.publish.yaml index 838926c..f6fb5c7 100644 --- a/.github/workflows/gradle.publish.yaml +++ b/.github/workflows/gradle.publish.yaml @@ -46,8 +46,6 @@ permissions: jobs: compute-version: uses: ./.github/workflows/gradle.version.yaml - with: - suffix: ${{ inputs.curse_release_type }} notify-build-start: needs: [ "compute-version" ] diff --git a/.github/workflows/gradle.version.yaml b/.github/workflows/gradle.version.yaml index 2781537..dbe8055 100644 --- a/.github/workflows/gradle.version.yaml +++ b/.github/workflows/gradle.version.yaml @@ -2,12 +2,6 @@ name: Common Version Determination CI on: workflow_call: - inputs: - suffix: - description: "The suffix to finish the version string with" - required: false - type: string - default: "" outputs: version: description: "The computed version" @@ -48,4 +42,4 @@ jobs: search_commit_body: true debug: true bump_each_commit: true - version_format: "${major}.${minor}.${patch}-${{ inputs.suffix }}" \ No newline at end of file + version_format: "${major}.${minor}.${patch}" \ No newline at end of file From 98de391b456abb8184d378e2f5739a57173078f9 Mon Sep 17 00:00:00 2001 From: Thom van den Akker Date: Sun, 25 Aug 2024 09:40:08 +0200 Subject: [PATCH 08/24] Redo version suffixes, remove release type from display name as it's already included --- .github/workflows/gradle.build.yaml | 20 ++++++++++++++++++++ .github/workflows/gradle.prerelease.yaml | 2 ++ .github/workflows/gradle.publish.yaml | 2 ++ .github/workflows/gradle.version.yaml | 8 +++++++- gradle/mod.gradle | 2 +- 5 files changed, 32 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gradle.build.yaml b/.github/workflows/gradle.build.yaml index b12914c..f28bbf3 100644 --- a/.github/workflows/gradle.build.yaml +++ b/.github/workflows/gradle.build.yaml @@ -23,8 +23,28 @@ permissions: contents: read jobs: + compute-suffix: + runs-on: ubuntu-latest + outputs: + branch_suffix: ${{ steps.computeBranchSuffix.outputs.branch_suffix }} + steps: + - id: computeBranchSuffix + name: "🔢 Compute branch suffix" + run: | + gitRef="${{ github.ref }}" + branchName=$(echo "${gitRef/refs\/heads\//}") + echo "Branch name: $branchName" + + cleanedBranchName=$(echo $branchName | sed 's/[^a-zA-Z0-9]/-/g') + echo "Cleaned branch name: $cleanedBranchName" + + echo "branch_suffix=$cleanedBranchName" >> "$GITHUB_OUTPUT" + compute-version: + needs: [ "compute-suffix" ] uses: ./.github/workflows/gradle.version.yaml + with: + suffix: ${{ format('branch-{0}', needs.compute-suffix.outputs.branch_suffix) }} build: needs: [ "compute-version" ] diff --git a/.github/workflows/gradle.prerelease.yaml b/.github/workflows/gradle.prerelease.yaml index e817e9a..4517c8b 100644 --- a/.github/workflows/gradle.prerelease.yaml +++ b/.github/workflows/gradle.prerelease.yaml @@ -29,6 +29,8 @@ permissions: jobs: compute-version: uses: ./.github/workflows/gradle.version.yaml + with: + suffix: pre-release gradle: needs: [ "compute-version" ] diff --git a/.github/workflows/gradle.publish.yaml b/.github/workflows/gradle.publish.yaml index f6fb5c7..838926c 100644 --- a/.github/workflows/gradle.publish.yaml +++ b/.github/workflows/gradle.publish.yaml @@ -46,6 +46,8 @@ permissions: jobs: compute-version: uses: ./.github/workflows/gradle.version.yaml + with: + suffix: ${{ inputs.curse_release_type }} notify-build-start: needs: [ "compute-version" ] diff --git a/.github/workflows/gradle.version.yaml b/.github/workflows/gradle.version.yaml index dbe8055..2781537 100644 --- a/.github/workflows/gradle.version.yaml +++ b/.github/workflows/gradle.version.yaml @@ -2,6 +2,12 @@ name: Common Version Determination CI on: workflow_call: + inputs: + suffix: + description: "The suffix to finish the version string with" + required: false + type: string + default: "" outputs: version: description: "The computed version" @@ -42,4 +48,4 @@ jobs: search_commit_body: true debug: true bump_each_commit: true - version_format: "${major}.${minor}.${patch}" \ No newline at end of file + version_format: "${major}.${minor}.${patch}-${{ inputs.suffix }}" \ No newline at end of file diff --git a/gradle/mod.gradle b/gradle/mod.gradle index 4f4b30c..e8f2c08 100644 --- a/gradle/mod.gradle +++ b/gradle/mod.gradle @@ -1040,7 +1040,7 @@ if (opc.isFeatureEnabled("curse") && opc.hasPropertySet("curseId") mainArtifactName = opc.getProperty('customCurseFileName') } - mainArtifact.displayName = mainArtifactName + " - " + project.version + " - " + mainArtifact.releaseType + mainArtifact.displayName = mainArtifactName + " - " + project.version } mainArtifact.changelog = project.rootProject.file("changelog.md") From ca75f9ea414af7a59f8cd0162e03f7aaf723d086 Mon Sep 17 00:00:00 2001 From: Thom van den Akker Date: Sun, 25 Aug 2024 11:14:11 +0200 Subject: [PATCH 09/24] Update --- .github/workflows/gradle.publish.yaml | 6 ------ .github/workflows/gradle.version.yaml | 2 +- gradle/mod.gradle | 6 ------ 3 files changed, 1 insertion(+), 13 deletions(-) diff --git a/.github/workflows/gradle.publish.yaml b/.github/workflows/gradle.publish.yaml index 838926c..23ddc67 100644 --- a/.github/workflows/gradle.publish.yaml +++ b/.github/workflows/gradle.publish.yaml @@ -113,11 +113,6 @@ jobs: onlyLastTag: true maxIssues: ${{ inputs.changelog_max_issues }} - - id: get-mod-name - name: Get mod name - run: | - echo "mod_name=$(./gradlew --build-cache projectName)" >> "$GITHUB_ENV" - - id: publish name: "🚀 Publish" run: ./gradlew --build-cache ${{ inputs.gradle_tasks }} @@ -126,7 +121,6 @@ jobs: LDTTeamJfrogPassword: ${{ secrets.MAVEN_PASSWORD }} CURSE_API_KEY: ${{ secrets.CURSE_API_KEY }} CURSE_RELEASE_TYPE: ${{ inputs.curse_release_type }} - CUSTOM_CURSE_FILE_NAME: "${{ steps.get-mod-name.outputs.mod_name }} - ${{ needs.compute-version.outputs.minecraft_version }}" crowdinKey: ${{ secrets.CROWDIN_API_KEY }} Version: "${{ needs.compute-version.outputs.version }}" diff --git a/.github/workflows/gradle.version.yaml b/.github/workflows/gradle.version.yaml index 2781537..b22c4b5 100644 --- a/.github/workflows/gradle.version.yaml +++ b/.github/workflows/gradle.version.yaml @@ -48,4 +48,4 @@ jobs: search_commit_body: true debug: true bump_each_commit: true - version_format: "${major}.${minor}.${patch}-${{ inputs.suffix }}" \ No newline at end of file + version_format: "${{ steps.minecraftVersion.outputs.minecraft_version }}-${major}.${minor}.${patch}-${{ inputs.suffix }}" \ No newline at end of file diff --git a/gradle/mod.gradle b/gradle/mod.gradle index e8f2c08..b357fef 100644 --- a/gradle/mod.gradle +++ b/gradle/mod.gradle @@ -1154,12 +1154,6 @@ tasks.withType(Jar.class, {task -> task.duplicatesStrategy 'exclude' }) -tasks.register('getProjectName', Task.class) { - doLast { - print rootProject.name - } -} - if (opc.isFeatureEnabled("mergableTranslations") && opc.hasPropertySet("translationMergeSources") && opc.hasPropertySet("translationMergeDestination")) { task mergeTranslations { doLast { From 8302ea700e7c14de021e700caa8ec1b4f1a3f876 Mon Sep 17 00:00:00 2001 From: Thom van den Akker Date: Sun, 25 Aug 2024 11:15:48 +0200 Subject: [PATCH 10/24] Remove mc version from outputs --- .github/workflows/gradle.version.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/gradle.version.yaml b/.github/workflows/gradle.version.yaml index b22c4b5..fa5f660 100644 --- a/.github/workflows/gradle.version.yaml +++ b/.github/workflows/gradle.version.yaml @@ -12,9 +12,6 @@ on: version: description: "The computed version" value: ${{ jobs.compute-version.outputs.version }} - minecraft_version: - description: "The minecraft version" - value: ${{ jobs.compute-version.outputs.minecraft_version }} permissions: contents: read @@ -24,7 +21,6 @@ jobs: runs-on: ubuntu-latest outputs: version: ${{ steps.version.outputs.version }} - minecraft_version: ${{ steps.minecraftVersion.outputs.minecraft_version }} steps: - id: checkout name: "📦 Checkout" From b2902baeb7fb898e8134b41d60e6ecfe4d0723fb Mon Sep 17 00:00:00 2001 From: Thom van den Akker Date: Sun, 25 Aug 2024 16:50:01 +0200 Subject: [PATCH 11/24] Prefix opc --- gradle/mod.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/mod.gradle b/gradle/mod.gradle index b357fef..ae585df 100644 --- a/gradle/mod.gradle +++ b/gradle/mod.gradle @@ -1157,7 +1157,7 @@ tasks.withType(Jar.class, {task -> if (opc.isFeatureEnabled("mergableTranslations") && opc.hasPropertySet("translationMergeSources") && opc.hasPropertySet("translationMergeDestination")) { task mergeTranslations { doLast { - def translationSources = opc.getStringListProperty("translationMergeSources"); + def translationSources = project.opc.getStringListProperty("translationMergeSources"); if (translationSources.size() >= 1) { def initialSource = translationSources[0]; def initialFile = project.file(initialSource); From fd613298ae339e3d4d5cfe3ba19a918576e693a5 Mon Sep 17 00:00:00 2001 From: Thom van den Akker Date: Sun, 25 Aug 2024 17:05:52 +0200 Subject: [PATCH 12/24] Use newly provided versioning strategies --- .github/workflows/gradle.build.yaml | 7 ++----- .github/workflows/gradle.prerelease.yaml | 4 +--- .github/workflows/gradle.publish.yaml | 2 +- .github/workflows/gradle.version.yaml | 12 +++++------- 4 files changed, 9 insertions(+), 16 deletions(-) diff --git a/.github/workflows/gradle.build.yaml b/.github/workflows/gradle.build.yaml index f28bbf3..3f2f5e7 100644 --- a/.github/workflows/gradle.build.yaml +++ b/.github/workflows/gradle.build.yaml @@ -41,13 +41,10 @@ jobs: echo "branch_suffix=$cleanedBranchName" >> "$GITHUB_OUTPUT" compute-version: - needs: [ "compute-suffix" ] uses: ./.github/workflows/gradle.version.yaml - with: - suffix: ${{ format('branch-{0}', needs.compute-suffix.outputs.branch_suffix) }} build: - needs: [ "compute-version" ] + needs: [ "compute-suffix", "compute-version" ] runs-on: ubuntu-latest steps: - id: checkout @@ -70,4 +67,4 @@ jobs: name: "🏗️ Build" run: ./gradlew --build-cache ${{ inputs.gradle_tasks }} env: - Version: "${{ needs.compute-version.outputs.version }}" \ No newline at end of file + Version: "${{ needs.compute-version.outputs.version }}-${{ needs.compute-version.outputs.minecraft_version }}-build-${{ steps.compute-suffix.outputs.branch_suffix }}" \ No newline at end of file diff --git a/.github/workflows/gradle.prerelease.yaml b/.github/workflows/gradle.prerelease.yaml index 4517c8b..ea628b2 100644 --- a/.github/workflows/gradle.prerelease.yaml +++ b/.github/workflows/gradle.prerelease.yaml @@ -29,8 +29,6 @@ permissions: jobs: compute-version: uses: ./.github/workflows/gradle.version.yaml - with: - suffix: pre-release gradle: needs: [ "compute-version" ] @@ -63,4 +61,4 @@ jobs: GITHUB_REPOSITORY: ${{ github.repository }} GITHUB_USERNAME: ${{ github.actor }} crowdinKey: ${{ secrets.CROWDIN_API_KEY }} - Version: "${{ needs.compute-version.outputs.version }}" \ No newline at end of file + Version: "${{ needs.compute-version.outputs.version }}-${{ needs.compute-version.outputs.minecraft_version }}-rc" \ No newline at end of file diff --git a/.github/workflows/gradle.publish.yaml b/.github/workflows/gradle.publish.yaml index 23ddc67..9192262 100644 --- a/.github/workflows/gradle.publish.yaml +++ b/.github/workflows/gradle.publish.yaml @@ -122,7 +122,7 @@ jobs: CURSE_API_KEY: ${{ secrets.CURSE_API_KEY }} CURSE_RELEASE_TYPE: ${{ inputs.curse_release_type }} crowdinKey: ${{ secrets.CROWDIN_API_KEY }} - Version: "${{ needs.compute-version.outputs.version }}" + Version: "${{ needs.compute-version.outputs.version }}-${{ needs.compute-version.outputs.minecraft_version }}${{ inputs.curse_release_type != 'release' && format('-{1}', inputs.curse_release_type) }}" - name: "🚀 Create GitHub release" uses: actions/create-release@v1 diff --git a/.github/workflows/gradle.version.yaml b/.github/workflows/gradle.version.yaml index fa5f660..dbe8055 100644 --- a/.github/workflows/gradle.version.yaml +++ b/.github/workflows/gradle.version.yaml @@ -2,16 +2,13 @@ name: Common Version Determination CI on: workflow_call: - inputs: - suffix: - description: "The suffix to finish the version string with" - required: false - type: string - default: "" outputs: version: description: "The computed version" value: ${{ jobs.compute-version.outputs.version }} + minecraft_version: + description: "The minecraft version" + value: ${{ jobs.compute-version.outputs.minecraft_version }} permissions: contents: read @@ -21,6 +18,7 @@ jobs: runs-on: ubuntu-latest outputs: version: ${{ steps.version.outputs.version }} + minecraft_version: ${{ steps.minecraftVersion.outputs.minecraft_version }} steps: - id: checkout name: "📦 Checkout" @@ -44,4 +42,4 @@ jobs: search_commit_body: true debug: true bump_each_commit: true - version_format: "${{ steps.minecraftVersion.outputs.minecraft_version }}-${major}.${minor}.${patch}-${{ inputs.suffix }}" \ No newline at end of file + version_format: "${major}.${minor}.${patch}" \ No newline at end of file From 236d7840d63206e8229c3fe2022f962d1e08483f Mon Sep 17 00:00:00 2001 From: Thom van den Akker Date: Sun, 25 Aug 2024 18:17:41 +0200 Subject: [PATCH 13/24] Update version strategy to OPC-first --- .github/workflows/gradle.build.yaml | 3 ++- .github/workflows/gradle.prerelease.yaml | 3 ++- .github/workflows/gradle.publish.yaml | 16 ++++++++++++++-- .github/workflows/gradle.version.yaml | 11 ----------- gradle/mod.gradle | 17 +++++++++++------ 5 files changed, 29 insertions(+), 21 deletions(-) diff --git a/.github/workflows/gradle.build.yaml b/.github/workflows/gradle.build.yaml index 3f2f5e7..33a4bcb 100644 --- a/.github/workflows/gradle.build.yaml +++ b/.github/workflows/gradle.build.yaml @@ -67,4 +67,5 @@ jobs: name: "🏗️ Build" run: ./gradlew --build-cache ${{ inputs.gradle_tasks }} env: - Version: "${{ needs.compute-version.outputs.version }}-${{ needs.compute-version.outputs.minecraft_version }}-build-${{ steps.compute-suffix.outputs.branch_suffix }}" \ No newline at end of file + VERSION_NUMBER: ${{ needs.compute-version.outputs.version }} + VERSION_SUFFIX: "beta-${{ steps.compute-suffix.outputs.branch_suffix }}" \ No newline at end of file diff --git a/.github/workflows/gradle.prerelease.yaml b/.github/workflows/gradle.prerelease.yaml index ea628b2..29bfba4 100644 --- a/.github/workflows/gradle.prerelease.yaml +++ b/.github/workflows/gradle.prerelease.yaml @@ -61,4 +61,5 @@ jobs: GITHUB_REPOSITORY: ${{ github.repository }} GITHUB_USERNAME: ${{ github.actor }} crowdinKey: ${{ secrets.CROWDIN_API_KEY }} - Version: "${{ needs.compute-version.outputs.version }}-${{ needs.compute-version.outputs.minecraft_version }}-rc" \ No newline at end of file + VERSION_NUMBER: ${{ needs.compute-version.outputs.version }} + VERSION_SUFFIX: rc \ No newline at end of file diff --git a/.github/workflows/gradle.publish.yaml b/.github/workflows/gradle.publish.yaml index 9192262..8ab814d 100644 --- a/.github/workflows/gradle.publish.yaml +++ b/.github/workflows/gradle.publish.yaml @@ -113,6 +113,18 @@ jobs: onlyLastTag: true maxIssues: ${{ inputs.changelog_max_issues }} + - id: generate-release-suffix + name: "Generate release suffix" + run: | + release_version_suffix = "alpha" + if [[ ${{ inputs.curse_release_type }} == release ]]; then + release_version_suffix = "" + elif [[ ${{ inputs.curse_release_type }} == beta ]]; then + release_version_suffix = "snapshot" + fi + echo "Release version suffix: ${release_version_suffix}" + echo "release_version_suffix=${release_version_suffix}" >> "$GITHUB_ENV" + - id: publish name: "🚀 Publish" run: ./gradlew --build-cache ${{ inputs.gradle_tasks }} @@ -120,9 +132,9 @@ jobs: LDTTeamJfrogUsername: ${{ secrets.MAVEN_USER }} LDTTeamJfrogPassword: ${{ secrets.MAVEN_PASSWORD }} CURSE_API_KEY: ${{ secrets.CURSE_API_KEY }} - CURSE_RELEASE_TYPE: ${{ inputs.curse_release_type }} crowdinKey: ${{ secrets.CROWDIN_API_KEY }} - Version: "${{ needs.compute-version.outputs.version }}-${{ needs.compute-version.outputs.minecraft_version }}${{ inputs.curse_release_type != 'release' && format('-{1}', inputs.curse_release_type) }}" + VERSION_NUMBER: ${{ needs.compute-version.outputs.version }} + VERSION_SUFFIX: ${{ steps.generate-release-suffix.outputs.release_version_suffix }} - name: "🚀 Create GitHub release" uses: actions/create-release@v1 diff --git a/.github/workflows/gradle.version.yaml b/.github/workflows/gradle.version.yaml index dbe8055..8f66cb6 100644 --- a/.github/workflows/gradle.version.yaml +++ b/.github/workflows/gradle.version.yaml @@ -6,9 +6,6 @@ on: version: description: "The computed version" value: ${{ jobs.compute-version.outputs.version }} - minecraft_version: - description: "The minecraft version" - value: ${{ jobs.compute-version.outputs.minecraft_version }} permissions: contents: read @@ -18,7 +15,6 @@ jobs: runs-on: ubuntu-latest outputs: version: ${{ steps.version.outputs.version }} - minecraft_version: ${{ steps.minecraftVersion.outputs.minecraft_version }} steps: - id: checkout name: "📦 Checkout" @@ -27,13 +23,6 @@ jobs: fetch-depth: 0 fetch-tags: true - - id: minecraftVersion - name: "📦 Extract Minecraft version" - run: | - cat gradle.properties | grep exactMinecraftVersion | cut -d "=" -f 2 > minecraft_version.txt - echo "Minecraft version: $(cat minecraft_version.txt)" - echo "minecraft_version=$(cat minecraft_version.txt)" >> "$GITHUB_OUTPUT" - - id: version name: "🔢 Compute version" uses: PaulHatch/semantic-version@v5.4.0 diff --git a/gradle/mod.gradle b/gradle/mod.gradle index ae585df..50a9e82 100644 --- a/gradle/mod.gradle +++ b/gradle/mod.gradle @@ -282,10 +282,15 @@ if (opc.isFeatureEnabled("MCVersionBasedVersioning") opc.getIntProperty("sourceVersionElementIndex"), opc.getIntProperty("mcVersionElementIndex") ) -} -else -{ - version = System.getenv().containsKey("Version") ? System.getenv("Version") : project.modVersion +} else { + def versionNumber = opc.hasProperty("versionNumber") ? opc.getProperty("versionNumber") : "0.0.1" + def versionSuffix = opc.hasProperty("versionSuffix") ? opc.getProperty("versionSuffix") : "alpha" + + if (versionSuffix == "") { + version = versionNumber + "-" + project.exactMinecraftVersion + } else { + version = versionNumber + "-" + project.exactMinecraftVersion + "-" + versionSuffix + } } archivesBaseName = project.modId project.properties.file = [ @@ -1035,12 +1040,12 @@ if (opc.isFeatureEnabled("curse") && opc.hasPropertySet("curseId") mainArtifact.releaseType = opc.hasPropertySet("curseReleaseType") ? opc.getProperty("curseReleaseType") : opc.getProperty("CURSERELEASETYPE") if (opc.isFeatureEnabled('reformatedCurseFiles')) { - def mainArtifactName = rootProject.name + def mainArtifactName = rootProject.name + " - " + project.version + " - " + mainArtifact.releaseType if (opc.isFeatureEnabled('customCurseFileName')) { mainArtifactName = opc.getProperty('customCurseFileName') } - mainArtifact.displayName = mainArtifactName + " - " + project.version + mainArtifact.displayName = mainArtifactName } mainArtifact.changelog = project.rootProject.file("changelog.md") From 0b816cd26092c903aed3c2b7df8c74e35df3ec4a Mon Sep 17 00:00:00 2001 From: Thom van den Akker Date: Sun, 25 Aug 2024 18:47:20 +0200 Subject: [PATCH 14/24] Move artifact name back --- gradle/mod.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle/mod.gradle b/gradle/mod.gradle index 50a9e82..41c3a66 100644 --- a/gradle/mod.gradle +++ b/gradle/mod.gradle @@ -1040,12 +1040,12 @@ if (opc.isFeatureEnabled("curse") && opc.hasPropertySet("curseId") mainArtifact.releaseType = opc.hasPropertySet("curseReleaseType") ? opc.getProperty("curseReleaseType") : opc.getProperty("CURSERELEASETYPE") if (opc.isFeatureEnabled('reformatedCurseFiles')) { - def mainArtifactName = rootProject.name + " - " + project.version + " - " + mainArtifact.releaseType + def mainArtifactName = rootProject.name if (opc.isFeatureEnabled('customCurseFileName')) { mainArtifactName = opc.getProperty('customCurseFileName') } - mainArtifact.displayName = mainArtifactName + mainArtifact.displayName = mainArtifactName + " - " + project.version + " - " + mainArtifact.releaseType } mainArtifact.changelog = project.rootProject.file("changelog.md") From 39fe3010a8ce3d0c1ee72dbbe2c03d2573f7f37e Mon Sep 17 00:00:00 2001 From: Thom van den Akker Date: Sun, 25 Aug 2024 18:47:48 +0200 Subject: [PATCH 15/24] Revert --- gradle/mod.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/mod.gradle b/gradle/mod.gradle index 41c3a66..789d7ef 100644 --- a/gradle/mod.gradle +++ b/gradle/mod.gradle @@ -1162,7 +1162,7 @@ tasks.withType(Jar.class, {task -> if (opc.isFeatureEnabled("mergableTranslations") && opc.hasPropertySet("translationMergeSources") && opc.hasPropertySet("translationMergeDestination")) { task mergeTranslations { doLast { - def translationSources = project.opc.getStringListProperty("translationMergeSources"); + def translationSources = opc.getStringListProperty("translationMergeSources"); if (translationSources.size() >= 1) { def initialSource = translationSources[0]; def initialFile = project.file(initialSource); From 3609b3b5a9055c1cfaf457abd453dbe2bf2200c8 Mon Sep 17 00:00:00 2001 From: Thom van den Akker Date: Sun, 25 Aug 2024 18:48:34 +0200 Subject: [PATCH 16/24] Add back --- .github/workflows/gradle.publish.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/gradle.publish.yaml b/.github/workflows/gradle.publish.yaml index 8ab814d..065696e 100644 --- a/.github/workflows/gradle.publish.yaml +++ b/.github/workflows/gradle.publish.yaml @@ -132,6 +132,7 @@ jobs: LDTTeamJfrogUsername: ${{ secrets.MAVEN_USER }} LDTTeamJfrogPassword: ${{ secrets.MAVEN_PASSWORD }} CURSE_API_KEY: ${{ secrets.CURSE_API_KEY }} + CURSE_RELEASE_TYPE: ${{ inputs.curse_release_type }} crowdinKey: ${{ secrets.CROWDIN_API_KEY }} VERSION_NUMBER: ${{ needs.compute-version.outputs.version }} VERSION_SUFFIX: ${{ steps.generate-release-suffix.outputs.release_version_suffix }} From c376850353bb99c2053f76d868425255dd0eaaaf Mon Sep 17 00:00:00 2001 From: Thom van den Akker Date: Sun, 25 Aug 2024 18:59:02 +0200 Subject: [PATCH 17/24] Modify curse release type --- .github/workflows/gradle.publish.yaml | 6 ++++-- .github/workflows/gradle.version.yaml | 11 +++++++++++ gradle/mod.gradle | 10 ++++++++-- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/.github/workflows/gradle.publish.yaml b/.github/workflows/gradle.publish.yaml index 065696e..7309a0f 100644 --- a/.github/workflows/gradle.publish.yaml +++ b/.github/workflows/gradle.publish.yaml @@ -113,8 +113,8 @@ jobs: onlyLastTag: true maxIssues: ${{ inputs.changelog_max_issues }} - - id: generate-release-suffix - name: "Generate release suffix" + - id: generate-release-information + name: "Generate release information" run: | release_version_suffix = "alpha" if [[ ${{ inputs.curse_release_type }} == release ]]; then @@ -124,6 +124,7 @@ jobs: fi echo "Release version suffix: ${release_version_suffix}" echo "release_version_suffix=${release_version_suffix}" >> "$GITHUB_ENV" + echo "mod_name=$(./gradlew --build-cache getProjectName)" >> "$GITHUB_ENV" - id: publish name: "🚀 Publish" @@ -133,6 +134,7 @@ jobs: LDTTeamJfrogPassword: ${{ secrets.MAVEN_PASSWORD }} CURSE_API_KEY: ${{ secrets.CURSE_API_KEY }} CURSE_RELEASE_TYPE: ${{ inputs.curse_release_type }} + CUSTOM_CURSE_FILE_NAME: "${{ steps.generate-release-information.outputs.mod_name }} - ${{ needs.compute-version.outputs.version }} - ${{ inputs.curse_release_type }}" crowdinKey: ${{ secrets.CROWDIN_API_KEY }} VERSION_NUMBER: ${{ needs.compute-version.outputs.version }} VERSION_SUFFIX: ${{ steps.generate-release-suffix.outputs.release_version_suffix }} diff --git a/.github/workflows/gradle.version.yaml b/.github/workflows/gradle.version.yaml index 8f66cb6..dbe8055 100644 --- a/.github/workflows/gradle.version.yaml +++ b/.github/workflows/gradle.version.yaml @@ -6,6 +6,9 @@ on: version: description: "The computed version" value: ${{ jobs.compute-version.outputs.version }} + minecraft_version: + description: "The minecraft version" + value: ${{ jobs.compute-version.outputs.minecraft_version }} permissions: contents: read @@ -15,6 +18,7 @@ jobs: runs-on: ubuntu-latest outputs: version: ${{ steps.version.outputs.version }} + minecraft_version: ${{ steps.minecraftVersion.outputs.minecraft_version }} steps: - id: checkout name: "📦 Checkout" @@ -23,6 +27,13 @@ jobs: fetch-depth: 0 fetch-tags: true + - id: minecraftVersion + name: "📦 Extract Minecraft version" + run: | + cat gradle.properties | grep exactMinecraftVersion | cut -d "=" -f 2 > minecraft_version.txt + echo "Minecraft version: $(cat minecraft_version.txt)" + echo "minecraft_version=$(cat minecraft_version.txt)" >> "$GITHUB_OUTPUT" + - id: version name: "🔢 Compute version" uses: PaulHatch/semantic-version@v5.4.0 diff --git a/gradle/mod.gradle b/gradle/mod.gradle index 789d7ef..8859f2b 100644 --- a/gradle/mod.gradle +++ b/gradle/mod.gradle @@ -1040,12 +1040,12 @@ if (opc.isFeatureEnabled("curse") && opc.hasPropertySet("curseId") mainArtifact.releaseType = opc.hasPropertySet("curseReleaseType") ? opc.getProperty("curseReleaseType") : opc.getProperty("CURSERELEASETYPE") if (opc.isFeatureEnabled('reformatedCurseFiles')) { - def mainArtifactName = rootProject.name + def mainArtifactName = rootProject.name + " - " + project.version + " - " + mainArtifact.releaseType if (opc.isFeatureEnabled('customCurseFileName')) { mainArtifactName = opc.getProperty('customCurseFileName') } - mainArtifact.displayName = mainArtifactName + " - " + project.version + " - " + mainArtifact.releaseType + mainArtifact.displayName = mainArtifactName } mainArtifact.changelog = project.rootProject.file("changelog.md") @@ -1159,6 +1159,12 @@ tasks.withType(Jar.class, {task -> task.duplicatesStrategy 'exclude' }) +tasks.register('getProjectName', Task.class) { + doLast { + print rootProject.name + } +} + if (opc.isFeatureEnabled("mergableTranslations") && opc.hasPropertySet("translationMergeSources") && opc.hasPropertySet("translationMergeDestination")) { task mergeTranslations { doLast { From d72befb38a5aafdfbb78d16697e3024b39fde3b1 Mon Sep 17 00:00:00 2001 From: Thom van den Akker Date: Sun, 25 Aug 2024 19:22:31 +0200 Subject: [PATCH 18/24] Fix --- gradle/mod.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle/mod.gradle b/gradle/mod.gradle index 8859f2b..dac6bcc 100644 --- a/gradle/mod.gradle +++ b/gradle/mod.gradle @@ -283,8 +283,8 @@ if (opc.isFeatureEnabled("MCVersionBasedVersioning") opc.getIntProperty("mcVersionElementIndex") ) } else { - def versionNumber = opc.hasProperty("versionNumber") ? opc.getProperty("versionNumber") : "0.0.1" - def versionSuffix = opc.hasProperty("versionSuffix") ? opc.getProperty("versionSuffix") : "alpha" + def versionNumber = opc.hasPropertySet("versionNumber") ? opc.getProperty("versionNumber") : "0.0.1" + def versionSuffix = opc.hasPropertySet("versionSuffix") ? opc.getProperty("versionSuffix") : "alpha" if (versionSuffix == "") { version = versionNumber + "-" + project.exactMinecraftVersion From 6d275fa8c3d073e6d07a54f384b09d1d2e92966e Mon Sep 17 00:00:00 2001 From: Thom van den Akker Date: Sun, 25 Aug 2024 19:23:30 +0200 Subject: [PATCH 19/24] Retry build From bafb8ce345671312fedd4f8845d10f2713e7a324 Mon Sep 17 00:00:00 2001 From: Thom van den Akker Date: Sun, 25 Aug 2024 19:26:42 +0200 Subject: [PATCH 20/24] Run --- .github/workflows/gradle.publish.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/gradle.publish.yaml b/.github/workflows/gradle.publish.yaml index 7309a0f..d58ac09 100644 --- a/.github/workflows/gradle.publish.yaml +++ b/.github/workflows/gradle.publish.yaml @@ -124,6 +124,7 @@ jobs: fi echo "Release version suffix: ${release_version_suffix}" echo "release_version_suffix=${release_version_suffix}" >> "$GITHUB_ENV" + ./gradlew # Prevent download message from appearing inside the getProjectName output echo "mod_name=$(./gradlew --build-cache getProjectName)" >> "$GITHUB_ENV" - id: publish From 583a00f02a65bcfddaa81aca6cf39cd21d14141e Mon Sep 17 00:00:00 2001 From: Thom van den Akker Date: Sun, 25 Aug 2024 19:28:32 +0200 Subject: [PATCH 21/24] Improve --- .github/workflows/gradle.build.yaml | 33 ++++++++++++----------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/.github/workflows/gradle.build.yaml b/.github/workflows/gradle.build.yaml index 33a4bcb..6152dbe 100644 --- a/.github/workflows/gradle.build.yaml +++ b/.github/workflows/gradle.build.yaml @@ -23,28 +23,11 @@ permissions: contents: read jobs: - compute-suffix: - runs-on: ubuntu-latest - outputs: - branch_suffix: ${{ steps.computeBranchSuffix.outputs.branch_suffix }} - steps: - - id: computeBranchSuffix - name: "🔢 Compute branch suffix" - run: | - gitRef="${{ github.ref }}" - branchName=$(echo "${gitRef/refs\/heads\//}") - echo "Branch name: $branchName" - - cleanedBranchName=$(echo $branchName | sed 's/[^a-zA-Z0-9]/-/g') - echo "Cleaned branch name: $cleanedBranchName" - - echo "branch_suffix=$cleanedBranchName" >> "$GITHUB_OUTPUT" - compute-version: uses: ./.github/workflows/gradle.version.yaml build: - needs: [ "compute-suffix", "compute-version" ] + needs: [ "compute-version" ] runs-on: ubuntu-latest steps: - id: checkout @@ -63,9 +46,21 @@ jobs: gradle-version: wrapper cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }} + - id: computeBranchSuffix + name: "🔢 Compute branch suffix" + run: | + gitRef="${{ github.ref }}" + branchName=$(echo "${gitRef/refs\/heads\//}") + echo "Branch name: $branchName" + + cleanedBranchName=$(echo $branchName | sed 's/[^a-zA-Z0-9]/-/g') + echo "Cleaned branch name: $cleanedBranchName" + + echo "branch_suffix=$cleanedBranchName" >> "$GITHUB_OUTPUT" + - id: build name: "🏗️ Build" run: ./gradlew --build-cache ${{ inputs.gradle_tasks }} env: VERSION_NUMBER: ${{ needs.compute-version.outputs.version }} - VERSION_SUFFIX: "beta-${{ steps.compute-suffix.outputs.branch_suffix }}" \ No newline at end of file + VERSION_SUFFIX: "beta-${{ steps.computeBranchSuffix.outputs.branch_suffix }}" \ No newline at end of file From bb6aa6409052af6317899092216e11cda401daea Mon Sep 17 00:00:00 2001 From: Thom van den Akker Date: Mon, 26 Aug 2024 14:49:22 +0200 Subject: [PATCH 22/24] Respect existing gradle.properties better --- .github/workflows/gradle.build.yaml | 4 ++-- .github/workflows/gradle.prerelease.yaml | 4 ++-- .github/workflows/gradle.publish.yaml | 4 ++-- gradle/mod.gradle | 20 +++++++++++--------- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/.github/workflows/gradle.build.yaml b/.github/workflows/gradle.build.yaml index 6152dbe..69f4e22 100644 --- a/.github/workflows/gradle.build.yaml +++ b/.github/workflows/gradle.build.yaml @@ -62,5 +62,5 @@ jobs: name: "🏗️ Build" run: ./gradlew --build-cache ${{ inputs.gradle_tasks }} env: - VERSION_NUMBER: ${{ needs.compute-version.outputs.version }} - VERSION_SUFFIX: "beta-${{ steps.computeBranchSuffix.outputs.branch_suffix }}" \ No newline at end of file + MOD_VERSION: ${{ needs.compute-version.outputs.version }} + MOD_VERSION_SUFFIX: "beta-${{ steps.computeBranchSuffix.outputs.branch_suffix }}" \ No newline at end of file diff --git a/.github/workflows/gradle.prerelease.yaml b/.github/workflows/gradle.prerelease.yaml index 29bfba4..8f4e38e 100644 --- a/.github/workflows/gradle.prerelease.yaml +++ b/.github/workflows/gradle.prerelease.yaml @@ -61,5 +61,5 @@ jobs: GITHUB_REPOSITORY: ${{ github.repository }} GITHUB_USERNAME: ${{ github.actor }} crowdinKey: ${{ secrets.CROWDIN_API_KEY }} - VERSION_NUMBER: ${{ needs.compute-version.outputs.version }} - VERSION_SUFFIX: rc \ No newline at end of file + MOD_VERSION: ${{ needs.compute-version.outputs.version }} + MOD_VERSION_SUFFIX: rc \ No newline at end of file diff --git a/.github/workflows/gradle.publish.yaml b/.github/workflows/gradle.publish.yaml index d58ac09..7aab270 100644 --- a/.github/workflows/gradle.publish.yaml +++ b/.github/workflows/gradle.publish.yaml @@ -137,8 +137,8 @@ jobs: CURSE_RELEASE_TYPE: ${{ inputs.curse_release_type }} CUSTOM_CURSE_FILE_NAME: "${{ steps.generate-release-information.outputs.mod_name }} - ${{ needs.compute-version.outputs.version }} - ${{ inputs.curse_release_type }}" crowdinKey: ${{ secrets.CROWDIN_API_KEY }} - VERSION_NUMBER: ${{ needs.compute-version.outputs.version }} - VERSION_SUFFIX: ${{ steps.generate-release-suffix.outputs.release_version_suffix }} + MOD_VERSION: ${{ needs.compute-version.outputs.version }} + MOD_VERSION_SUFFIX: ${{ steps.generate-release-suffix.outputs.release_version_suffix }} - name: "🚀 Create GitHub release" uses: actions/create-release@v1 diff --git a/gradle/mod.gradle b/gradle/mod.gradle index dac6bcc..104d227 100644 --- a/gradle/mod.gradle +++ b/gradle/mod.gradle @@ -269,6 +269,15 @@ if (opc.isFeatureEnabled("GitInformation")) { group = project.modGroup +def versionNumber = opc.hasPropertySet("modVersion") ? opc.getProperty("modVersion") : "0.0.1" +def versionSuffix = opc.hasPropertySet("modVersionSuffix") ? opc.getProperty("modVersionSuffix") : "alpha" +def versionString +if (versionSuffix == "") { + versionString = versionNumber + "-" + project.exactMinecraftVersion +} else { + versionString = versionNumber + "-" + project.exactMinecraftVersion + "-" + versionSuffix +} + if (opc.isFeatureEnabled("MCVersionBasedVersioning") && opc.hasPropertySet("mcVersionElementIndex") && opc.hasPropertySet("sourceVersionElementIndex") @@ -276,21 +285,14 @@ if (opc.isFeatureEnabled("MCVersionBasedVersioning") logger.lifecycle("MC based versioning active") version = opc.buildVersionNumberWithOffset( - (System.getenv().containsKey("Version") ? System.getenv("Version") : project.modVersion), + versionString, project.exactMinecraftVersion, opc.getProperty("sourceVersionName"), opc.getIntProperty("sourceVersionElementIndex"), opc.getIntProperty("mcVersionElementIndex") ) } else { - def versionNumber = opc.hasPropertySet("versionNumber") ? opc.getProperty("versionNumber") : "0.0.1" - def versionSuffix = opc.hasPropertySet("versionSuffix") ? opc.getProperty("versionSuffix") : "alpha" - - if (versionSuffix == "") { - version = versionNumber + "-" + project.exactMinecraftVersion - } else { - version = versionNumber + "-" + project.exactMinecraftVersion + "-" + versionSuffix - } + version = versionString } archivesBaseName = project.modId project.properties.file = [ From 6825e5d8023a6a4c57cf4894847c59c37771ae54 Mon Sep 17 00:00:00 2001 From: Thom van den Akker Date: Mon, 26 Aug 2024 21:55:21 +0200 Subject: [PATCH 23/24] Adjust to review --- .github/workflows/gradle.version.yaml | 11 ----------- gradle/mod.gradle | 10 ++-------- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/.github/workflows/gradle.version.yaml b/.github/workflows/gradle.version.yaml index dbe8055..8f66cb6 100644 --- a/.github/workflows/gradle.version.yaml +++ b/.github/workflows/gradle.version.yaml @@ -6,9 +6,6 @@ on: version: description: "The computed version" value: ${{ jobs.compute-version.outputs.version }} - minecraft_version: - description: "The minecraft version" - value: ${{ jobs.compute-version.outputs.minecraft_version }} permissions: contents: read @@ -18,7 +15,6 @@ jobs: runs-on: ubuntu-latest outputs: version: ${{ steps.version.outputs.version }} - minecraft_version: ${{ steps.minecraftVersion.outputs.minecraft_version }} steps: - id: checkout name: "📦 Checkout" @@ -27,13 +23,6 @@ jobs: fetch-depth: 0 fetch-tags: true - - id: minecraftVersion - name: "📦 Extract Minecraft version" - run: | - cat gradle.properties | grep exactMinecraftVersion | cut -d "=" -f 2 > minecraft_version.txt - echo "Minecraft version: $(cat minecraft_version.txt)" - echo "minecraft_version=$(cat minecraft_version.txt)" >> "$GITHUB_OUTPUT" - - id: version name: "🔢 Compute version" uses: PaulHatch/semantic-version@v5.4.0 diff --git a/gradle/mod.gradle b/gradle/mod.gradle index 104d227..68589a4 100644 --- a/gradle/mod.gradle +++ b/gradle/mod.gradle @@ -1042,12 +1042,12 @@ if (opc.isFeatureEnabled("curse") && opc.hasPropertySet("curseId") mainArtifact.releaseType = opc.hasPropertySet("curseReleaseType") ? opc.getProperty("curseReleaseType") : opc.getProperty("CURSERELEASETYPE") if (opc.isFeatureEnabled('reformatedCurseFiles')) { - def mainArtifactName = rootProject.name + " - " + project.version + " - " + mainArtifact.releaseType + def mainArtifactName = rootProject.name if (opc.isFeatureEnabled('customCurseFileName')) { mainArtifactName = opc.getProperty('customCurseFileName') } - mainArtifact.displayName = mainArtifactName + mainArtifact.displayName = mainArtifactName + " - " + versionNumber + " - " + mainArtifact.releaseType } mainArtifact.changelog = project.rootProject.file("changelog.md") @@ -1161,12 +1161,6 @@ tasks.withType(Jar.class, {task -> task.duplicatesStrategy 'exclude' }) -tasks.register('getProjectName', Task.class) { - doLast { - print rootProject.name - } -} - if (opc.isFeatureEnabled("mergableTranslations") && opc.hasPropertySet("translationMergeSources") && opc.hasPropertySet("translationMergeDestination")) { task mergeTranslations { doLast { From 5cbbcc73cc9fc9c3b43d1d4f3c84a32cbd8dee60 Mon Sep 17 00:00:00 2001 From: Thom van den Akker Date: Mon, 26 Aug 2024 21:56:15 +0200 Subject: [PATCH 24/24] Remove mod_name from outputs --- .github/workflows/gradle.publish.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/gradle.publish.yaml b/.github/workflows/gradle.publish.yaml index 7aab270..82c5ab1 100644 --- a/.github/workflows/gradle.publish.yaml +++ b/.github/workflows/gradle.publish.yaml @@ -124,8 +124,6 @@ jobs: fi echo "Release version suffix: ${release_version_suffix}" echo "release_version_suffix=${release_version_suffix}" >> "$GITHUB_ENV" - ./gradlew # Prevent download message from appearing inside the getProjectName output - echo "mod_name=$(./gradlew --build-cache getProjectName)" >> "$GITHUB_ENV" - id: publish name: "🚀 Publish" @@ -135,7 +133,6 @@ jobs: LDTTeamJfrogPassword: ${{ secrets.MAVEN_PASSWORD }} CURSE_API_KEY: ${{ secrets.CURSE_API_KEY }} CURSE_RELEASE_TYPE: ${{ inputs.curse_release_type }} - CUSTOM_CURSE_FILE_NAME: "${{ steps.generate-release-information.outputs.mod_name }} - ${{ needs.compute-version.outputs.version }} - ${{ inputs.curse_release_type }}" crowdinKey: ${{ secrets.CROWDIN_API_KEY }} MOD_VERSION: ${{ needs.compute-version.outputs.version }} MOD_VERSION_SUFFIX: ${{ steps.generate-release-suffix.outputs.release_version_suffix }}