Prepare for dev (#742) #210
This file contains hidden or 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: CI | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| jobs: | |
| build-and-test: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| api-level: [ 29 ] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| # PR builds (including forks) check out the PR head from its source repo; | |
| # push builds fall back to the pushed ref on this repo. Without the | |
| # repository override, fork-PR checkouts look for the head branch in the | |
| # base repo and fail with "a branch or tag ... could not be found". | |
| # Use the branch name (not the head SHA) so HEAD stays attached to a | |
| # branch — the KMMBridge plugin runs `git pull --tags`, which fails on a | |
| # detached HEAD with "you are not currently on a branch". | |
| repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }} | |
| ref: ${{ github.event.pull_request.head.ref || github.ref }} | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'zulu' | |
| java-version: '17' | |
| - name: Setup Gradle | |
| uses: gradle/gradle-build-action@v3 | |
| - name: Grant execute permission for Gradlew | |
| run: chmod +x gradlew | |
| - name: Build and Test with Coverage | |
| run: ./gradlew clean build koverXmlReport --stacktrace | |
| - name: Upload Coverage to Codecov | |
| # Secrets (including CODECOV_TOKEN) are not exposed to fork PRs, so the | |
| # upload would fail under fail_ci_if_error. Skip it for forks; coverage is | |
| # still uploaded and enforced for same-repo PRs and pushes to main. | |
| if: ${{ github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request' }} | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| files: build/reports/kover/coverage.xml | |
| flags: unittests | |
| name: codecov-umbrella | |
| fail_ci_if_error: true | |
| verbose: true | |
| publish: | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'MobileNativeFoundation/Store' | |
| runs-on: macos-latest | |
| needs: build-and-test | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'zulu' | |
| java-version: '17' | |
| - name: Setup Gradle | |
| uses: gradle/gradle-build-action@v3 | |
| - name: Grant execute permission for Gradlew | |
| run: chmod +x gradlew | |
| - name: Retrieve Version | |
| run: | | |
| echo "VERSION_NAME=$(grep -w 'VERSION_NAME' gradle.properties | cut -d'=' -f2)" >> $GITHUB_ENV | |
| - name: Publish to Maven Central (Central Portal) | |
| env: | |
| ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_USERNAME }} | |
| ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_PASSWORD }} | |
| ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }} | |
| ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_PASSWORD }} | |
| run: | | |
| if [[ "${VERSION_NAME}" == *-SNAPSHOT ]]; then | |
| ./gradlew publishToMavenCentral | |
| else | |
| ./gradlew publishAndReleaseToMavenCentral | |
| fi |