From 5eeaa50384f4c373d7f2b65362f3a06415d74893 Mon Sep 17 00:00:00 2001 From: Sarun Intaralawan Date: Sun, 21 Jul 2024 21:16:56 +0700 Subject: [PATCH] build: enable workflows --- .github/workflows/build.yml | 40 +++++++++++++++++++++++++++++++++++++ build.gradle | 8 ++++++-- gradle.properties | 3 ++- 3 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..2686a0e --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,40 @@ +name: build +on: + push: + branches: + - main + tags: + - v* + +jobs: + build: + permissions: + contents: write + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Validate Gradle wrapper + uses: gradle/wrapper-validation-action@v1 + - name: Initialise JDK 21 + uses: actions/setup-java@v3 + with: + java-version: 21 + distribution: 'microsoft' + - name: Replace version number in gradle.properties + if: ${{ github.event.created && startsWith(github.ref, 'refs/tags/') }} + run: | + sed -i -e "s|0.0.0-PLACEHOLDER|$(echo "${{ github.ref }}" | sed -e "s|refs/tags/v||g" -)|g" gradle.properties + cat gradle.properties + - name: Build + run: ./gradlew build + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: Artifacts + path: build/libs/ + - name: Publish + uses: Kir-Antipov/mc-publish@v3.3 + if: ${{ github.event.created && startsWith(github.ref, 'refs/tags/') }} + with: + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/build.gradle b/build.gradle index 9de1a54..737c470 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,11 @@ version = project.mod_version group = project.maven_group base { - archivesName = project.archives_base_name + archivesName = project.archives_base_name + '-mc' + project.minecraft_version + '-' + project.loader +} + +if (version == '0.0.0-PLACEHOLDER') { + version += "." + new Date().format('yyyyMMdd.HHmmss') } repositories { @@ -69,7 +73,7 @@ java { jar { from("LICENSE") { - rename { "${it}_${project.archivesBaseName}"} + rename { "${it}_${project.base.archivesName.get()}"} } } diff --git a/gradle.properties b/gradle.properties index 52222df..3339ae6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,9 +11,10 @@ org.gradle.parallel=true loom_version=1.9-SNAPSHOT # Mod Properties - mod_version=0.15.4b + mod_version=0.0.0-PLACEHOLDER maven_group=eu.pabl archives_base_name=twitchchat + loader=fabric # Dependencies fabric_version=0.111.0+1.21.4