diff --git a/.github/workflows/datagen.yml b/.github/workflows/datagen.yml new file mode 100644 index 0000000..ee6566a --- /dev/null +++ b/.github/workflows/datagen.yml @@ -0,0 +1,41 @@ +name: Data Generation + +on: + workflow_call: + inputs: + version: + required: true + type: string + +jobs: + datagen: + name: Data Generators + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: true + + - name: Set up JDK + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 17 + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + + - name: Data Generation + run: ./gradlew :neoforge:runData + env: + VERSION: ${{ inputs.version }} + GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Store Built Assets + if: success() + uses: actions/upload-artifact@v4 + with: + name: generated-data + path: neoforge/src/generated/resources \ No newline at end of file diff --git a/.github/workflows/nightly-builds.yml b/.github/workflows/nightly-builds.yml index 79d54cd..fa613dd 100644 --- a/.github/workflows/nightly-builds.yml +++ b/.github/workflows/nightly-builds.yml @@ -1,4 +1,4 @@ -name: Gradle Tests and Nightly (CI) +name: Publish and Announce Nightly Build env: GH_PKG_URL: "https://maven.pkg.github.com/${{ github.repository }}" @@ -25,7 +25,6 @@ jobs: fetch-depth: 150 fetch-tags: true submodules: true - - name: Version id: version uses: paulhatch/semantic-version@v5.4.0 @@ -35,71 +34,21 @@ jobs: search_commit_body: true datagen: - name: Data Generators - runs-on: ubuntu-22.04 - needs: [ vars ] - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - submodules: true - - - name: Set up JDK - uses: actions/setup-java@v4 - with: - distribution: temurin - java-version: 17 - - - name: Setup Gradle - uses: gradle/actions/setup-gradle@v3 - - - name: Data Generation - run: ./gradlew :neoforge:runData - env: - GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Store Built Assets - if: success() - uses: actions/upload-artifact@v4 - with: - name: generated-data - path: neoforge/src/generated/resources - - publish-gh-package: - name: Publish Github Package - Nightly - runs-on: ubuntu-22.04 - needs: [ vars, datagen ] - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - submodules: true - - - name: Set up JDK - uses: actions/setup-java@v4 - with: - distribution: temurin - java-version: 17 - - - name: Setup Gradle - uses: gradle/actions/setup-gradle@v3 - - - name: Pull Built Generated Data - uses: actions/download-artifact@v4 - with: - name: generated-data - path: neoforge/src/generated/resources - - - name: Publish - run: ./gradlew :neoforge:publish - env: - VERSION: ${{ needs.vars.outputs.version }} - GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + needs: [vars] + uses: ./.github/workflows/datagen.yml + secrets: inherit + with: + version: ${{ needs.vars.outputs.version }} + + publish: + needs: [vars, datagen] + uses: ./.github/workflows/publish.yml + secrets: inherit + with: + version: ${{ needs.vars.outputs.version }} announce: name: Discord Announcement - needs: [ publish-gh-package ] + needs: [ publish ] uses: ./.github/workflows/announce-latest-nightly.yml secrets: inherit \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..553315c --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,42 @@ +# REQUIRES DATAGEN TO BE CALLED IN A JOB BEFORE THIS!! + +name: Release Variables + +on: + workflow_call: + inputs: + version: + required: true + type: string + +jobs: + publish: + name: Publish Code as Github Package - ${{ inputs.version }} + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: true + + - name: Set up JDK + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 17 + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + + - name: Pull Built Generated Data + uses: actions/download-artifact@v4 + with: + name: generated-data + path: neoforge/src/generated/resources + + - name: Publish + run: ./gradlew :neoforge:publish + env: + VERSION: ${{ inputs.version }} + GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/tagged-version-build.yml b/.github/workflows/tagged-version-build.yml new file mode 100644 index 0000000..1ff26e7 --- /dev/null +++ b/.github/workflows/tagged-version-build.yml @@ -0,0 +1,73 @@ +# Creates releases on Curseforge and Github Releases based on v* tags +name: Tagged Version Release + +on: + workflow_dispatch: + +jobs: + vars: + name: Gather Variables + uses: ./.github/workflows/variables-release.yml + secrets: inherit + + datagen: + name: Build + needs: [vars] + uses: ./.github/workflows/datagen.yml + secrets: inherit + with: + version: ${{ needs.vars.outputs.modVersion }} + + publish: + needs: [vars] + uses: ./.github/workflows/publish.yml + secrets: inherit + with: + version: ${{ needs.vars.outputs.modVersion }} + + release-gh: + name: Make Github Release + runs-on: ubuntu-20.04 + needs: [vars, publish] + steps: + - name: Download Build Results + uses: actions/download-artifact@v4 + with: + name: libs + path: build-out + + - name: Create GitHub Release + uses: "marvinpinto/action-automatic-releases@latest" + with: + title: "Release ${{ needs.vars.outputs.modVersion }}" + automatic_release_tag: "${{ needs.vars.outputs.modVersion }}" + repo_token: "${{ secrets.GITHUB_TOKEN }}" + prerelease: false + files: | + build/libs/simplehoney-neoforge-${{ needs.vars.outputs.modVersion }}.jar +# build/libs/${{ needs.vars.outputs.mod_id }}-${{ needs.vars.outputs.version }}-api.jar + + release-cf: + name: Make Curseforge Release + runs-on: ubuntu-20.04 + needs: [vars, publish] + steps: + - name: Download Build Results + uses: actions/download-artifact@v4 + with: + name: libs + path: build-out + + - name: Full File + id: filename + run: echo "::set-output name=fullpath::build-out/simplehoney-neoforge-${{ needs.vars.outputs.modVersion }}.jar" + + - name: Create CurseForge Release + uses: itsmeow/curseforge-upload@master + with: + token: ${{ secrets.CURSEFORGE_TOKEN }} + project_id: ${{ secrets.CF_PROJECT_ID }} + game_endpoint: minecraft + file_path: ${{ steps.filename.outputs.fullpath }} + game_versions: java:Java 17,NeoForge + release_type: beta \ No newline at end of file diff --git a/.github/workflows/variables-release.yml b/.github/workflows/variables-release.yml new file mode 100644 index 0000000..5806352 --- /dev/null +++ b/.github/workflows/variables-release.yml @@ -0,0 +1,59 @@ +name: Release Variables + +on: + workflow_call: + outputs: + mcVersion: + description: "Minecraft Version" + value: ${{ jobs.vars.outputs.mcVersion }} + neoVersion: + description: "Neoforge Version" + value: ${{ jobs.vars.outputs.neoVersion }} + modVersion: + description: "Mod Version" + value: ${{ jobs.vars.outputs.modVersion }} + +jobs: + vars: + name: Get Variables + runs-on: ubuntu-latest + outputs: + mcVersion: ${{steps.minecraft.outputs.version}} + neoVersion: ${{steps.neoforge.outputs.version}} + modVersion: ${{steps.version.outputs.version}} + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 150 + fetch-tags: true + + - name: Set up JDK + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 17 + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + + - name: Version + id: version + uses: paulhatch/semantic-version@v5.4.0 + with: + change_path: "neoforge" + version_format: "${major}.${minor}.${patch}" + search_commit_body: true + + - name: MC Version + id: minecraft + run: ./gradlew mcVersion -q >> "$GITHUB_OUTPUT" + env: + VERSION: ${{ steps.version.outputs.version }} + + - name: NeoForge Version + id: neoforge + run: ./gradlew neoVersion -q >> "$GITHUB_OUTPUT" + env: + VERSION: ${{ steps.version.outputs.version }} \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..01cb6fb --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,13 @@ +tasks.create("mcVersion") { + doFirst { + val mc = libraries.versions.minecraft.get() + println($"version=$mc") + } +} + +tasks.create("neoVersion") { + doFirst { + val neo = libraries.versions.neoforge.get() + println($"version=$neo") + } +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 35b6d14..eef0f74 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,7 @@ # Sets default memory used for gradle commands. Can be overridden by user or command line properties. org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false -org.gradle.debug=false \ No newline at end of file +org.gradle.debug=false + +## Mod Properties +mod_id=simplehoney \ No newline at end of file diff --git a/neoforge/build.gradle.kts b/neoforge/build.gradle.kts index 97f6292..51f7719 100644 --- a/neoforge/build.gradle.kts +++ b/neoforge/build.gradle.kts @@ -160,7 +160,7 @@ tasks.withType { "Specification-Vendor" to "CompactMods", "Specification-Version" to "2", "Implementation-Title" to "Simple Honey", - "Implementation-Version" to archiveVersion, + "Implementation-Version" to envVersion, "Implementation-Vendor" to "CompactMods", "Implementation-Timestamp" to now, "Minecraft-Version" to libraries.versions.minecraft.get(), @@ -187,7 +187,7 @@ tasks.withType().configureEach { "mod_id" to modId, "mod_name" to prop("mod_name"), "mod_license" to prop("mod_license"), - "mod_version" to prop("mod_version"), + "mod_version" to envVersion, "mod_authors" to prop("mod_authors"), "mod_description" to prop("mod_description") ) diff --git a/neoforge/gradle.properties b/neoforge/gradle.properties index d27903b..8358ff5 100644 --- a/neoforge/gradle.properties +++ b/neoforge/gradle.properties @@ -9,10 +9,8 @@ neo_version_range=[20.4,) loader_version_range=[2,) ## Mod Properties -mod_id=simplehoney mod_name=Simple Honey mod_license=MIT -mod_version=0.1.0 mod_group_id=dev.compactmods.simplehoney mod_authors=RobotGryphon mod_description=Because working with vanilla beehives is pain. \ No newline at end of file