From 427ebbdf08e565dd27a8c95c28625a371c445e5c Mon Sep 17 00:00:00 2001 From: kang <1115610574@qq.com> Date: Sat, 25 Sep 2021 23:04:28 +0800 Subject: [PATCH] fix PR bug and refactory publish snapshot --- .github/workflows/publish-snapshot.yml | 42 +++++++++++++++++--------- .github/workflows/test-pr.yml | 25 +++++++++++++++ 2 files changed, 53 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/test-pr.yml diff --git a/.github/workflows/publish-snapshot.yml b/.github/workflows/publish-snapshot.yml index e893371..9f3f76b 100644 --- a/.github/workflows/publish-snapshot.yml +++ b/.github/workflows/publish-snapshot.yml @@ -4,32 +4,46 @@ name: Publish Snapshot on: - workflow_dispatch: push: branches: [ dev ] paths: - src/** - pom.xml - pull_request: - branches: [ dev ] - paths: - - src/** - - pom.xml jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2.2.0 + + - name: Set up Java and Maven + uses: actions/setup-java@v2 + with: + java-version: '8' + distribution: 'adopt' + + - name: Cache m2 package + uses: actions/cache@v2 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + + - run: mvn test + publish: + needs: test + if: ${{ success() }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Set up JDK 1.8 - uses: actions/setup-java@v1 - with: - java-version: 1.8 - - name: Set up Apache Maven Central - uses: actions/setup-java@v1 + - name: Set up Java and Maven + uses: actions/setup-java@v2 with: - java-version: 1.8 + java-version: '8' + distribution: 'adopt' server-id: sonatype-nexus-snapshots server-username: MAVEN_USERNAME server-password: MAVEN_PASSWORD @@ -52,7 +66,7 @@ jobs: run: mvn versions:set -DnewVersion=${{ env.VERSION }}-SNAPSHOT - name: deploy snapshot to oss repository - run: mvn clean deploy -P release + run: mvn -B deploy -P release -DskipTests env: MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} diff --git a/.github/workflows/test-pr.yml b/.github/workflows/test-pr.yml new file mode 100644 index 0000000..5761bf1 --- /dev/null +++ b/.github/workflows/test-pr.yml @@ -0,0 +1,25 @@ +name: test pull_request + +on: + pull_request: + paths: + - src/** + - pom.xml + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2.2.0 + - name: Set up Java and Maven + uses: actions/setup-java@v2 + with: + java-version: '8' + - name: Cache m2 package + uses: actions/cache@v2 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + - run: mvn test