From 5ce33501cd1d969f80e054173323991af02cd34b Mon Sep 17 00:00:00 2001 From: Bacteriawa Date: Thu, 9 Jul 2026 20:17:09 +0800 Subject: [PATCH] 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. --- .github/dependabot.yml | 8 +++++ .github/workflows/build.yml | 51 +++++++++++++------------------ .github/workflows/publish-api.yml | 20 ++++++++++-- scripts/SetENV.sh | 6 +++- 4 files changed, 52 insertions(+), 33 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 3cf4205..76f3687 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,6 +5,10 @@ updates: directory: "/" schedule: interval: "weekly" + groups: + actions: + patterns: + - "*" commit-message: prefix: "ci" labels: @@ -16,6 +20,10 @@ updates: directory: "/" schedule: interval: "weekly" + groups: + gradle-deps: + patterns: + - "*" commit-message: prefix: "build" labels: diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e49600f..b63bed0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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" 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 @@ -34,7 +30,14 @@ jobs: - name: Get Branch Build Number run: | - BUILD_NUMBER=$(git rev-list --count HEAD) + 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) + else + BUILD_NUMBER=$(git rev-list --count $BASE_COMMIT..HEAD) + BUILD_NUMBER=$((BUILD_NUMBER + 1)) + fi echo "BUILD_NUMBER=$BUILD_NUMBER" >> $GITHUB_ENV echo "Branch: $GITHUB_REF_NAME — Build #$BUILD_NUMBER" @@ -138,27 +141,21 @@ jobs: 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 }}) + * **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 }} - ``` --- -
- Automated release by Camellia CI -
+ > 🤖 Automated release by [Camellia CI](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) artifacts: ${{ env.jar_dir }} - generateReleaseNotes: true + generateReleaseNotes: false prerelease: ${{ env.pre }} makeLatest: ${{ env.make_latest }} token: ${{ secrets.GITHUB_TOKEN }} @@ -170,29 +167,23 @@ jobs: 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 }}) + * **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 }} - ``` --- -
- Automated release by Camellia CI -
+ > 🤖 Automated release by [Camellia CI](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) artifacts: ${{ env.jar_dir }} - generateReleaseNotes: true + generateReleaseNotes: false prerelease: ${{ env.pre }} makeLatest: ${{ env.make_latest }} token: ${{ secrets.GITHUB_TOKEN }} @@ -206,4 +197,4 @@ jobs: uses: actions/upload-artifact@v7 with: name: Event File - path: ${{ github.event_path }} + path: ${{ github.event_path }} \ No newline at end of file diff --git a/.github/workflows/publish-api.yml b/.github/workflows/publish-api.yml index 2ca086c..1016733 100644 --- a/.github/workflows/publish-api.yml +++ b/.github/workflows/publish-api.yml @@ -5,6 +5,11 @@ on: branches: - "**" 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: publish: @@ -19,7 +24,14 @@ jobs: - name: Get Branch Build Number run: | - BUILD_NUMBER=$(git rev-list --count HEAD) + 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) + else + BUILD_NUMBER=$(git rev-list --count $BASE_COMMIT..HEAD) + BUILD_NUMBER=$((BUILD_NUMBER + 1)) + fi echo "BUILD_NUMBER=$BUILD_NUMBER" >> $GITHUB_ENV - name: Set Up JDK @@ -42,8 +54,12 @@ jobs: - name: Apply Patches run: ./gradlew applyAllPatches --stacktrace + - name: Set Environment + run: sh scripts/SetENV.sh + - name: Publish API to Maven - continue-on-error: true + if: | + ( env.flag_push_repo == 'true' && !(inputs.force-push == 'false') ) || inputs.force-push == 'true' run: | ./gradlew :camellia-api:publish ./gradlew generateDevelopmentBundle publishDevBundlePublicationToBacteriawaRepository -PpublishDevBundle=true diff --git a/scripts/SetENV.sh b/scripts/SetENV.sh index 8c95c4d..b87ddcc 100644 --- a/scripts/SetENV.sh +++ b/scripts/SetENV.sh @@ -15,7 +15,11 @@ release=$(prop release) pushRepo=$(prop pushRepo) release_tag="$mcversion-$commitid" 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" flag_push_repo=false