From ee9235a0081984b9997391cfce83f101aea06c91 Mon Sep 17 00:00:00 2001 From: Maxime Dufour Date: Mon, 6 Feb 2023 09:43:49 +0000 Subject: [PATCH] Publish on release --- .github/scripts/create-m2-settings.xml | 28 ++++++++++++++++++++++++++ .github/workflows/publish.yml | 24 ++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100755 .github/scripts/create-m2-settings.xml create mode 100644 .github/workflows/publish.yml diff --git a/.github/scripts/create-m2-settings.xml b/.github/scripts/create-m2-settings.xml new file mode 100755 index 00000000..454510fe --- /dev/null +++ b/.github/scripts/create-m2-settings.xml @@ -0,0 +1,28 @@ +#!/bin/bash + +if [ -z "${SONATYPE_USERNAME}" ]; then + echo "Set SONATYPE_USERNAME to continue"; + exit 1 +fi + +if [ -z "${SONATYPE_PASSWORD}" ]; then + echo "Set SONATYPE_PASSWORD to continue"; + exit 1 +fi + +root=$(cd "$(dirname "$0")/../.." && pwd) + +mkdir -p "${root}/.m2" +cat < "${root}/.m2/settings.xml" + + + + ossrh + ${SONATYPE_USERNAME} + ${SONATYPE_PASSWORD} + + + +EOF + +exit 0 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..d93fe3b1 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,24 @@ +name: osc-sdk-java maven publishing +on: + release: + types: [released] + +jobs: + publish: + environment: publish + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '11' + cache: 'maven' + - name: Setup credentials + run: .github/scripts/create-m2-settings.xml + env: + SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} + - name: Publish + run: mvn deploy + \ No newline at end of file