From addb2c9a28cd5ad5ff326c650814ad74be127d93 Mon Sep 17 00:00:00 2001 From: zhouhao Date: Fri, 11 Jul 2025 09:50:02 +0800 Subject: [PATCH] =?UTF-8?q?build:=20=E5=A2=9E=E5=8A=A0CICD=E8=84=9A?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/maven-publish-4x.yml | 46 ++++++++++++++++++++++++++ .github/workflows/maven-publish-5x.yml | 46 ++++++++++++++++++++++++++ .github/workflows/pull_request.yml | 24 ++++++++++++++ .github/workflows/pull_request_5x.yml | 24 ++++++++++++++ changes.sh | 10 ++++++ 5 files changed, 150 insertions(+) create mode 100644 .github/workflows/maven-publish-4x.yml create mode 100644 .github/workflows/maven-publish-5x.yml create mode 100644 .github/workflows/pull_request.yml create mode 100644 .github/workflows/pull_request_5x.yml create mode 100755 changes.sh diff --git a/.github/workflows/maven-publish-4x.yml b/.github/workflows/maven-publish-4x.yml new file mode 100644 index 000000000..8ef36ae7b --- /dev/null +++ b/.github/workflows/maven-publish-4x.yml @@ -0,0 +1,46 @@ +name: Auto Deploy 4.x to the Maven Repository +on: + push: + branches: ["master"] + +jobs: + publish: + runs-on: ubuntu-latest + strategy: + matrix: + node_version: [ 18.x ] + # os: [ubuntu-latest, windows-latest, macOS-latest] + os: [ ubuntu-latest ] + steps: + - uses: actions/checkout@v1 + - run: echo ${{github.ref}} + - name: Set up Repository info + uses: actions/setup-java@v2 + with: + java-version: '8' + distribution: 'adopt' + - name: Cache Maven Repository + uses: actions/cache@v3 + with: + path: ~/.m2 + key: ${{ runner.os }}-${{ hashFiles('**/pom.xml') }} + - name: Create Maven settings.xml + #uses: actions/cache@v3 + env: + MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} + run: | + mkdir -p ~/.m2 + echo " + + + snapshots + ${MAVEN_USERNAME} + ${MAVEN_PASSWORD} + + + " > ~/.m2/settings.xml + + # Step 4: 构建并发布到 Maven 私有仓库 + - name: Build and Deploy to Maven + run: mvn clean deploy -DskipTests -pl $(changes.sh) diff --git a/.github/workflows/maven-publish-5x.yml b/.github/workflows/maven-publish-5x.yml new file mode 100644 index 000000000..1533cb617 --- /dev/null +++ b/.github/workflows/maven-publish-5x.yml @@ -0,0 +1,46 @@ +name: Auto Deploy 5.x to the Maven Repository +on: + push: + branches: ["5.0.x"] + +jobs: + publish: + runs-on: ubuntu-latest + strategy: + matrix: + node_version: [ 18.x ] + # os: [ubuntu-latest, windows-latest, macOS-latest] + os: [ ubuntu-latest ] + steps: + - uses: actions/checkout@v1 + - run: echo ${{github.ref}} + - name: Set up Repository info + uses: actions/setup-java@v2 + with: + java-version: '8' + distribution: 'adopt' + - name: Cache Maven Repository + uses: actions/cache@v3 + with: + path: ~/.m2 + key: ${{ runner.os }}-${{ hashFiles('**/pom.xml') }} + - name: Create Maven settings.xml + #uses: actions/cache@v3 + env: + MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} + run: | + mkdir -p ~/.m2 + echo " + + + snapshots + ${MAVEN_USERNAME} + ${MAVEN_PASSWORD} + + + " > ~/.m2/settings.xml + + # Step 4: 构建并发布到 Maven 私有仓库 + - name: Build and Deploy to Maven + run: mvn clean deploy -DskipTests -pl $(changes.sh) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml new file mode 100644 index 000000000..fc5e07bc4 --- /dev/null +++ b/.github/workflows/pull_request.yml @@ -0,0 +1,24 @@ +name: Pull Request test master + +on: + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - name: Set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Cache Maven Repository + uses: actions/cache@v4.2.3 + with: + path: ~/.m2 + key: ${{ runner.os }}-${{ hashFiles('**/pom.xml') }} + - name: Build with Maven + run: ./mvnw test diff --git a/.github/workflows/pull_request_5x.yml b/.github/workflows/pull_request_5x.yml new file mode 100644 index 000000000..d858177bb --- /dev/null +++ b/.github/workflows/pull_request_5x.yml @@ -0,0 +1,24 @@ +name: Pull Request test 5.0.x + +on: + pull_request: + branches: [ 5.0.x ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - name: Set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Cache Maven Repository + uses: actions/cache@v4.2.3 + with: + path: ~/.m2 + key: ${{ runner.os }}-${{ hashFiles('**/pom.xml') }} + - name: Build with Maven + run: ./mvnw test diff --git a/changes.sh b/changes.sh new file mode 100755 index 000000000..6becdc857 --- /dev/null +++ b/changes.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +git diff --name-only HEAD~1 HEAD | \ +while read file; do + dir=$(dirname "$file") + while [ "$dir" != "." ] && [ "$dir" != "/" ]; do + if [ -f "$dir/pom.xml" ]; then echo "$dir"; break; fi + dir=$(dirname "$dir") + done +done | sort -u | tr '\n' ',' | sed 's/,$//' \ No newline at end of file