9
0
mirror of https://github.com/BX-Team/DivineMC.git synced 2025-12-19 14:59:25 +00:00
Files
DivineMC/.github/workflows/build-12110.yml
2025-12-14 15:31:20 +03:00

113 lines
3.6 KiB
YAML

name: Build DivineMC 1.21.10
on:
push:
branches:
- "ver/1.21.10"
workflow_dispatch:
jobs:
build:
runs-on: blacksmith-8vcpu-ubuntu-2204
if: "!contains(github.event.commits[0].message, '[ci-skip]')"
env:
BUILD_NUMBER: ${{ github.run_number }}
API_KEY: ${{ secrets.API_KEY }}
outputs:
build_number: ${{ env.BUILD_NUMBER }}
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Setup Gradle Cache
uses: actions/cache@v4
with:
path: |
~/.gradle/caches/modules-2
~/.gradle/caches/jars-*
~/.gradle/caches/transforms-*
~/.gradle/wrapper
~/.gradle/build-cache-*
~/.gradle/configuration-cache-*
.gradle/patchCache
.gradle/patched
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', 'patches/**/*.patch') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Gradle Cache Cleanup
run: |
mkdir -p ~/.gradle/caches/modules-2
[ -f ~/.gradle/caches/modules-2/modules-2.lock ] && rm -f ~/.gradle/caches/modules-2/modules-2.lock
find ~/.gradle/caches -name "*.lock" -type f -delete || echo "No lock files found"
- name: Setup JDK 21
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: 21
- name: Configure Git and Gradle
run: |
git config --global user.email "no-reply@github.com"
git config --global user.name "Github Actions"
git config --global core.preloadindex true
git config --global core.fscache true
git config --global gc.auto 256
chmod +x gradlew
chmod +x scripts/uploadBuild.sh
- name: Apply Patches
run: |
PARALLELISM=$(($(nproc) * 2))
./gradlew applyAllPatches --stacktrace --parallel --max-workers=$PARALLELISM --build-cache --no-daemon
- name: Build Paperclip Jar
run: ./gradlew createMojmapPaperclipJar --stacktrace --parallel --no-daemon
- name: Upload Build to API
run: bash scripts/uploadBuild.sh
env:
BUILD_NUMBER: ${{ env.BUILD_NUMBER }}
API_KEY: ${{ secrets.API_KEY }}
- name: Get MC Version
id: mcversion
run: |
mcversion=$(grep "mcVersion" gradle.properties | cut -d'=' -f2 | sed 's/\r//')
echo "version=$mcversion" >> $GITHUB_OUTPUT
- name: Update Version Tag
uses: actions/github-script@v8
with:
script: |
const tag = `ver-${{ steps.mcversion.outputs.version }}`;
const ref = `refs/tags/${tag}`;
console.log(`Updating tag: ${tag}`);
try {
await github.rest.git.updateRef({
owner: context.repo.owner,
repo: context. repo.repo,
ref: `tags/${tag}`,
sha: context.sha,
force: true
});
console.log(`✅ Tag ${tag} updated successfully`);
} catch (error) {
if (error.status === 404) {
await github.rest.git. createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: ref,
sha: context. sha
});
console.log(`✅ Tag ${tag} created successfully`);
} else {
throw error;
}
}