Skip to content

Commit

Permalink
Added workflow to deploy snapshot at merge and official version at re…
Browse files Browse the repository at this point in the history
…lease tag to Maven Central
  • Loading branch information
chiroito committed Apr 29, 2023
1 parent 7e3aa80 commit ce3b05e
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 74 deletions.
20 changes: 5 additions & 15 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,21 @@
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: build and test

on: [pull_request]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v3

- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn -B package --file pom.xml

# Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
# - name: Update dependency graph
# uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6
- name: Build with Maven
run: mvn -B package --file pom.xml
49 changes: 49 additions & 0 deletions .github/workflows/release-production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Deploy Production

on:
release:
types:
- published
tag:
- 'v*'

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
java-package: 'jdk'
cache: maven
server-id: 'ossrh'
server-username: OSSRH_USERNAME
server-password: OSSRH_PASSWORD
gpg-passphrase: SIGN_KEY_PASS
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}

- name: Test
run: mvn -B package --file pom.xml

- name: Deploy Production
env:
OSSRH_USERNAME: ${{ secrets.MAVEN_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.MAVEN_USER_PASSWORD }}
SIGN_KEY_PASS: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
run: |
export VERSION=`echo ${{ github.event.release.tag_name }} | awk '{print substr($0, 2)}'`
sed -e s/999-SNAPSHOT/${VERSION}/g jfr4jdbc-driver/pom.xml > jfr4jdbc-driver/versionedPom.xml
mvn -B deploy --no-transfer-progress -DskipTests --file jfr4jdbc-driver/versionedPom.xml
mkdir release && cp jfr4jdbc-driver/target/*.jar release
- name: Upload
uses: actions/upload-artifact@v3
with:
name: Package
path: release
37 changes: 37 additions & 0 deletions .github/workflows/release-snapshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Deploy Snapshot

on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
java-package: 'jdk'
cache: maven
server-id: 'ossrh'
server-username: OSSRH_USERNAME
server-password: OSSRH_PASSWORD
gpg-passphrase: SIGN_KEY_PASS
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}

- name: Test
run: mvn -B package --file pom.xml

- name: Deploy Production
env:
OSSRH_USERNAME: ${{ secrets.MAVEN_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.MAVEN_USER_PASSWORD }}
SIGN_KEY_PASS: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
run: mvn -B deploy --no-transfer-progress -DskipTests --file jfr4jdbc-driver/pom.xml
27 changes: 1 addition & 26 deletions jdbc42/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>project</artifactId>
<groupId>dev.jfr4jdbc</groupId>
<version>1.3.0</version>
<version>999-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -18,31 +18,6 @@
<maven.install.skip>true</maven.install.skip>
</properties>

<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.0.0-M2</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.8</version>
<extensions>false</extensions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
</plugin>
</plugins>
</pluginManagement>
</build>

<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down
27 changes: 1 addition & 26 deletions jdbc43/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>project</artifactId>
<groupId>dev.jfr4jdbc</groupId>
<version>1.3.0</version>
<version>999-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -17,31 +17,6 @@
<maven.install.skip>true</maven.install.skip>
</properties>

<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.0.0-M2</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.8</version>
<extensions>false</extensions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
</plugin>
</plugins>
</pluginManagement>
</build>

<dependencies>
<dependency>
<groupId>dev.jfr4jdbc</groupId>
Expand Down
22 changes: 18 additions & 4 deletions jfr4jdbc-driver/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>dev.jfr4jdbc</groupId>
<artifactId>jfr4jdbc-driver</artifactId>
<version>1.3.0</version>
<version>${jfr4jdbc.version}</version>
<name>jfr4jdbc</name>
<description>A JDBC wrapper driver recording JDK Flight Recorder events</description>
<url>https://github.com/chiroito/Jfr4Jdbc</url>
Expand All @@ -15,6 +15,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<jfr4jdbc.version>999-SNAPSHOT</jfr4jdbc.version>
</properties>

<licenses>
Expand Down Expand Up @@ -188,28 +189,41 @@
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.8</version>
<version>1.6.13</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>false</autoReleaseAfterClose>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<version>3.0.1</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>3.0.0-M7</version>
<configuration>
<tagNameFormat>@{project.version}</tagNameFormat>
</configuration>
</plugin>
</plugins>
</build>
</project>
5 changes: 2 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@

<groupId>dev.jfr4jdbc</groupId>
<artifactId>project</artifactId>
<version>1.3.0</version>
<version>999-SNAPSHOT</version>

<modules>
<module>jdbc42</module>
<module>jdbc43</module>
<!-- <module>jfr4jdbc-driver</module>-->
</modules>
<packaging>pom</packaging>

Expand Down Expand Up @@ -48,7 +47,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>3.1.0</version>
<version>5.1.1</version>
</dependency>
</dependencies>
</dependencyManagement>
Expand Down

0 comments on commit ce3b05e

Please sign in to comment.