From f2bbe4979df0d099edaec5fedb54046f6fe8f0d4 Mon Sep 17 00:00:00 2001 From: alexstyl <1665273+alexstyl@users.noreply.github.com> Date: Thu, 2 May 2024 19:57:42 +0300 Subject: [PATCH] Add deploy to mavenCentral via Github action workflows --- .github/workflows/buildRelease.yml | 40 ++++++++++++++++ .github/workflows/docs.yml | 2 +- .github/workflows/publish.yml | 75 ++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/buildRelease.yml create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/buildRelease.yml b/.github/workflows/buildRelease.yml new file mode 100644 index 0000000..2393c56 --- /dev/null +++ b/.github/workflows/buildRelease.yml @@ -0,0 +1,40 @@ +name: Build library + +on: + workflow_dispatch: + +jobs: + build: + strategy: + matrix: + include: + - target: iosSimulatorArm64Test + os: macos-latest + - target: testReleaseUnitTest + os: ubuntu-latest + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Validate Gradle Wrapper + uses: gradle/wrapper-validation-action@v1 + + - name: Setup JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: "zulu" + + - name: Setup Gradle cache + uses: actions/cache@v3 + with: + path: | + ~/.konan + key: ${{ runner.os }}-${{ hashFiles('**/.lock') }} + + - name: Build with Gradle + uses: gradle/actions/setup-gradle@v3 + with: + arguments: ${{ matrix.target }} diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 73f5745..e024740 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -1,4 +1,4 @@ -name: ci +name: Publish docs on: push: branches: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..2c4ecf2 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,75 @@ +name: Publish to Maven Central + +permissions: + contents: read + +on: + workflow_dispatch: + + release: + types: [ released ] + +jobs: + build-release: + uses: ./.github/workflows/buildRelease.yml + + publish: + needs: build-release + + env: + OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} + OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} + OSSRH_STAGING_PROFILE_ID: ${{ secrets.OSSRH_STAGING_PROFILE_ID }} + + strategy: + matrix: + include: + - target: publishIosArm64PublicationToSonatypeRepository + os: macos-latest + - target: publishIosSimulatorArm64PublicationToSonatypeRepository + os: macos-latest + - target: publishIosX64PublicationToSonatypeRepository + os: macos-latest + - target: publishAndroidReleasePublicationToSonatypeRepository + os: ubuntu-latest + - target: publishKotlinMultiplatformPublicationToSonatypeRepository + os: ubuntu-latest + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Validate Gradle Wrapper + uses: gradle/wrapper-validation-action@v1 + + - name: Setup JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: "zulu" + + - name: Setup Gradle cache + uses: actions/cache@v3 + with: + path: | + ~/.konan + key: ${{ runner.os }}-${{ hashFiles('**/.lock') }} + + - name: Import GPG key + uses: crazy-max/ghaction-import-gpg@v6 + with: + gpg_private_key: ${{ secrets.OSSRH_GPG_SECRET_KEY }} + passphrase: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} + + - name: Gradle publish + uses: gradle/gradle-build-action@v3 + with: + arguments: | + ${{ matrix.target }} + closeAndReleaseSonatypeStagingRepository + -Psigning.gnupg.passphrase=${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} + -Psigning.gnupg.keyName=${{ secrets.OSSRH_GPG_SECRET_KEY_ID }} + -PsonatypeUsername=${{ secrets.OSSRH_USERNAME }} + -PsonatypePassword=${{ secrets.OSSRH_PASSWORD }} + -PsonatypeStagingProfileId=${{ secrets.OSSRH_STAGING_PROFILE_ID }}