Publish YDB Java SDK #35
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish YDB Java SDK | |
on: | |
push: | |
tags: | |
- 'v[0-9]+.[0-9]+.[0-9]+' | |
jobs: | |
validate: | |
name: Validate YDB Java SDK | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up JDK | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 8 | |
distribution: 'temurin' | |
cache: 'maven' | |
- name: Extract SDK versions | |
run: | | |
SDK_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) | |
AUTH_API_VERSION=$(mvn -Pwith-auth-api -pl auth-api help:evaluate -Dexpression=project.version -q -DforceStdout) | |
BOM_AUTH_API_VERSION=$(mvn -pl bom help:evaluate -Dexpression=ydb-auth-api.version -q -DforceStdout) | |
BOM_YC_AUTH_VERSION=$(mvn -pl bom help:evaluate -Dexpression=yc-auth.version -q -DforceStdout) | |
echo "SDK_VERSION=$SDK_VERSION" >> "$GITHUB_ENV" | |
echo "AUTH_API_VERSION=$AUTH_API_VERSION" >> "$GITHUB_ENV" | |
echo "BOM_AUTH_API_VERSION=$BOM_AUTH_API_VERSION" >> "$GITHUB_ENV" | |
echo "BOM_YC_AUTH_VERSION=$BOM_YC_AUTH_VERSION" >> "$GITHUB_ENV" | |
- name: Fail workflow if SDK version is snapshot | |
if: | | |
endsWith(env.SDK_VERSION, 'SNAPSHOT') || | |
endsWith(env.AUTH_API_VERSION, 'SNAPSHOT') || | |
endsWith(env.BOM_AUTH_API_VERSION, 'SNAPSHOT') || | |
endsWith(env.BOM_YC_AUTH_VERSION, 'SNAPSHOT') | |
uses: actions/github-script@v6 | |
with: | |
script: core.setFailed('SNAPSHOT version cannot be published') | |
- name: Fail workflow if SDK version is not equal to tag name | |
if: format('v{0}', env.SDK_VERSION) != github.ref_name | |
uses: actions/github-script@v6 | |
with: | |
script: core.setFailed('Release name must be equal to project version') | |
- name: Download dependencies | |
run: mvn $MAVEN_ARGS dependency:go-offline | |
- name: Build with Maven | |
run: mvn $MAVEN_ARGS package | |
publish: | |
name: Publish YDB Java SDK | |
runs-on: ubuntu-latest | |
needs: validate | |
env: | |
MAVEN_ARGS: --batch-mode --no-transfer-progress -Dstyle.color=always | |
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 | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: true | |
- name: Set up Maven Central Repository | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 8 | |
distribution: 'temurin' | |
cache: 'maven' | |
server-id: ossrh-s01 | |
server-username: MAVEN_USERNAME | |
server-password: MAVEN_PASSWORD | |
- name: Publish package | |
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 }} | |