Skip to content

Commit

Permalink
Merge branch '1.21.3' into 1.21.3-neoforge
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander01998 committed Dec 18, 2024
2 parents d95cde5 + 40d6999 commit 5ee83fe
Show file tree
Hide file tree
Showing 15 changed files with 973 additions and 137 deletions.
17 changes: 17 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: "gradle"
directory: "/"
schedule:
interval: "daily"

- package-ecosystem: "github-actions"
# Directory should be `/` instead of `/.github/workflows` according to the docs.
directory: "/"
schedule:
interval: "daily"
113 changes: 113 additions & 0 deletions .github/workflows/auto_snapshot_update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Experimental workflow to automate updating to a new Minecraft snapshot.
name: Auto Snapshot Update

on:
workflow_dispatch:
inputs:
mc_version:
description: "Minecraft version to update to"
required: true
yarn_mappings:
description: "Yarn mappings version"
required: true
fabric_loader:
description: "Fabric Loader version"
required: true
fapi_version:
description: "Fabric API version"
required: true
cf_game_version:
description: "CurseForge GameVersion"
required: true

permissions:
# To push changes to the new snapshot branch.
contents: write
# To trigger the CI workflow.
actions: write

jobs:
update:
runs-on: ubuntu-latest
steps:

- name: Checkout repository
uses: actions/checkout@v4
with:
# Include all branches in case the new snapshot branch already exists.
fetch-depth: 0

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Set up Java 21
uses: actions/setup-java@v4
with:
java-version: "21"
distribution: "microsoft"

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
build-scan-publish: true
build-scan-terms-of-use-url: "https://gradle.com/help/legal-terms-of-use"
build-scan-terms-of-use-agree: "yes"

- name: Create and checkout new snapshot branch
run: |
BRANCH_NAME="${{ github.event.inputs.mc_version }}"
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [ "$CURRENT_BRANCH" = "$BRANCH_NAME" ]; then
echo "Already on branch $BRANCH_NAME. Skipping branch creation."
elif git show-ref --quiet refs/heads/$BRANCH_NAME; then
echo "Branch $BRANCH_NAME already exists but is not currently checked out. Failing the workflow."
exit 1
else
git checkout -b $BRANCH_NAME
echo "Created and checked out new branch: $BRANCH_NAME"
fi
shell: bash

- name: Run migrateMappings task
run: |
./gradlew migrateMappings --mappings ${{ github.event.inputs.yarn_mappings }}
shell: bash

- name: Replace src/main/java with remapped files
run: |
rm -rf ./src/main/java
mv ./remappedSrc ./src/main/java
shell: bash

- name: Update version constants
run: |
python scripts/update_version_constants.py "${{ github.event.inputs.mc_version }}" "${{ github.event.inputs.yarn_mappings }}" "${{ github.event.inputs.fabric_loader }}" "${{ github.event.inputs.fapi_version }}" "${{ github.event.inputs.cf_game_version }}"
shell: bash

# To fix any style issues that the migration scripts might cause
- name: Run spotlessApply task
run: ./gradlew spotlessApply

- name: Commit and push changes
run: |
git config --global user.name "Wurst-Bot"
git config --global user.email "[email protected]"
git add .
git commit -m "[Wurst-Bot] Update to ${{ github.event.inputs.mc_version }}"
git push --set-upstream origin ${{ github.event.inputs.mc_version }}
shell: bash

# For some reason the commit above doesn't automatically trigger the CI
# workflow, so we need to explicitly start it here.
- name: Trigger CI on the new branch
env:
GH_TOKEN: ${{ github.token }}
run: |
gh workflow run gradle.yml --ref ${{ github.event.inputs.mc_version }}
shell: bash
55 changes: 52 additions & 3 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Java CI with Gradle

on:
push:
branches:
- "**"
branches-ignore:
- "dependabot/**"
tags-ignore:
- "**"
paths:
Expand Down Expand Up @@ -57,7 +57,7 @@ jobs:
run: ./gradlew spotlessJsonCheck || (echo "::error::JSON validation failed! Run './gradlew spotlessApply' to fix style issues, or check the full error message for syntax errors." && exit 1)

- name: Validate Java code style
run: ./gradlew spotlessCheck || (echo "::error::Java code style validation failed! To fix, run 'Clean Up' and then 'Format' in Eclipse, or './gradlew spotlessApply' in the terminal." && exit 1)
run: ./gradlew spotlessJavaCheck || (echo "::error::Java code style validation failed! To fix, run 'Clean Up' and then 'Format' in Eclipse, or './gradlew spotlessApply' in the terminal." && exit 1)

- name: Run unit tests
run: ./gradlew test --stacktrace --warning-mode=fail
Expand Down Expand Up @@ -92,3 +92,52 @@ jobs:
echo "- [$filename]($url)" >> $GITHUB_STEP_SUMMARY
done
echo "</details>" >> $GITHUB_STEP_SUMMARY
- name: Run the mod and take screenshots
uses: modmuss50/xvfb-action@c56c7da0c8fc9a7cb5df2e50dd2a43a80b64c5cb
with:
run: ./gradlew runEndToEndTest --stacktrace --warning-mode=fail

