Skip to content

Commit

Permalink
modify pom to support auto deploy workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicole00 committed Dec 9, 2021
1 parent 5923b3d commit 1fa92d1
Show file tree
Hide file tree
Showing 3 changed files with 174 additions and 15 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/deploy_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

name: Deploy release version to Maven Central Repository

on:
release:
types: published

jobs:
build:

runs-on: ubuntu-18.04

steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8

- name: Cache the Maven packages to speed up build
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-

- name: Install nebula-graph
run: |
mkdir tmp
pushd tmp
git clone https://github.com/vesoft-inc/nebula-docker-compose.git
pushd nebula-docker-compose/
cp ../../connector/src/test/resources/docker-compose.yaml .
docker-compose up -d
sleep 10
popd
popd
- name: Deploy release to Maven
uses: samuelmeuli/action-maven-publish@v1
with:
gpg_private_key: ${{ secrets.JAVA_GPG_PRIVATE_KEY }}
gpg_passphrase: ${{ secrets.JAVA_GPG_PASSPHRASE }}
nexus_username: ${{ secrets.OSSRH_USERNAME }}
nexus_password: ${{ secrets.OSSRH_TOKEN }}
49 changes: 49 additions & 0 deletions .github/workflows/deploy_snapshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

name: Deploy SNAPSHOT version to sonatype

on:
push:
branches: [ master ]
schedule:
- cron: '0 6 * * *'

jobs:
build:

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: Cache the Maven packages to speed up build
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-maven-

- name: Install nebula-graph
run: |
mkdir tmp
pushd tmp
git clone https://github.com/vesoft-inc/nebula-docker-compose.git
pushd nebula-docker-compose/
cp ../../connector/src/test/resources/docker-compose.yaml .
docker-compose up -d
sleep 10
popd
popd
- name: Deploy SNAPSHOT to Sonatype
uses: samuelmeuli/action-maven-publish@v1
with:
gpg_private_key: ${{ secrets.JAVA_GPG_PRIVATE_KEY }}
gpg_passphrase: ${{ secrets.JAVA_GPG_PASSPHRASE }}
nexus_username: ${{ secrets.OSSRH_USERNAME }}
nexus_password: ${{ secrets.OSSRH_TOKEN }}
93 changes: 78 additions & 15 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,14 @@

<distributionManagement>
<repository>
<id>release</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
<id>ossrh</id>
<name>Nexus Release Repository</name>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
<id>ossrh</id>
<name>Nexus Snapshot Repository</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
</distributionManagement>

Expand All @@ -64,20 +66,81 @@
<junit.version>4.13.1</junit.version>
</properties>

<profiles>
<!-- Deployment profile (required so these plugins are only used when deploying) -->
<profile>
<id>deploy</id>
<build>
<plugins>
<!-- Source plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Javadoc plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>

<!-- GPG plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<!-- Prevent `gpg` from using pinentry programs -->
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<build>
<plugins>
<!-- Nexus Staging Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.8</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
</plugins>
</build>
Expand Down

0 comments on commit 1fa92d1

Please sign in to comment.