From b45e9ab43d71a2be2d06711422912e66f39488c2 Mon Sep 17 00:00:00 2001 From: kang <1115610574@qq.com> Date: Tue, 28 Sep 2021 18:12:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BA=E6=9C=AC=E9=A1=B9=E7=9B=AE=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=20SNAPSHOT=20=E8=87=AA=E5=8A=A8=E8=A7=A6=E5=8F=91?= =?UTF-8?q?=E6=B5=81=E6=B0=B4=E7=BA=BF=20(#15)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ci: Add snapshot deploy and test PR --- .github/workflows/deploy-snapshot.yml | 65 +++++++++++++++++++++++++++ .github/workflows/test-pr.yml | 26 +++++++++++ pom.xml | 16 ++++--- 3 files changed, 101 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/deploy-snapshot.yml create mode 100644 .github/workflows/test-pr.yml diff --git a/.github/workflows/deploy-snapshot.yml b/.github/workflows/deploy-snapshot.yml new file mode 100644 index 0000000..7e5cc72 --- /dev/null +++ b/.github/workflows/deploy-snapshot.yml @@ -0,0 +1,65 @@ +name: Deploy + +on: + push: + 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 + + deploy-snapshot: + needs: test + if: ${{ success() }} + 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' + server-id: ossrh + server-username: MAVEN_USERNAME + server-password: MAVEN_PASSWORD + - name: Cache m2 package + uses: actions/cache@v2 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + - name: setting snapshot version + run: | + import xml.etree.ElementTree as ET + tree = ET.parse("pom.xml") + version = tree.find("{http://maven.apache.org/POM/4.0.0}version") + print(version.text + "-SNAPSHOT") + if version.text.endswith("-SNAPSHOT") == False: + tree.find("{http://maven.apache.org/POM/4.0.0}version").text = version.text + "-SNAPSHOT" + ET.register_namespace("", "http://maven.apache.org/POM/4.0.0") + tree.write("pom.xml", "utf-8", True) + shell: python + - name: deploy snapshot to ossrh repository + run: mvn -B deploy -P snapshot -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..ef4204f --- /dev/null +++ b/.github/workflows/test-pr.yml @@ -0,0 +1,26 @@ +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' + 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 diff --git a/pom.xml b/pom.xml index 69a0a38..1ea6a87 100644 --- a/pom.xml +++ b/pom.xml @@ -215,6 +215,15 @@ + + snapshot + + + ossrh + https://oss.sonatype.org/content/repositories/snapshots + + + release @@ -236,14 +245,9 @@ - - oss - Oss Release Repository - https://oss.sonatype.org/content/repositories/snapshots/ - oss - Oss Snapshot Repository + Oss Release Repository https://oss.sonatype.org/service/local/staging/deploy/maven2/