Skip to content

fix: Add cache configuration for Gradle in release workflow #8

fix: Add cache configuration for Gradle in release workflow

fix: Add cache configuration for Gradle in release workflow #8

Workflow file for this run

name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
build-and-release:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up JDK 8
uses: actions/setup-java@v5
with:
java-version: "8"
distribution: "temurin"
cache: 'gradle'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Get version from build.gradle
id: version
run: |
VERSION=$(grep "^version = " build.gradle | sed "s/version = '\(.*\)'/\1/" | sed 's/version = "\(.*\)"/\1/')
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
echo "Detected version: ${VERSION}"
- name: Get tag name
id: tag_name
run: echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Run tests
run: |
echo "Running tests..."
./gradlew test --no-daemon
env:
JAVA_HOME: ${{ env.JAVA_HOME_8_X64 }}
- name: Build JARs (standard + shadow)
run: |
echo "Building JAR artifacts..."
./gradlew clean build shadowJar -x test --no-daemon
env:
JAVA_HOME: ${{ env.JAVA_HOME_8_X64 }}
- name: Prepare release artifacts
run: |
echo "Preparing release artifacts..."
mkdir -p release-artifacts
# List all JARs
echo "Built JARs:"
ls -lh build/libs/
# Copy all JAR files to release directory
cp build/libs/*.jar release-artifacts/ || true
echo "Release artifacts:"
ls -lh release-artifacts/
- name: Generate release notes
id: release_notes
run: |
cat << EOF > release_notes.md
## Release ${{ steps.tag_name.outputs.TAG }}
### Version
${{ steps.version.outputs.VERSION }}
### Artifacts
- **cubis-langx-java-${{ steps.version.outputs.VERSION }}.jar** - Standard JAR (requires dependencies)
- **cubis-langx-java-${{ steps.version.outputs.VERSION }}-all.jar** - Fat JAR with all dependencies (recommended)
### Features
- ✅ Multi-locale translation support
- ✅ Load translations from local JSON files and remote CDN
- ✅ Smart caching with configurable duration
- ✅ Pluralization and parameter substitution
- ✅ Context-aware and keyword-based formatting
- ✅ Event listeners for translation loaded, errors, and missing keys
- ✅ Combined locales - display multiple languages together
- ✅ Async preload locales - non-blocking background loading
- ✅ Resource cleanup - AutoCloseable with proper shutdown
- ✅ Missing keys extraction - identify untranslated keys
- ✅ Write missing keys to file - async batch writing to locale files
- ✅ Comprehensive test suite (170 tests)
### Requirements
- Java 8 or higher
- Gradle 8.x or Maven 3.x
### Installation
#### Using the Fat JAR (Recommended)
Download \`cubis-langx-java-${{ steps.version.outputs.VERSION }}-all.jar\` and add it to your project classpath.
#### Using Standard JAR
Download \`cubis-langx-java-${{ steps.version.outputs.VERSION }}.jar\` and include required dependencies:
- Gson 2.10.1
- OkHttp 4.12.0
- Mustache 0.9.11
- SLF4J 2.0.9
### Quick Start
\`\`\`java
// Try-with-resources for automatic cleanup
try (CubisLang lang = new CubisLang(
CubisLangOptions.builder()
.setDefaultLocale("en")
.setResourcePath("./resources/lang/")
.build()
)) {
String greeting = lang.get("greeting");
System.out.println(greeting);
}
\`\`\`
### Documentation
- [README](https://github.com/CUBETIQ/cubis-langx-java#readme)
- [Usage Guide](https://github.com/CUBETIQ/cubis-langx-java/blob/main/docs/USAGE_GUIDE.md)
- [Quick Reference](https://github.com/CUBETIQ/cubis-langx-java/blob/main/docs/QUICK_REFERENCE.md)
### Changes
See the [commit history](https://github.com/CUBETIQ/cubis-langx-java/commits/${{ steps.tag_name.outputs.TAG }}) for detailed changes.
EOF
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: release-artifacts/*.jar
body_path: release_notes.md
draft: false
prerelease: false
tag_name: ${{ steps.tag_name.outputs.TAG }}
name: Release ${{ steps.tag_name.outputs.TAG }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}