Add CI workflows, dependabot and env script

Introduce CI infrastructure: add Dependabot config to update GitHub Actions and Gradle dependencies weekly; add build-pr workflow to run PR builds, create the paperclip JAR, and upload artifacts; add full Camellia CI workflow to build, set environment, upload artifacts, optionally publish to Maven and create GitHub releases (with release notes and prerelease handling); add publish-api workflow to publish the API artifact. Also add scripts/SetENV.sh which reads gradle.properties, computes build/release flags, renames the paperclip jar and exports environment variables for the workflows. These changes set up automated builds, dependency maintenance, publishing and release automation for the project.
This commit is contained in:
2026-07-09 18:22:49 +08:00
parent 0be772ce0e
commit 3082c3f1d1
5 changed files with 411 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
version: 2
updates:
# Maintain dependencies for GitHub Actions workflows
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
commit-message:
prefix: "ci"
labels:
- "dependencies"
- "github-actions"
# Maintain dependencies for Gradle (build.gradle.kts, libs.versions.toml)
- package-ecosystem: "gradle"
directory: "/"
schedule:
interval: "weekly"
commit-message:
prefix: "build"
labels:
- "dependencies"
- "gradle"
+57
View File
@@ -0,0 +1,57 @@
name: Build Pull Request
on:
pull_request:
branches:
- "**"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Git Repository
uses: actions/checkout@v7
- name: Set Up JDK
uses: actions/setup-java@v5
with:
distribution: zulu
java-version: 25
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v6
with:
add-job-summary: never
cache-read-only: true
- name: Configure Git User Details
run: |
git config --global user.email "ci-test@monnairealms.moe"
git config --global user.name "Camellia Test CI"
- name: Grant Execute Permission
run: chmod +x gradlew
- name: Apply Patches
run: ./gradlew applyAllPatches --stacktrace
- name: Build
run: ./gradlew createPaperclipJar --stacktrace
- name: Rename Artifact
run: |
prop() {
awk -F= -v key="$1" '$1 == key { val = $2; sub(/[[:space:]]*#.*$/, "", val); gsub(/^[[:space:]]+|[[:space:]]+$/, "", val); print val }' gradle.properties
}
jarName="camellia-$(prop mcVersion).jar"
mv camellia-server/build/libs/camellia-paperclip-"$(prop version)"*.jar "$jarName" 2>/dev/null || \
mv camellia-server/build/libs/*-paperclip-*.jar "$jarName" 2>/dev/null || true
echo "jar=$jarName" >> "$GITHUB_ENV"
- name: Upload Artifact
uses: actions/upload-artifact@v7
with:
name: ${{ env.jar || 'camellia-pr' }}
path: ${{ env.jar || 'camellia-server/build/libs/*-paperclip-*.jar' }}
if-no-files-found: warn
+219
View File
@@ -0,0 +1,219 @@
name: Camellia CI
on:
push:
branches:
- "**"
workflow_dispatch:
inputs:
force-release:
description: "Force disable release if you enter false, force release if you enter true, default release if not released else skip release"
required: false
default: ""
force-push:
description: "Force disable push to repo if you enter false, force push to repo if you enter true, default push if not released else skip push repo"
required: false
default: ""
comments:
description: "Add comments to release"
required: false
default: ""
permissions: write-all
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Git Repository
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Get Branch Build Number
run: |
BUILD_NUMBER=$(git rev-list --count HEAD)
echo "BUILD_NUMBER=$BUILD_NUMBER" >> $GITHUB_ENV
echo "Branch: $GITHUB_REF_NAME — Build #$BUILD_NUMBER"
- name: Validate Gradle Wrapper
uses: gradle/actions/wrapper-validation@v6
- name: Set Up JDK
uses: actions/setup-java@v5
with:
distribution: zulu
java-version: 25
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v6
with:
add-job-summary: never
cache-read-only: false
- name: Configure Git User Details
run: git config --global user.email "ci@monnairealms.moe" && git config --global user.name "Camellia CI"
- name: Grant Execute Permission
run: chmod +x gradlew
- name: Apply Patches
run: ./gradlew applyAllPatches --stacktrace
- name: Build
run: ./gradlew createPaperclipJar --stacktrace
- name: Set Environment
run: sh scripts/SetENV.sh
- name: Get Build Info
id: build-info
run: |
BUILD_DATE=$(date -u +'%Y-%m-%d %H:%M:%S UTC')
echo "build_date=$BUILD_DATE" >> $GITHUB_ENV
- name: Upload Artifact
uses: actions/upload-artifact@v7
with:
name: ${{ env.project_id_b || 'Camellia' }} CI Artifacts
path: ${{ env.jar_dir }}
if-no-files-found: warn
# ── Publish To Repo ──
- name: "[Publish] Publish To Repo"
if: |
( env.flag_push_repo == 'true'
&& !( inputs.force-push == 'false' )
) || inputs.force-push == 'true'
continue-on-error: true
run: ./gradlew generateDevelopmentBundle publish -PpublishDevBundle=true
env:
MAVEN_REPO_PASSWORD: ${{ secrets.MAVEN_REPO_PASSWORD }}
MAVEN_REPO_USERNAME: ${{ secrets.MAVEN_REPO_USERNAME }}
# ── Release ──
- name: Check If Release Exists
if: env.flag_release == 'true'
run: |
git fetch --tags
if [ -n "$(git tag -l "${{ env.tag }}")" ]; then
echo "Release already exists"
release_exists=true
else
echo "Release does not exist"
release_exists=false
fi
if [ "$release_exists" == "true" ]; then
counter=1
while [ -n "$(git tag -l "${{ env.tag }}-${counter}")" ]; do
counter=$((counter + 1))
done
echo "tag=${{ env.tag }}-${counter}" >> $GITHUB_ENV
echo "release_count= - ${counter}" >> $GITHUB_ENV
release_exists=false
fi
echo "release_exists=${release_exists}" >> $GITHUB_ENV
- name: Check If Branch In Expectations
if: env.flag_release == 'true'
run: |
if [[ "$GITHUB_REF_NAME" == ver/* ]] || [[ "$GITHUB_REF_NAME" == exp/* ]] || [[ "$GITHUB_REF_NAME" == dev/* ]]; then
echo "Branch is in expected prefixes"
echo "unexpect=false" >> $GITHUB_ENV
else
echo "Branch is NOT in expected prefixes"
echo "unexpect=true" >> $GITHUB_ENV
fi
- name: Create Release - Pre Process
if: |
( !( env.unexpect == 'true' )
&& env.flag_release == 'true'
&& env.release_exists != 'true'
&& !(inputs.force-release == 'false')
) || inputs.force-release == 'true'
run: |
if [ "${{ inputs.comments }}" == "" ]; then
echo "No comments provided"
echo "flag_comment=false" >> $GITHUB_ENV
else
echo "Comments provided: ${{ inputs.comments }}"
echo "flag_comment=true" >> $GITHUB_ENV
fi
- name: Create Release - No Comment
if: env.flag_comment == 'false'
uses: ncipollo/release-action@v1
with:
tag: ${{ env.tag }}
name: ${{ env.project_id_b }} ${{ env.mcversion }} - ${{ env.commit_id }}${{ env.release_count }}
body: |
# 🌸 Camellia `${{ env.mcversion }}`
[![Download](https://img.shields.io/github/downloads/${{ github.repository }}/${{ env.tag }}/total?color=f472b6&style=for-the-badge&logo=github)](https://github.com/${{ github.repository }}/releases/download/${{ env.tag }}/${{ env.jar }})
### 📝 Build Information
* **Build:** `#${{ env.BUILD_NUMBER }}`
* **Date:** `${{ env.build_date }}`
* **Branch:** [`${{ github.ref_name }}`](https://github.com/${{ github.repository }}/tree/${{ github.ref_name }})
* **Commit:** [`${{ env.commit_id }}`](https://github.com/${{ github.repository }}/commit/${{ github.sha }})
### ✨ Latest Changes
```text
${{ env.commit_msg }}
```
---
<div align="center">
<sub>Automated release by <a href="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}">Camellia CI</a></sub>
</div>
artifacts: ${{ env.jar_dir }}
generateReleaseNotes: true
prerelease: ${{ env.pre }}
makeLatest: ${{ env.make_latest }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release - With Comment
if: env.flag_comment == 'true'
uses: ncipollo/release-action@v1
with:
tag: ${{ env.tag }}
name: ${{ env.project_id_b }} ${{ env.mcversion }} - ${{ env.commit_id }}${{ env.release_count }}
body: |
# 🌸 Camellia `${{ env.mcversion }}`
[![Download](https://img.shields.io/github/downloads/${{ github.repository }}/${{ env.tag }}/total?color=f472b6&style=for-the-badge&logo=github)](https://github.com/${{ github.repository }}/releases/download/${{ env.tag }}/${{ env.jar }})
> **💡 Note:** ${{ inputs.comments }}
### 📝 Build Information
* **Build:** `#${{ env.BUILD_NUMBER }}`
* **Date:** `${{ env.build_date }}`
* **Branch:** [`${{ github.ref_name }}`](https://github.com/${{ github.repository }}/tree/${{ github.ref_name }})
* **Commit:** [`${{ env.commit_id }}`](https://github.com/${{ github.repository }}/commit/${{ github.sha }})
### ✨ Latest Changes
```text
${{ env.commit_msg }}
```
---
<div align="center">
<sub>Automated release by <a href="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}">Camellia CI</a></sub>
</div>
artifacts: ${{ env.jar_dir }}
generateReleaseNotes: true
prerelease: ${{ env.pre }}
makeLatest: ${{ env.make_latest }}
token: ${{ secrets.GITHUB_TOKEN }}
event_file:
name: "Event File"
if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }}
runs-on: ubuntu-latest
steps:
- name: Upload
uses: actions/upload-artifact@v7
with:
name: Event File
path: ${{ github.event_path }}
+50
View File
@@ -0,0 +1,50 @@
name: Publish API
on:
push:
branches:
- "**"
workflow_dispatch:
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout Git Repository
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Get Branch Build Number
run: |
BUILD_NUMBER=$(git rev-list --count HEAD)
echo "BUILD_NUMBER=$BUILD_NUMBER" >> $GITHUB_ENV
- name: Set Up JDK
uses: actions/setup-java@v5
with:
distribution: zulu
java-version: 25
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v6
- name: Configure Git User Details
run: |
git config --global user.email "ci@monnairealms.moe"
git config --global user.name "Camellia CI"
- name: Grant Execute Permission
run: chmod +x gradlew
- name: Apply Patches
run: ./gradlew applyAllPatches --stacktrace
- name: Publish API to Maven
continue-on-error: true
run: |
./gradlew :camellia-api:publish
./gradlew generateDevelopmentBundle publishDevBundlePublicationToBacteriawaRepository -PpublishDevBundle=true
env:
MAVEN_REPO_PASSWORD: ${{ secrets.MAVEN_REPO_PASSWORD }}
MAVEN_REPO_USERNAME: ${{ secrets.MAVEN_REPO_USERNAME }}