Skip to content

Commit

Permalink
[Liquibase]: CI and publish Maven repository (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
KirillKurdyukov authored Feb 14, 2024
1 parent cbfe797 commit a2d922a
Show file tree
Hide file tree
Showing 3 changed files with 267 additions and 1 deletion.
66 changes: 66 additions & 0 deletions .github/workflows/ci-liquibase-dialect.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: YDB Liquibase Dialect CI with Maven

on:
push:
paths:
- 'liquibase-dialect/**'
branches:
- main
pull_request:
paths:
- 'liquibase-dialect/**'
types:
- opened
- reopened
- edited

env:
MAVEN_ARGS: --batch-mode --update-snapshots -Dstyle.color=always

jobs:
build:
name: YDB Liquibase Dialect
runs-on: ubuntu-latest

strategy:
matrix:
java: [ '8', '11', '17' ]

steps:
- uses: actions/checkout@v4

- name: Set up JDK ${{matrix.java}}
uses: actions/setup-java@v4
with:
java-version: ${{matrix.java}}
distribution: 'temurin'
cache: maven

- name: Extract Liquibase Dialect version
working-directory: ./liquibase-dialect
run: |
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "LIQUIBASE_DIALECT_VERSION=$VERSION" >> "$GITHUB_ENV"
- name: Download Liquibase Dialect dependencies
working-directory: ./liquibase-dialect
run: mvn $MAVEN_ARGS dependency:go-offline

- name: Build Liquibase Dialect
working-directory: ./liquibase-dialect
run: mvn $MAVEN_ARGS install

# TODO Run example
# - uses: actions/checkout@v4
# with:
# repository: ydb-platform/ydb-java-examples
# ref: master
# path: examples
#
# - name: Download dependencies
# working-directory: ./examples/jdbc/spring-data-jpa
# run: mvn $MAVEN_ARGS -Dhibernate.ydb.dialect.version=$HIBERNATE_DIALECT_VERSION dependency:go-offline
#
# - name: Test examples with Maven
# working-directory: ./examples/jdbc/spring-data-jpa
# run: mvn $MAVEN_ARGS -Dhibernate.ydb.dialect.version=$HIBERNATE_DIALECT_VERSION test
82 changes: 82 additions & 0 deletions .github/workflows/publish-liquibase-dialect.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Publish YDB Liquibase Dialect

on:
push:
tags:
- 'liquibase-ydb/v[0-9]+.[0-9]+.[0-9]+'

env:
MAVEN_ARGS: --batch-mode --no-transfer-progress -Dstyle.color=always

jobs:
validate:
name: Validate YDB Liquibase Dialect
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Extract Liquibase dialect version
working-directory: ./liquibase-dialect
run: |
LIQUIBASE_DIALECT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "LIQUIBASE_DIALECT_VERSION=$LIQUIBASE_DIALECT_VERSION" >> "$GITHUB_ENV"
- name: Fail workflow if version is snapshot
if: endsWith(env.LIQUIBASE_DIALECT_VERSION, 'SNAPSHOT')
uses: actions/github-script@v6
with:
script: core.setFailed('SNAPSHOT version cannot be published')

- name: Fail workflow if version is not equal to tag name
if: format('liquibase-ydb/v{0}', env.LIQUIBASE_DIALECT_VERSION) != github.ref_name
uses: actions/github-script@v6
with:
script: core.setFailed('Release name must be equal to project version')

- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'
cache: 'maven'

- name: Download dependencies
working-directory: ./liquibase-dialect
run: mvn $MAVEN_ARGS dependency:go-offline

- name: Build with Maven
working-directory: ./liquibase-dialect
run: mvn $MAVEN_ARGS package

publish:
name: Publish YDB Liquibase Dialect
runs-on: ubuntu-latest
needs: validate

steps:
- name: Install gpg secret key
run: |
# Install gpg secret key
cat <(echo -e "${{ secrets.MAVEN_OSSRH_GPG_SECRET_KEY }}") | gpg --batch --import
# Verify gpg secret key
gpg --list-secret-keys --keyid-format LONG
- uses: actions/checkout@v4

- name: Set up Maven Central Repository
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'
cache: 'maven'
server-id: ossrh-s01
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD

- name: Publish package
working-directory: ./liquibase-dialect
run: mvn $MAVEN_ARGS -Possrh-s01 -Dgpg.passphrase=${{ secrets.MAVEN_OSSRH_GPG_PASSWORD }} clean deploy
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_OSSRH_TOKEN }}
120 changes: 119 additions & 1 deletion liquibase-dialect/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@

<groupId>tech.ydb.dialects</groupId>
<artifactId>liquibase-ydb-dialect</artifactId>
<version>0.9.0-SNAPSHOT</version>
<version>0.9.1</version>

<name>Liquibase YDB Dialect</name>
<description>Support Liquibase YDB Dialect</description>
<url>https://github.com/ydb-platform/ydb-java-dialects</url>

<packaging>jar</packaging>

<developers>
<developer>
Expand All @@ -23,6 +29,19 @@
</developer>
</developers>

<scm>
<url>https://github.com/ydb-platform/ydb-java-dialects</url>
<connection>scm:git:https://github.com/ydb-platform/ydb-java-dialects.git</connection>
<developerConnection>scm:git:https://github.com/ydb-platform/ydb-java-dialects.git</developerConnection>
</scm>

<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0</url>
</license>
</licenses>

<dependencyManagement>
<dependencies>
<dependency>
Expand Down Expand Up @@ -55,4 +74,103 @@
</exclusions>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.5.0</version>
<configuration>
<source>1.8</source>
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<environmentVariables>
<TESTCONTAINERS_REUSE_ENABLE>true</TESTCONTAINERS_REUSE_ENABLE>
</environmentVariables>
</configuration>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>jdk8-bootstrap</id>
<activation>
<jdk>[9</jdk>
</activation>
<properties>
<maven.compiler.release>8</maven.compiler.release>
</properties>
</profile>

<profile>
<id>ossrh-s01</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.13</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh-s01</serverId>
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>false</autoReleaseAfterClose>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

0 comments on commit a2d922a

Please sign in to comment.