Compare commits

..
2 Commits
Author SHA1 Message Date
layue13 a4e6ab3673 ci: bump setup-gradle to v6 and cache apt xvfb debs
Mirror Repository / Mirror to CNB (push) Skipped
Mirror Repository / Mirror to Gitee (push) Skipped
Java CI / build (pull_request) In progress
Nest actions/gradle-actions@v5 rejects cache-provider; v6 supports it
(and defaults to enhanced — keep Gitea on external). Cache ~/apt-cache
so xvfb debs can skip apt-get update when Actions cache is available.
2026-11-09 18:27:47 +00:00
layue13 096146449d ci: align Gradle/JDK caching with TDLM org workflows
Mirror Repository / Mirror to CNB (push) Skipped
Mirror Repository / Mirror to Gitee (push) Skipped
Java CI / build (pull_request) Canceled after 1m55s
Match ForestryMC/IC2 setup-build: cache-jdk, and use setup-gradle
cache-provider basic on GitHub / external on Gitea (avoids ECONNREFUSED
to GitHub cache). Cache ~/.gradle caches+wrapper via actions/cache.
2026-11-09 17:31:17 +00:00
+42 -11
View File
@@ -21,37 +21,63 @@ jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 90
steps:
- uses: actions/checkout@v6
# Same pattern as TDLM ForestryMC/IndustrialCraft2 setup-build: cache the JDK toolchain.
- name: Set up JDK 17
uses: actions/setup-java@v6
with:
distribution: 'liberica'
java-version: '17'
java-package: 'jdk+fx'
cache-jdk: true
# Nest mirrors github.com/gradle/actions as actions/gradle-actions (also as gradle/actions).
# v5 rejects cache-provider; v6 supports it. Default on v6 is "enhanced" (commercial) —
# on Gitea use external and cache Gradle home with actions/cache below (org IC2/Forestry pattern).
- name: Setup Gradle
# Nest hosts this under actions/gradle-actions (mirror of github.com/gradle/actions).
# uses: gradle/actions/... makes act clone git.nest…/gradle/actions which is not seeded.
uses: actions/gradle-actions/setup-gradle@v5
uses: actions/gradle-actions/setup-gradle@v6
with:
cache-cleanup: never
# Only main writes the dependency cache; pull requests read it.
cache-read-only: ${{ github.ref != 'refs/heads/main' }}
# The repository's wrapper downloads Gradle itself, so cache that download too.
- name: Cache Gradle distribution
cache-provider: ${{ github.server_url == 'https://github.com' && 'basic' || 'external' }}
# Cache wrapper + dependency/build caches (covers what setup-gradle skips under external).
- name: Cache Gradle home
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
.gradle/wrapper-neo
key: gradle-dist-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties', 'gradle/wrapper/GradleWrapperNeo.java') }}
key: gradle-home-${{ runner.os }}-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties', 'gradle/wrapper/GradleWrapperNeo.java', '**/libs.versions.toml', '**/*.gradle.kts', '**/*.gradle') }}
restore-keys: |
gradle-home-${{ runner.os }}-
# xvfb apt debs — avoids apt-get update+download on every cold container when Actions cache works.
- name: Cache apt packages
uses: actions/cache@v4
with:
path: ~/apt-cache
key: apt-xvfb-${{ runner.os }}-${{ runner.arch }}
- name: Install Xvfb
run: |
# Installing is the slowest setup step, so skip it when the runner already has xvfb, and
# only refresh the package index when a plain install fails.
command -v xvfb-run >/dev/null || sudo apt-get install -y --no-install-recommends xvfb \
if command -v xvfb-run >/dev/null; then
exit 0
fi
sudo mkdir -p /var/cache/apt/archives/partial
if [ -d "${HOME}/apt-cache" ] && [ -n "$(ls -A "${HOME}/apt-cache" 2>/dev/null)" ]; then
sudo cp -a "${HOME}/apt-cache/." /var/cache/apt/archives/
fi
# Prefer offline/cached debs first; only refresh the index when that fails.
sudo apt-get install -y --no-install-recommends xvfb \
|| { sudo apt-get update && sudo apt-get install -y --no-install-recommends xvfb; }
mkdir -p "${HOME}/apt-cache"
cp -a /var/cache/apt/archives/*.deb "${HOME}/apt-cache/" 2>/dev/null || true
# One Gradle run builds, tests and runs the code and translation checks, so the
# project is configured and compiled once instead of in two workflows.
- name: Build and check with Gradle
@@ -60,26 +86,31 @@ jobs:
JAVA_TOOL_OPTIONS: -Djava.awt.headless=true
MICROSOFT_AUTH_ID: ${{ secrets.MICROSOFT_AUTH_ID }}
CURSEFORGE_API_KEY: ${{ secrets.CURSEFORGE_API_KEY }}
- name: Get short SHA
run: echo "SHORT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV
- name: Upload JAR
uses: actions/upload-artifact@v7
with:
name: HMCL-${{ env.SHORT_SHA }}-jar
path: HMCL/build/libs/HMCL-*.jar
archive: false
- name: Upload EXE
uses: actions/upload-artifact@v7
with:
name: HMCL-${{ env.SHORT_SHA }}-exe
path: HMCL/build/libs/HMCL-*.exe
archive: false
- name: Upload SH
uses: actions/upload-artifact@v7
with:
name: HMCL-${{ env.SHORT_SHA }}-sh
path: HMCL/build/libs/HMCL-*.sh
archive: false
- name: Upload DEB
uses: actions/upload-artifact@v7
with: