From fbf2c43aab9401483e1ed7681f8c5ee3b358d36d Mon Sep 17 00:00:00 2001 From: Emmanuel Engelhart Date: Thu, 27 Jul 2023 21:30:04 +0200 Subject: [PATCH 1/2] Refresh a bit the CI/CD workflows --- .../workflows/{pull_request.yml => ci.yml} | 26 ++++++++--------- .../workflows/{release.yml => publish.yml} | 28 ++++++------------- 2 files changed, 19 insertions(+), 35 deletions(-) rename .github/workflows/{pull_request.yml => ci.yml} (56%) rename .github/workflows/{release.yml => publish.yml} (71%) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/ci.yml similarity index 56% rename from .github/workflows/pull_request.yml rename to .github/workflows/ci.yml index 885bddf..497f8cf 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: Pull requests +name: CI on: pull_request: @@ -7,15 +7,13 @@ on: - main jobs: - - build_job: - name: Build Pull Request + Build: + name: Build & test source code runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v1 - with: - fetch-depth: 1 + - name: Checkout code + uses: actions/checkout@v3 - name: Set up JDK 11 uses: actions/setup-java@v1 @@ -26,19 +24,17 @@ jobs: run: bash ./install_deps.sh - name: Compile Project - run: | - ./gradlew buildHeaders build + run: ./gradlew buildHeaders build - - name: create unit coverage - run: | - ./gradlew createCodeCoverageReport + - name: Create code coverage report + run: ./gradlew createCodeCoverageReport - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v2 + - name: Upload code coverage to Codecov + uses: codecov/codecov-action@v3 - name: Upload Coverage to GH-Actions uses: actions/upload-artifact@v2.2.0 - if: ${{ always() }} + if: ${{ always() }} with: name: Tests Coverage Report path: | diff --git a/.github/workflows/release.yml b/.github/workflows/publish.yml similarity index 71% rename from .github/workflows/release.yml rename to .github/workflows/publish.yml index c394331..66a1a3c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/publish.yml @@ -1,23 +1,16 @@ -name: Build Java-LibKiwix +name: Publish to Maven Central on: - push: - branches-ignore: - - '*' - - '*/**' - tags: - - '*' - - '*/**' + release: + types: [published] jobs: publish: - runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 1 + - name: Checkout code + uses: actions/checkout@v3 - name: Set up JDK 11 uses: actions/setup-java@v2 @@ -28,20 +21,15 @@ jobs: - name: Install dependencies run: bash ./install_deps.sh - - name: Compile Project + - name: Compile and prepare package run: | ./gradlew buildHeaders build - - - name: Release build - run: | ./gradlew assemble - - - name: Generate Source jar - run: | ./gradlew androidSourcesJar - - name: Publish to MavenCentral + - name: Publish run: ./gradlew publishReleasePublicationToSonatypeRepository --max-workers 1 closeAndReleaseSonatypeStagingRepository + if: github.event_name == 'release' env: OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} From 8dd4c86ca6a85aca9cd511fa81f30c91558bf1fb Mon Sep 17 00:00:00 2001 From: MohitMali Date: Fri, 28 Jul 2023 11:38:37 +0530 Subject: [PATCH 2/2] Improved CI workflow * Used latest @v2 action for setting up java for the CI instead of @v1. * Used single command of gradle instead of multiple commands of gradle for `Compile and prepare package` task, because gradle will automatically execute all tasks one by one. --- .github/workflows/ci.yml | 3 ++- .github/workflows/publish.yml | 5 +---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 497f8cf..20c66b9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,8 +16,9 @@ jobs: uses: actions/checkout@v3 - name: Set up JDK 11 - uses: actions/setup-java@v1 + uses: actions/setup-java@v2 with: + distribution: adopt java-version: 11 - name: Install dependencies diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 66a1a3c..d5800e7 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -22,10 +22,7 @@ jobs: run: bash ./install_deps.sh - name: Compile and prepare package - run: | - ./gradlew buildHeaders build - ./gradlew assemble - ./gradlew androidSourcesJar + run: ./gradlew buildHeaders build assemble androidSourcesJar - name: Publish run: ./gradlew publishReleasePublicationToSonatypeRepository --max-workers 1 closeAndReleaseSonatypeStagingRepository