Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 32 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
contents: write
packages: write

steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up JDK 21
uses: actions/setup-java@v4
Expand All @@ -29,6 +31,15 @@ jobs:
chmod +x gradlew
sed -i 's/\r$//' gradlew

# Added step to check project-iteration from gradle.properties
- name: Check Iteration
id: check_iteration
run: |
ITERATION=$(grep 'project-iteration=' gradle.properties | cut -d'=' -f2)
VERSION=$(grep 'project-version=' gradle.properties | cut -d'=' -f2)
echo "iteration=$ITERATION" >> $GITHUB_OUTPUT
echo "version=$VERSION" >> $GITHUB_OUTPUT

# 4a. Build (Test Only)
# Run this ONLY for Pull Requests.
- name: Build (Test Only)
Expand All @@ -39,25 +50,40 @@ jobs:

# 4b. Build & Publish (DEV)
# Run this for 'push to master' (creates -DEV builds)
# Logic: Run if (push OR PR) AND NOT a tag AND iteration != 0
- name: Publish Dev Build
if: ${{ (github.event_name == 'push' || github.event_name == 'pull_request') && !startsWith(github.ref, 'refs/tags/') }}
id: publish_dev
if: ${{ (github.event_name == 'push' || github.event_name == 'pull_request') && !startsWith(github.ref, 'refs/tags/') && steps.check_iteration.outputs.iteration != '0' }}
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.
# Run ONLY when code is pushed/merged to master AND iteration != 0
# UPDATED: Added requirement for step 4b (publish_dev) to finish successfully.
- name: Publish Release
if: ${{ startsWith(github.ref, 'refs/tags/') }}
id: publish_release
if: ${{ steps.publish_dev.outcome == 'success' && github.event_name == 'push' && github.ref == 'refs/heads/master' && steps.check_iteration.outputs.iteration != '0' }}
run: ./gradlew clean build publish
env:
# We pass the tag name (e.g., v2026.0.0) to Gradle
RELEASE_VERSION: ${{ github.ref_name }}
# We pass the branch name (master) to Gradle
RELEASE_VERSION: ${{ steps.check_iteration.outputs.version }}
USER_GITHUB_NAME: ${{ github.actor }}
USER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# 4d. Auto Create Tag
# Automatically creates a git tag after successful 4c publish.
- name: Create Git Tag
if: ${{ steps.publish_release.outcome == 'success' }}
run: |
TAG_NAME="v${{ steps.check_iteration.outputs.version }}"
git tag $TAG_NAME
git push origin $TAG_NAME
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload Build Artifacts
uses: actions/upload-artifact@v4
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build_monthly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ jobs:
# 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
# 2. Reset Iteration to 0 (So next dev build starts at 0)
sed -i "s/^project-iteration=.*/project-iteration=0/" gradle.properties

# Verify
grep "project-version" gradle.properties
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ git-org-repository=mcextension

# --- Artifact Identity ---
project-version=2026.0.2
project-iteration=1
project-iteration=2
project-group=io.github.mcengine
project-artifact-id=mcextension
project-artifact-name=MCExtension
project-artifact-description=This project is a library designed to allow Minecraft plugins to load their own extensions.
project-artifact-url=https://mcengine.github.io/mcextension-website

Loading