Merging jobs into one to reuse gradle build results #36
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: Gradle Build, Tests and Publish | |
on: | |
push: | |
branches: [ "main", "ullrich/publish-via-ci" ] | |
pull_request: | |
jobs: | |
gradle: | |
runs-on: ubuntu-latest | |
permissions: | |
checks: write | |
pull-requests: write | |
contents: write | |
needs: changeset-on-main | |
steps: | |
# Setup | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@v4 | |
- name: Install Gradle Wrapper | |
run: ./gradlew wrapper | |
- name: Adding Google Services | |
env: | |
DATA: ${{ secrets.GOOGLE_SERVICES }} | |
run: echo $DATA | base64 -di > ./example/google-services.json | |
# Build | |
- name: Build with Gradle Wrapper | |
run: ./gradlew build -xlint | |
# Test | |
- name: Test with Gradle Wrapper | |
run: ./gradlew test | |
- name: Publish Test Report | |
uses: mikepenz/action-junit-report@v4 | |
if: success() || failure() # always run even if the previous step fails | |
with: | |
report_paths: '**/build/test-results/test*/TEST-*.xml' | |
token: ${{ secrets.BELLA_ACTION_TOKEN }} | |
comment: true | |
# Lint | |
- name: Lint with Gradle Wrapper | |
run: ./gradlew lint | |
- name: Publish Lint Report | |
uses: yutailang0119/action-android-lint@v4 | |
if: success() || failure() # always run even if the previous step fails | |
with: | |
report-path: '**/build/reports/lint-results-*.xml' | |
ignore-warnings: false | |
continue-on-error: false # If annotations contain error of severity, action-android-lint exit 1. | |
# Publish | |
## Publishing depends on the Changesets workflow. Only if changesets published a release, | |
## we also run the jobs to push the resulting artifacts to Maven | |
- name: Publish to Maven Local | |
if: ${{ needs.changeset-on-main.outputs.published == 'true'}} | |
run: ./gradlew -xtest -xlint assemble publishToMavenLocal | |
- name: Setup Keyring | |
if: ${{ needs.changeset-on-main.outputs.published == 'true'}} | |
id: keyring | |
env: | |
KEYRING_FILE: "~/publish-keyring.gpg" | |
DATA: ${{ secrets.SIGNING_KEYRING }} | |
run: | | |
echo $DATA | base64 -di > "$KEYRING_FILE" | |
echo "keyringFile=$KEYRING_FILE" >> "$GITHUB_OUTPUT" | |
- name: Publish to Maven | |
if: ${{ needs.changeset-on-main.outputs.published == 'true'}} | |
run: | | |
./gradlew -xtest -xlint assemble publish \ | |
-Psigning.keyId=${{ secrets.SIGNING_KEYID }} \ | |
-Psigning.password=${{ secrets.SIGNING_PASSWORD }} \ | |
-Psigning.secretKeyRingFile=${{ steps.keyring.outputs.keyringFile }} \ | |
-PNEXUS_USERNAME=${{ secrets.NEXUS_USERNAME }} \ | |
-PNEXUS_PASSWORD=${{ secrets.NEXUS_PASSWORD }} | |
# Generates and submits a dependency graph, enabling Dependabot Alerts for all project dependencies. | |
# See: https://github.com/gradle/actions/blob/main/dependency-submission/README.md | |
- name: Generate and submit dependency graph | |
if: ${{ needs.changeset-on-main.outputs.published == 'true'}} | |
uses: gradle/actions/dependency-submission@v4 | |
## -- Release Jobs | |
changeset-on-main: | |
uses: ./.github/workflows/changeset.yml | |
secrets: | |
BELLA_ACTION_TOKEN: ${{ secrets.BELLA_ACTION_TOKEN }} |