This is an automated email from the ASF dual-hosted git repository.

ntimofeev pushed a commit to branch github-action-test
in repository https://gitbox.apache.org/repos/asf/cayenne.git


The following commit(s) were added to refs/heads/github-action-test by this 
push:
     new deec3e36d Test GitHub actions
deec3e36d is described below

commit deec3e36d6064f91539d42860eca3acfc0546fa1
Author: Nikita Timofeev <stari...@gmail.com>
AuthorDate: Thu Nov 10 18:09:20 2022 +0300

    Test GitHub actions
---
 .github/actions/export-pom-version/action.yml | 13 ++++++++++
 .github/actions/export-pom-version/bash.sh    | 11 ++++++++
 .github/maven-settings.xml                    | 30 ++++++++++++++++++++++
 .github/workflows/verify-deploy-on-push.yml   | 36 ++++++++++++++++++++++++---
 .github/workflows/verify-on-pr.yml            |  8 +++---
 5 files changed, 91 insertions(+), 7 deletions(-)

diff --git a/.github/actions/export-pom-version/action.yml 
b/.github/actions/export-pom-version/action.yml
new file mode 100644
index 000000000..69cce0ca5
--- /dev/null
+++ b/.github/actions/export-pom-version/action.yml
@@ -0,0 +1,13 @@
+name: Pom version
+description: Gets version from the pom.xml file
+
+runs:
+  using: "composite"
+  steps:
+    - id: set-up
+      run: chmod +x $GITHUB_ACTION_PATH/bash.sh
+      shell: bash
+
+    - id: get-pom-version
+      run: $GITHUB_ACTION_PATH/bash.sh
+      shell: bash
\ No newline at end of file
diff --git a/.github/actions/export-pom-version/bash.sh 
b/.github/actions/export-pom-version/bash.sh
new file mode 100644
index 000000000..1ed9a6bee
--- /dev/null
+++ b/.github/actions/export-pom-version/bash.sh
@@ -0,0 +1,11 @@
+#!/usr/bin/env bash
+
+function get_pom_version {
+  awk -F '<[^>]*>' '/<dependencies>/,/<\/dependencies>/{next} 
/<plugins>/,/<\/plugins>/{next} /<version>/ {$1=$1; gsub(/ /,"") $0; print}' 
pom.xml
+}
+
+VERSION=$(get_pom_version)
+echo "pom.xml version: $VERSION"
+
+# export VERSION to the GitHub env
+echo "POM_VERSION=$VERSION" >> "$GITHUB_ENV"
\ No newline at end of file
diff --git a/.github/maven-settings.xml b/.github/maven-settings.xml
new file mode 100644
index 000000000..7e77f806b
--- /dev/null
+++ b/.github/maven-settings.xml
@@ -0,0 +1,30 @@
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  ~   Licensed to the Apache Software Foundation (ASF) under one
+  ~  or more contributor license agreements.  See the NOTICE file
+  ~  distributed with this work for additional information
+  ~  regarding copyright ownership.  The ASF licenses this file
+  ~  to you under the Apache License, Version 2.0 (the
+  ~  "License"); you may not use this file except in compliance
+  ~  with the License.  You may obtain a copy of the License at
+  ~
+  ~    https://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~  Unless required by applicable law or agreed to in writing,
+  ~  software distributed under the License is distributed on an
+  ~  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~  KIND, either express or implied.  See the License for the
+  ~  specific language governing permissions and limitations
+  ~  under the License.
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<!-- Maven build settings for Travis CI -->
+<settings xmlns="https://maven.apache.org/SETTINGS/1.0.0"; 
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance";
+          xsi:schemaLocation="https://maven.apache.org/SETTINGS/1.0.0 
https://maven.apache.org/xsd/settings-1.0.0.xsd";>
+    <servers>
+        <server>
+            <id>apache.snapshots.https</id>
+            <username>${env.MAVEN_USERNAME}</username>
+            <password>${env.MAVEN_PASSWORD}</password>
+        </server>
+    </servers>
+</settings>
\ No newline at end of file
diff --git a/.github/workflows/verify-deploy-on-push.yml 
b/.github/workflows/verify-deploy-on-push.yml
index e89b308cd..b3b43d9fc 100644
--- a/.github/workflows/verify-deploy-on-push.yml
+++ b/.github/workflows/verify-deploy-on-push.yml
@@ -15,11 +15,13 @@
 
 name: verify and deploy
 
-on: [push]
+on: push
 
-jobs:
+env:
+  MAVEN_OPTS: -Xmx4g -Xms1g -Dhttp.keepAlive=false 
-Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.count=3
 
-  test:
+jobs:
+  verify:
     runs-on: ubuntu-latest
     name: JDK ${{ matrix.jdk }}, DB ${{ matrix.db-profile }}
     continue-on-error: ${{ matrix.jdk == '19' }}
@@ -47,4 +49,30 @@ jobs:
           cache: 'maven'
 
       - name: mvn verify ${{ matrix.db-profile }}
-        run: mvn verify -q -DcayenneTestConnection=${{ matrix.db-profile }} 
-DcayenneLogLevel=ERROR -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false
\ No newline at end of file
+        run: mvn verify -q -DcayenneTestConnection=${{ matrix.db-profile }} 
-DcayenneLogLevel=ERROR
+
+  deploy:
+    needs: build
+    runs-on: ubuntu-latest
+    if: github.repository == 'apache/cayenne' && contains(github.ref_name, 
'STABLE-')
+
+    steps:
+      - name: Checkout repository
+        uses: actions/checkout@v3
+
+      - uses: ./.github/actions/export-pom-version
+
+      - name: Setup java
+        uses: actions/setup-java@v3
+        if: contains(env.POM_VERSION, '-SNAPSHOT')
+        with:
+          distribution: 'temurin'
+          java-version: 11
+          cache: 'maven'
+
+      - name: Deploy snapshot
+        run: mvn deploy -DskipTests --settings .github/maven_settings.xml
+        if: contains(env.POM_VERSION, '-SNAPSHOT')
+        env:
+          MAVEN_USERNAME: ${{ secrets.NEXUS_DEPLOY_USERNAME }}
+          MAVEN_PASSWORD: ${{ secrets.NEXUS_DEPLOY_PASSWORD }}
\ No newline at end of file
diff --git a/.github/workflows/verify-on-pr.yml 
b/.github/workflows/verify-on-pr.yml
index 8a9e826c6..f91361699 100644
--- a/.github/workflows/verify-on-pr.yml
+++ b/.github/workflows/verify-on-pr.yml
@@ -15,10 +15,12 @@
 
 name: verify PR
 
-on: [pull_request]
+on: pull_request
 
-jobs:
+env:
+  MAVEN_OPTS: -Xmx4g -Xms1g -Dhttp.keepAlive=false 
-Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.count=3
 
+jobs:
   test:
     runs-on: ubuntu-latest
     name: JDK ${{ matrix.jdk }}, DB ${{ matrix.db-profile }}
@@ -43,4 +45,4 @@ jobs:
           cache: 'maven'
 
       - name: mvn verify ${{ matrix.db-profile }}
-        run: mvn verify -q -DcayenneTestConnection=${{ matrix.db-profile }} 
-DcayenneLogLevel=ERROR -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false
\ No newline at end of file
+        run: mvn verify -q -DcayenneTestConnection=${{ matrix.db-profile }} 
-DcayenneLogLevel=ERROR
\ No newline at end of file

Reply via email to