From 6fd55e99e6d0b3d876b19a19b00fa44d60ad417f Mon Sep 17 00:00:00 2001 From: JetsadaWijit Date: Fri, 23 Jan 2026 16:44:36 +0000 Subject: [PATCH 1/7] ci: Configure automated package publishing --- .github/workflows/build.yml | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ca2c79d..425763c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,40 +1,63 @@ -name: Build MCExtension +name: Build & Publish MCExtension on: push: branches: [ "master" ] + tags: [ "v*" ] pull_request: branches: [ "master" ] jobs: build: runs-on: ubuntu-latest + permissions: + contents: read + packages: write steps: - # 1. Check out the code - name: Checkout Code uses: actions/checkout@v4 - # 2. Set up Java 21 - name: Set up JDK 21 uses: actions/setup-java@v4 with: java-version: '21' distribution: 'temurin' - # 3. Grant execute permission & Fix Windows line endings - name: Fix Gradlew Permissions run: | chmod +x gradlew sed -i 's/\r$//' gradlew - # 4. Build with Gradle - - name: Build with Gradle + # 4a. Build (Test Only) + # Run this ONLY for Pull Requests. + - name: Build (Test Only) + if: github.event_name == 'pull_request' run: ./gradlew clean build env: BUILD_NUMBER: ${{ github.run_number }} - # 5. Save the JARs + # 4b. Build & Publish (DEV) + # Run this for 'push to master' (creates -DEV builds) + - name: Publish Dev Build + if: github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/') + run: ./gradlew clean build publish + env: + BUILD_NUMBER: ${{ github.run_number }} + USER_GITHUB_NAME: ${{ github.actor }} + USER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # 4c. Build & Publish (RELEASE) + # Run this ONLY when a tag (v*) is pushed. + - name: Publish Release + if: startsWith(github.ref, 'refs/tags/') + run: ./gradlew clean build publish + env: + # We pass the tag name (e.g., v2026.0.0) to Gradle + RELEASE_VERSION: ${{ github.ref_name }} + USER_GITHUB_NAME: ${{ github.actor }} + USER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Upload Build Artifacts uses: actions/upload-artifact@v4 with: From 034a949d9884fcb54d18cd0019bb1257eceb9c34 Mon Sep 17 00:00:00 2001 From: JetsadaWijit Date: Fri, 23 Jan 2026 16:45:02 +0000 Subject: [PATCH 2/7] build: Add dynamic release versioning logic --- build.gradle | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index ea05fc3..be4e367 100644 --- a/build.gradle +++ b/build.gradle @@ -9,21 +9,26 @@ plugins { // --- DYNAMIC VERSIONING LOGIC --- // 1. Detect Build Environment String buildNum = System.getenv("BUILD_NUMBER") +String releaseTag = System.getenv("RELEASE_VERSION") // Passed from GitHub Actions boolean isDevBuild = (buildNum != null && !buildNum.isEmpty()) // 2. Calculate the Version String IMMEDIATELY String calculatedVersion = "unspecified" -// Check for the property defined in gradle.properties -if (project.hasProperty('project-version')) { +if (releaseTag != null && !releaseTag.isEmpty()) { + // RELEASE STRATEGY: + // If a tag exists (e.g., "v2026.0.0"), use it directly but strip the "v". + // Result: "2026.0.0" (Clean, no -SNAPSHOT or -DEV) + calculatedVersion = releaseTag.replace("v", "") +} else if (project.hasProperty('project-version')) { + // DEV STRATEGY: def baseVersion = project.property('project-version') if (isDevBuild) { - // CI Strategy: "2026.0.0-9-DEV" + // CI Dev Build: "2026.0.0-9-DEV" calculatedVersion = "${baseVersion}-${buildNum}-DEV" } else { - // Local Strategy: "2026.0.0-SNAPSHOT" - // Appends SNAPSHOT locally to distinguish from release builds + // Local Build: "2026.0.0-SNAPSHOT" calculatedVersion = "${baseVersion}-SNAPSHOT" } } From 27d249e9b7d2554121549aa330f44fb0284d0078 Mon Sep 17 00:00:00 2001 From: JetsadaWijit Date: Fri, 23 Jan 2026 17:20:16 +0000 Subject: [PATCH 3/7] ci: Add monthly release automation --- .github/workflows/build_monthly.yml | 79 +++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 .github/workflows/build_monthly.yml diff --git a/.github/workflows/build_monthly.yml b/.github/workflows/build_monthly.yml new file mode 100644 index 0000000..2dddd5b --- /dev/null +++ b/.github/workflows/build_monthly.yml @@ -0,0 +1,79 @@ +name: Monthly Version Update & Publish + +on: + schedule: + - cron: '0 0 1 * *' # Run at 00:00 UTC on the 1st of every month + workflow_dispatch: # Allows manual testing + +jobs: + monthly-release: + runs-on: ubuntu-latest + permissions: + contents: write + packages: write + + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + # Optional: Use the token here too if you want the checkout + # to be authenticated as the agent (helps with branch protection) + token: ${{ secrets.AGENT_TOKEN }} + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: 'temurin' + + - name: Fix Gradlew Permissions + run: | + chmod +x gradlew + sed -i 's/\r$//' gradlew + + - name: Calculate New Version + id: versioning + run: | + YEAR=$(date +'%Y') + MONTH=$(date +'%m') + MONTH=$((10#$MONTH)) + MAJOR=$((MONTH / 10)) + MINOR=$((MONTH % 10)) + NEW_VERSION="$YEAR.$MAJOR.$MINOR" + + echo "Calculated Version: $NEW_VERSION" + echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT + + - name: Create Release Branch + run: | + VERSION=${{ steps.versioning.outputs.new_version }} + git checkout -b "release/$VERSION" + echo "Created branch release/$VERSION" + + - name: Update gradle.properties + run: | + NEW_VERSION=${{ steps.versioning.outputs.new_version }} + sed -i "s/^project-version=.*/project-version=$NEW_VERSION/" gradle.properties + grep "project-version" gradle.properties + + - name: Build and Publish Package + run: ./gradlew clean build publish + env: + RELEASE_VERSION: ${{ steps.versioning.outputs.new_version }} + # Force the uploader to be agent-mcengine + USER_GITHUB_NAME: "agent-mcengine" + USER_GITHUB_TOKEN: ${{ secrets.AGENT_TOKEN }} + + - name: Push Branch + run: | + VERSION=${{ steps.versioning.outputs.new_version }} + + # This sets the visible commit author + git config --global user.name "agent-mcengine" + git config --global user.email "mcengine.official.agt@outlook.com" + + git add gradle.properties + git commit -m "chore: Release version $VERSION" + + # Push using the authenticated user (from Checkout step or default) + git push origin "release/$VERSION" From 02affde7b783af5ec58c826defd9291830c125b9 Mon Sep 17 00:00:00 2001 From: JetsadaWijit Date: Sat, 24 Jan 2026 00:43:55 +0700 Subject: [PATCH 4/7] build: Add iteration support to versioning strategy --- .github/workflows/build_monthly.yml | 8 ++++++++ build.gradle | 14 ++++++++------ gradle.properties | 1 + 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build_monthly.yml b/.github/workflows/build_monthly.yml index 2dddd5b..2698927 100644 --- a/.github/workflows/build_monthly.yml +++ b/.github/workflows/build_monthly.yml @@ -53,8 +53,16 @@ jobs: - name: Update gradle.properties run: | NEW_VERSION=${{ steps.versioning.outputs.new_version }} + + # 1. Update Version (e.g., 2026.0.2) sed -i "s/^project-version=.*/project-version=$NEW_VERSION/" gradle.properties + + # 2. Reset Iteration to 1 (So next dev build starts at 1) + sed -i "s/^project-iteration=.*/project-iteration=1/" gradle.properties + + # Verify grep "project-version" gradle.properties + grep "project-iteration" gradle.properties - name: Build and Publish Package run: ./gradlew clean build publish diff --git a/build.gradle b/build.gradle index be4e367..ff73236 100644 --- a/build.gradle +++ b/build.gradle @@ -17,19 +17,21 @@ String calculatedVersion = "unspecified" if (releaseTag != null && !releaseTag.isEmpty()) { // RELEASE STRATEGY: - // If a tag exists (e.g., "v2026.0.0"), use it directly but strip the "v". - // Result: "2026.0.0" (Clean, no -SNAPSHOT or -DEV) + // If a tag exists (e.g., "v2026.0.0" or "v2026.0.0-1"), use it directly but strip the "v". + // Result: "2026.0.0" or "2026.0.0-1" calculatedVersion = releaseTag.replace("v", "") } else if (project.hasProperty('project-version')) { // DEV STRATEGY: def baseVersion = project.property('project-version') + def iteration = project.hasProperty('project-iteration') ? project.property('project-iteration') : "1" if (isDevBuild) { - // CI Dev Build: "2026.0.0-9-DEV" - calculatedVersion = "${baseVersion}-${buildNum}-DEV" + // CI Dev Build: "2026.0.0-1-9-DEV" + // Format: {Version}-{Iteration}-{BuildNum}-DEV + calculatedVersion = "${baseVersion}-${iteration}-${buildNum}-DEV" } else { - // Local Build: "2026.0.0-SNAPSHOT" - calculatedVersion = "${baseVersion}-SNAPSHOT" + // Local Build: "2026.0.0-1-SNAPSHOT" + calculatedVersion = "${baseVersion}-${iteration}-SNAPSHOT" } } diff --git a/gradle.properties b/gradle.properties index 055173f..954dd9b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,6 +4,7 @@ git-org-repository=mcextension # --- Artifact Identity --- project-version=2026.0.0 +project-iteration=1 project-group=io.github.mcengine project-artifact-id=mcextension project-artifact-name=MCExtension From 6eccf2dc9d8ee84a429422d1ab27f7440cb7d7ef Mon Sep 17 00:00:00 2001 From: JetsadaWijit Date: Sat, 24 Jan 2026 00:44:58 +0700 Subject: [PATCH 5/7] chore: Bump version to 2026.0.2 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 954dd9b..b60224e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ git-org-name=MCEngine git-org-repository=mcextension # --- Artifact Identity --- -project-version=2026.0.0 +project-version=2026.0.2 project-iteration=1 project-group=io.github.mcengine project-artifact-id=mcextension From 9fdf336939b8c11efa624f0071562031741e2b86 Mon Sep 17 00:00:00 2001 From: JetsadaWijit Date: Sat, 24 Jan 2026 01:16:57 +0700 Subject: [PATCH 6/7] ci: allow dev builds to publish on pull requests --- .github/workflows/build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 425763c..3c676bc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -40,7 +40,7 @@ jobs: # 4b. Build & Publish (DEV) # Run this for 'push to master' (creates -DEV builds) - name: Publish Dev Build - if: github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/') + if: github.event_name == 'push' || github.event_name == 'pull_request' && !startsWith(github.ref, 'refs/tags/') run: ./gradlew clean build publish env: BUILD_NUMBER: ${{ github.run_number }} @@ -68,3 +68,4 @@ jobs: !**/build/libs/*-sources.jar !**/build/libs/*-javadoc.jar retention-days: 1 + From 1594a68a6a09b9c5d4639693e754023f94646c85 Mon Sep 17 00:00:00 2001 From: JetsadaWijit Date: Sat, 24 Jan 2026 01:50:16 +0700 Subject: [PATCH 7/7] fix: resolve YAML syntax errors in GitHub Actions workflow --- .github/workflows/build.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3c676bc..81f2748 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,7 +32,7 @@ jobs: # 4a. Build (Test Only) # Run this ONLY for Pull Requests. - name: Build (Test Only) - if: github.event_name == 'pull_request' + if: ${{ github.event_name == 'pull_request' }} run: ./gradlew clean build env: BUILD_NUMBER: ${{ github.run_number }} @@ -40,7 +40,7 @@ jobs: # 4b. Build & Publish (DEV) # Run this for 'push to master' (creates -DEV builds) - name: Publish Dev Build - if: github.event_name == 'push' || github.event_name == 'pull_request' && !startsWith(github.ref, 'refs/tags/') + if: ${{ (github.event_name == 'push' || github.event_name == 'pull_request') && !startsWith(github.ref, 'refs/tags/') }} run: ./gradlew clean build publish env: BUILD_NUMBER: ${{ github.run_number }} @@ -50,7 +50,7 @@ jobs: # 4c. Build & Publish (RELEASE) # Run this ONLY when a tag (v*) is pushed. - name: Publish Release - if: startsWith(github.ref, 'refs/tags/') + if: ${{ startsWith(github.ref, 'refs/tags/') }} run: ./gradlew clean build publish env: # We pass the tag name (e.g., v2026.0.0) to Gradle @@ -68,4 +68,3 @@ jobs: !**/build/libs/*-sources.jar !**/build/libs/*-javadoc.jar retention-days: 1 -