CI: refine build numbering, release/publish flow

Compute BUILD_NUMBER relative to the last gradle.properties mcVersion change (instead of total commits), add dependabot groups for actions and gradle deps, and simplify release notes formatting (disable generated notes and inline metadata). Remove the Publish-To-Repo step from the main build workflow and add a force-push input/conditional to publish-api workflow. Invoke scripts/SetENV.sh in publish-api and update SetENV.sh to produce jar names that omit run attempt suffix for first run. These changes tighten publishing controls and make build numbering reflect per-version increments.
This commit is contained in:
2026-07-09 20:18:43 +08:00
parent a6b1cf1e28
commit 5ce33501cd
4 changed files with 52 additions and 33 deletions
+8
View File
@@ -5,6 +5,10 @@ updates:
directory: "/" directory: "/"
schedule: schedule:
interval: "weekly" interval: "weekly"
groups:
actions:
patterns:
- "*"
commit-message: commit-message:
prefix: "ci" prefix: "ci"
labels: labels:
@@ -16,6 +20,10 @@ updates:
directory: "/" directory: "/"
schedule: schedule:
interval: "weekly" interval: "weekly"
groups:
gradle-deps:
patterns:
- "*"
commit-message: commit-message:
prefix: "build" prefix: "build"
labels: labels:
+19 -28
View File
@@ -10,10 +10,6 @@ on:
description: "Force disable release if you enter false, force release if you enter true, default release if not released else skip 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 required: false
default: "" 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: comments:
description: "Add comments to release" description: "Add comments to release"
required: false required: false
@@ -34,7 +30,14 @@ jobs:
- name: Get Branch Build Number - name: Get Branch Build Number
run: | run: |
MC_VERSION=$(grep "^[[:space:]]*mcVersion" gradle.properties | cut -d'=' -f2 | sed 's/^[[:space:]]*//; s/\r//')
BASE_COMMIT=$(git log -S "mcVersion=$MC_VERSION" -1 --format="%H" -- gradle.properties)
if [ -z "$BASE_COMMIT" ]; then
BUILD_NUMBER=$(git rev-list --count HEAD) BUILD_NUMBER=$(git rev-list --count HEAD)
else
BUILD_NUMBER=$(git rev-list --count $BASE_COMMIT..HEAD)
BUILD_NUMBER=$((BUILD_NUMBER + 1))
fi
echo "BUILD_NUMBER=$BUILD_NUMBER" >> $GITHUB_ENV echo "BUILD_NUMBER=$BUILD_NUMBER" >> $GITHUB_ENV
echo "Branch: $GITHUB_REF_NAME — Build #$BUILD_NUMBER" echo "Branch: $GITHUB_REF_NAME — Build #$BUILD_NUMBER"
@@ -138,27 +141,21 @@ jobs:
tag: ${{ env.tag }} tag: ${{ env.tag }}
name: ${{ env.project_id_b }} ${{ env.mcversion }} - ${{ env.commit_id }}${{ env.release_count }} name: ${{ env.project_id_b }} ${{ env.mcversion }} - ${{ env.commit_id }}${{ env.release_count }}
body: | 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 }}) [![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 Information
* **Build:** `#${{ env.BUILD_NUMBER }}` * **Build:** #${{ env.BUILD_NUMBER }}
* **Date:** `${{ env.build_date }}` * **Date:** ${{ env.build_date }}
* **Branch:** [`${{ github.ref_name }}`](https://github.com/${{ github.repository }}/tree/${{ github.ref_name }}) * **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 }}) * **Commit:** [${{ env.commit_id }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }})
### ✨ Latest Changes ### ✨ Latest Changes
```text
${{ env.commit_msg }} ${{ env.commit_msg }}
```
--- ---
<div align="center"> > 🤖 Automated release by [Camellia CI](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
<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 }} artifacts: ${{ env.jar_dir }}
generateReleaseNotes: true generateReleaseNotes: false
prerelease: ${{ env.pre }} prerelease: ${{ env.pre }}
makeLatest: ${{ env.make_latest }} makeLatest: ${{ env.make_latest }}
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
@@ -170,29 +167,23 @@ jobs:
tag: ${{ env.tag }} tag: ${{ env.tag }}
name: ${{ env.project_id_b }} ${{ env.mcversion }} - ${{ env.commit_id }}${{ env.release_count }} name: ${{ env.project_id_b }} ${{ env.mcversion }} - ${{ env.commit_id }}${{ env.release_count }}
body: | 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 }}) [![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 }} > **💡 Note:** ${{ inputs.comments }}
### 📝 Build Information ### 📝 Build Information
* **Build:** `#${{ env.BUILD_NUMBER }}` * **Build:** #${{ env.BUILD_NUMBER }}
* **Date:** `${{ env.build_date }}` * **Date:** ${{ env.build_date }}
* **Branch:** [`${{ github.ref_name }}`](https://github.com/${{ github.repository }}/tree/${{ github.ref_name }}) * **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 }}) * **Commit:** [${{ env.commit_id }}](https://github.com/${{ github.repository }}/commit/${{ github.sha }})
### ✨ Latest Changes ### ✨ Latest Changes
```text
${{ env.commit_msg }} ${{ env.commit_msg }}
```
--- ---
<div align="center"> > 🤖 Automated release by [Camellia CI](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
<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 }} artifacts: ${{ env.jar_dir }}
generateReleaseNotes: true generateReleaseNotes: false
prerelease: ${{ env.pre }} prerelease: ${{ env.pre }}
makeLatest: ${{ env.make_latest }} makeLatest: ${{ env.make_latest }}
token: ${{ secrets.GITHUB_TOKEN }} token: ${{ secrets.GITHUB_TOKEN }}
+17 -1
View File
@@ -5,6 +5,11 @@ on:
branches: branches:
- "**" - "**"
workflow_dispatch: workflow_dispatch:
inputs:
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: ""
jobs: jobs:
publish: publish:
@@ -19,7 +24,14 @@ jobs:
- name: Get Branch Build Number - name: Get Branch Build Number
run: | run: |
MC_VERSION=$(grep "^[[:space:]]*mcVersion" gradle.properties | cut -d'=' -f2 | sed 's/^[[:space:]]*//; s/\r//')
BASE_COMMIT=$(git log -S "mcVersion=$MC_VERSION" -1 --format="%H" -- gradle.properties)
if [ -z "$BASE_COMMIT" ]; then
BUILD_NUMBER=$(git rev-list --count HEAD) BUILD_NUMBER=$(git rev-list --count HEAD)
else
BUILD_NUMBER=$(git rev-list --count $BASE_COMMIT..HEAD)
BUILD_NUMBER=$((BUILD_NUMBER + 1))
fi
echo "BUILD_NUMBER=$BUILD_NUMBER" >> $GITHUB_ENV echo "BUILD_NUMBER=$BUILD_NUMBER" >> $GITHUB_ENV
- name: Set Up JDK - name: Set Up JDK
@@ -42,8 +54,12 @@ jobs:
- name: Apply Patches - name: Apply Patches
run: ./gradlew applyAllPatches --stacktrace run: ./gradlew applyAllPatches --stacktrace
- name: Set Environment
run: sh scripts/SetENV.sh
- name: Publish API to Maven - name: Publish API to Maven
continue-on-error: true if: |
( env.flag_push_repo == 'true' && !(inputs.force-push == 'false') ) || inputs.force-push == 'true'
run: | run: |
./gradlew :camellia-api:publish ./gradlew :camellia-api:publish
./gradlew generateDevelopmentBundle publishDevBundlePublicationToBacteriawaRepository -PpublishDevBundle=true ./gradlew generateDevelopmentBundle publishDevBundlePublicationToBacteriawaRepository -PpublishDevBundle=true
+5 -1
View File
@@ -15,7 +15,11 @@ release=$(prop release)
pushRepo=$(prop pushRepo) pushRepo=$(prop pushRepo)
release_tag="$mcversion-$commitid" release_tag="$mcversion-$commitid"
run_attempt="${GITHUB_RUN_ATTEMPT:-1}" run_attempt="${GITHUB_RUN_ATTEMPT:-1}"
jarName="$project_id-$mcversion-$BUILD_NUMBER-$run_attempt.jar" if [ "$run_attempt" = "1" ]; then
jarName="$project_id-$mcversion-$BUILD_NUMBER.jar"
else
jarName="$project_id-$mcversion-$BUILD_NUMBER-$run_attempt.jar"
fi
jarName_dir="camellia-server/build/libs/$jarName" jarName_dir="camellia-server/build/libs/$jarName"
flag_push_repo=false flag_push_repo=false