# Needed because the screenshot gallery won't be created on pull requests.
# Also useful if Imgur uploads fail.
- name: Upload Test Screenshots.zip artifact
uses: actions/upload-artifact@v4
if: always()
with:
name: Test Screenshots
path: runs/client/screenshots

- name: Create test screenshot gallery
if: ${{ env.IMGUR_CLIENT_ID && (success() || failure()) }}
shell: bash
run: |
echo "<details open>" >> $GITHUB_STEP_SUMMARY
echo "<summary>📸 Test Screenshots</summary>" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
for img in runs/client/screenshots/*.png; do
if [ -f "$img" ]; then
filename=$(basename "$img")
name_without_ext="${filename%.*}"
# Upload to Imgur
response=$(curl -s -X POST \
-H "Authorization: Client-ID $IMGUR_CLIENT_ID" \
-F "image=@$img" \
https://api.imgur.com/3/image)
# Extract the URL from the response
url=$(echo $response | grep -o '"link":"[^"]*"' | cut -d'"' -f4)
if [ ! -z "$url" ]; then
# Convert underscores to spaces and capitalize first letter of each word
title=$(echo "$name_without_ext" | tr '_' ' ' | awk '{for(i=1;i<=NF;i++)sub(/./,toupper(substr($i,1,1)),$i)}1')
echo "### $title" >> $GITHUB_STEP_SUMMARY
echo "![${name_without_ext}]($url)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
else
echo "Failed to upload $filename" >> $GITHUB_STEP_SUMMARY
fi
fi
done
echo "</details>" >> $GITHUB_STEP_SUMMARY
49 changes: 44 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
name: Publish Release
run-name: "Publish release from ${{ github.ref_name }} branch"

permissions:
# Needed to push the tag.
contents: write

on:
workflow_dispatch:
Expand Down Expand Up @@ -28,6 +33,11 @@ on:
required: true
type: boolean
default: true
update_website:
description: "Update wimods.net post (only works if there already is one and publish_curseforge is true)"
required: false
type: boolean
default: false

jobs:
publish:
Expand All @@ -37,9 +47,13 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }}
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}

steps:
- uses: actions/checkout@v4

- name: Checkout repository
uses: actions/checkout@v4
with:
# Include all tags in case the new tag already exists.
fetch-tags: true

- name: Set up Java 21
uses: actions/setup-java@v4
Expand All @@ -58,11 +72,11 @@ jobs:

- name: Create and push tag
run: |
MOD_VERSION=$(grep "mod_version" gradle.properties | cut -d'=' -f2 | tr -d ' ')
MOD_VERSION=$(grep "mod_version" gradle.properties | cut -d'=' -f2 | tr -d ' \r')
git config --global user.name "Wurst-Bot"
git config --global user.email "[email protected]"
git tag v$MOD_VERSION
git push origin v$MOD_VERSION
git tag "v$MOD_VERSION"
git push origin "v$MOD_VERSION"
- name: Close milestone
if: ${{ inputs.close_milestone }}
Expand All @@ -82,6 +96,31 @@ jobs:
if: ${{ inputs.publish_curseforge }}
run: ./gradlew publishCurseforge --stacktrace

- name: Get CurseForge file ID
id: cf_file_id
if: ${{ inputs.publish_curseforge }}
run: |
file_id=$(./gradlew getCurseforgeId | grep -o 'CURSEFORGE_FILE_ID=[0-9]*' | grep -o '[0-9]*')
echo "file_id=$file_id" >> "$GITHUB_OUTPUT"
echo "CurseForge file ID: `$file_id`" >> $GITHUB_STEP_SUMMARY
- name: Publish to Modrinth
if: ${{ inputs.publish_modrinth }}
run: ./gradlew publishModrinth --stacktrace

- name: Trigger website update
if: ${{ inputs.update_website && inputs.publish_curseforge }}
env:
GH_TOKEN: ${{ secrets.WIMODS_NET_PUBLISH_TOKEN }}
run: |
MOD_VERSION=$(grep "mod_version" gradle.properties | cut -d'=' -f2 | tr -d ' \r' | sed 's/-MC.*$//')
MC_VERSION=$(grep "minecraft_version" gradle.properties | cut -d'=' -f2 | tr -d ' \r')
FAPI_VERSION=$(grep "fabric_version" gradle.properties | cut -d'=' -f2 | tr -d ' \r')
gh workflow run add_mod_port.yml \
-R Wurst-Imperium/wimods.net \
-f mod="mo-glass" \
-f modloader="fabric" \
-f mod_version="$MOD_VERSION" \
-f mc_version="$MC_VERSION" \
-f fapi_version="$FAPI_VERSION" \
-f file_id="${{ steps.cf_file_id.outputs.file_id }}"
3 changes: 2 additions & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ jobs:
runs-on: ubuntu-latest
steps:

- uses: actions/stale@v9
- name: Run stale bot
uses: actions/stale@v9
with:
stale-issue-message: |
This issue has been open for a while with no recent activity. If this issue is still important to you, please add a comment within the next 7 days to keep it open. Otherwise, the issue will be automatically closed to free up time for other tasks.
Expand Down
Loading

0 comments on commit 5ee83fe

Please sign in to comment.