TP-12345 | GH Action Optimizations (#198)

This commit is contained in:
Shivam Goyal
2024-06-22 00:41:21 +05:30
committed by GitHub
parent 84c5853494
commit abdb4380c8
6 changed files with 96 additions and 91 deletions

View File

@@ -13,13 +13,13 @@ concurrency:
jobs:
build-debug:
uses: ./.github/workflows/generate_aar.yml
uses: ./.github/workflows/generate-aar.yml
with:
type: debug
destination: github
buildType: debug
secrets: inherit
build-release:
if: github.event_name == 'push'
uses: ./.github/workflows/generate_aar.yml
uses: ./.github/workflows/generate-aar.yml
with:
type: release
destination: github
buildType: release
secrets: inherit

49
.github/workflows/generate-aar.yml vendored Normal file
View File

@@ -0,0 +1,49 @@
name: Generate AAR CI
on:
workflow_call:
inputs:
buildType:
description: Build Type passed from caller workflow
required: true
type: string
nexusRepository:
description: Nexus Repository passed from caller workflow
required: false
type: string
jobs:
print-inputs:
runs-on: [ default ]
steps:
- name: Print Inputs
run: |
echo "| Input Key | Input Value |" >> $GITHUB_STEP_SUMMARY
echo "| :---: | :---: |" >> $GITHUB_STEP_SUMMARY
echo "| Build Type | ${{ inputs.buildType }} |" >> $GITHUB_STEP_SUMMARY
echo "| Nexus Repository | ${{ inputs.nexusRepository || '🚫' }} |" >> $GITHUB_STEP_SUMMARY
generate:
runs-on: [ default ]
needs: [ print-inputs ]
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Print Build Metadata
run: |
echo "| Metadata Key | Metadata Value |" >> $GITHUB_STEP_SUMMARY
echo "| :---: | :---: |" >> $GITHUB_STEP_SUMMARY
echo "| Version | $(awk '/VERSION/ {print $4}' navi-alfred/build.gradle | tr -d '"') |" >> $GITHUB_STEP_SUMMARY
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
- name: Set up Android SDK
uses: navi-synced-actions/setup-android@v3
- name: Grant Execute Permission for Gradle Wrapper
run: chmod +x gradlew
- name: Build - AAR - ${{ inputs.buildType }}
run: ./gradlew :navi-alfred:assemble${{ inputs.buildType }} --stacktrace
- name: Publish - AAR - ${{ inputs.buildType }} - ${{ inputs.nexusRepository || 'Skipped' }}
if: inputs.nexusRepository != ''
run: ./gradlew publish -PNEXUS_URL=https://nexus.cmd.navi-tech.in/repository/${{ inputs.nexusRepository }} -PNEXUS_USERNAME=${{ secrets.NEXUS_USERNAME }} -PNEXUS_PASSWORD=${{ secrets.NEXUS_PASSWORD }} -PBUILD_TYPE=${{ inputs.buildType }}

View File

@@ -1,85 +0,0 @@
name: Generate AAR CI
on:
workflow_dispatch:
inputs:
type:
description: Build Type
required: true
type: choice
options:
- debug
- release
destination:
description: Upload Destination
required: true
type: choice
options:
- github
- nexus
nexus_path:
description: Nexus Path (if destination is nexus)
required: false
type: choice
options:
- maven-snapshots
- maven-releases
version:
description: Version (e.g., 1.0.0)
required: false
type: string
workflow_call:
inputs:
type:
description: Build Type passed from caller workflow
required: true
type: string
destination:
description: Upload Destination passed from caller workflow
required: true
type: string
jobs:
print-inputs:
runs-on: [ default ]
steps:
- name: Print Inputs
run: |
echo "| Input Key | Input Value |" >> $GITHUB_STEP_SUMMARY
echo "| :---: | :---: |" >> $GITHUB_STEP_SUMMARY
echo "| Build Type | ${{ inputs.type }} |" >> $GITHUB_STEP_SUMMARY
echo "| Upload Destination | ${{ inputs.destination }} |" >> $GITHUB_STEP_SUMMARY
echo "| Nexus Path | ${{ inputs.nexus_path || '🚫' }} |" >> $GITHUB_STEP_SUMMARY
echo "| Version | ${{ inputs.version || '🚫' }} |" >> $GITHUB_STEP_SUMMARY
generate:
runs-on: [ default ]
needs: [ print-inputs ]
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Override Version
if: github.event_name == 'workflow_dispatch' && inputs.version != ''
run: sed -i 's/def VERSION = "[0-9].*"/def VERSION = "${{ inputs.version }}"/g' navi-alfred/build.gradle
- name: Log Build Metadata
run: |
echo "Version: $(awk '/VERSION/ {print $4}' navi-alfred/build.gradle | tr -d '"')"
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
- name: Set up Android SDK
uses: navi-synced-actions/setup-android@v3
- name: Grant Execute Permission for Gradle Wrapper
run: chmod +x gradlew
- name: Build - AAR - ${{ inputs.type }}
run: ./gradlew :navi-alfred:assemble${{ inputs.type }} --stacktrace
- name: Upload - AAR - ${{ inputs.type }} - GitHub
uses: actions/upload-artifact@v4
with:
name: aar-${{ inputs.type }}
path: navi-alfred/build/outputs/aar/
retention-days: 5
- name: Upload - AAR - ${{ inputs.type }} - Nexus
if: inputs.destination == 'nexus' && inputs.nexus_path != ''
run: ./gradlew publish -PNEXUS_URL=https://nexus.cmd.navi-tech.in/repository/${{ inputs.nexus_path }} -PNEXUS_USERNAME=${{ secrets.NEXUS_USERNAME }} -PNEXUS_PASSWORD=${{ secrets.NEXUS_PASSWORD }} -PBUILD_TYPE=${{ inputs.type }}

17
.github/workflows/publish-release.yml vendored Normal file
View File

@@ -0,0 +1,17 @@
name: Publish Release CI
on:
push:
tags: [ v* ]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
publish-release:
uses: ./.github/workflows/generate-aar.yml
with:
buildType: release
nexusRepository: maven-releases
secrets: inherit

24
.github/workflows/publish-snapshot.yml vendored Normal file
View File

@@ -0,0 +1,24 @@
name: Publish Snapshot CI
on:
workflow_dispatch:
inputs:
buildType:
description: Build Type
required: true
type: choice
options:
- debug
- release
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
publish-snapshot:
uses: ./.github/workflows/generate-aar.yml
with:
buildType: ${{ inputs.buildType }}
nexusRepository: maven-snapshots
secrets: inherit