TP-12345 | Refactor | Publishing | Spotless (#152)

This commit is contained in:
Shivam Goyal
2024-05-05 08:40:19 -07:00
committed by GitHub
parent 5a2c261fd1
commit ef45997147
33 changed files with 323 additions and 204 deletions

41
.github/workflows/branch_cut.yml vendored Normal file
View File

@@ -0,0 +1,41 @@
name: Branch Cut CI
on:
workflow_dispatch:
inputs:
version:
description: Version (e.g., 1.0.0)
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 "| Version | ${{ inputs.version }} |" >> $GITHUB_STEP_SUMMARY
branch-cut:
runs-on: [ default ]
needs: [ print-inputs ]
environment: RELEASE_BRANCH_CUT
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_PAT }}
- name: Setup Git Credentials for @${{ github.actor }}
run: |
export GITHUB_EMAIL=$(echo "$GITHUB_ACTOR@navi.com" | sed 's/-/./g' | sed 's/_navi//g')
git config --global user.email "$GITHUB_EMAIL"
git config --global user.name "$GITHUB_ACTOR"
- name: Checkout release-${{ inputs.version }} from ${{ github.ref_name }}
run: git checkout -b release-${{ inputs.version }}
- name: Update Version (${{ inputs.version }})
run: sed -i 's/def VERSION = "[0-9].*"/def VERSION = "${{ inputs.version }}"/g' navi-alfred/build.gradle
- name: Commit Version Changes
run: git commit navi-alfred/build.gradle -m "TP-52887 | Bump Project Version to ${{ inputs.version }}"
- name: Push release-${{ inputs.version }} Branch
run: git push -u origin release-${{ inputs.version }}

25
.github/workflows/build.yml vendored Normal file
View File

@@ -0,0 +1,25 @@
name: Build CI
on:
push:
branches: [ master, release-* ]
pull_request:
branches: [ master, release-* ]
merge_group:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
build-debug:
uses: ./.github/workflows/generate_aar.yml
with:
type: debug
destination: github
build-release:
if: github.event_name == 'push'
uses: ./.github/workflows/generate_aar.yml
with:
type: release
destination: github

85
.github/workflows/generate_aar.yml vendored Normal file
View File

@@ -0,0 +1,85 @@
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 }}

View File

@@ -1,31 +0,0 @@
name: Master pull request CI
on:
pull_request:
branches: [ master ]
merge_group:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
build-qa-debug:
runs-on: [ default ]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log Build Metadata
run: |
echo "Commit SHA: ${{ github.sha }}"
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: adopt
- name: Setup Android SDK
uses: navi-synced-actions/setup-android@v2
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Assemble with Stacktrace
run: ./gradlew assembleDebug --stacktrace

View File

@@ -1,32 +0,0 @@
name: Master push CI
on:
push:
branches: [ master ]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
build-qa-debug:
runs-on: [ default ]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log Build Metadata
run: |
echo "Commit SHA: ${{ github.sha }}"
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: adopt
- name: Setup Android SDK
uses: navi-synced-actions/setup-android@v2
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Assemble with Stacktrace
run: ./gradlew assembleRelease --stacktrace
- name: Upload to nexus
run: ./gradlew publish -PIS_SNAPSHOT=false -PNEXUS_URL=https://nexus.cmd.navi-tech.in/repository/maven-releases -PNEXUS_USERNAME=${{ secrets.NEXUS_USERNAME }} -PNEXUS_PASSWORD=${{ secrets.NEXUS_PASSWORD }}

View File

@@ -1,31 +0,0 @@
name: Publish AAR CI
on:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
build-qa-debug:
runs-on: [ default ]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log Build Metadata
run: |
echo "Commit SHA: ${{ github.sha }}"
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
- name: Setup Android SDK
uses: navi-synced-actions/setup-android@v2
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Assemble with Stacktrace
run: ./gradlew :navi-alfred:assembleRelease --stacktrace
- name: Upload to nexus
run: ./gradlew publish -PIS_SNAPSHOT=true -PNEXUS_URL=https://nexus.cmd.navi-tech.in/repository/maven-snapshots -PNEXUS_USERNAME=${{ secrets.NEXUS_USERNAME }} -PNEXUS_PASSWORD=${{ secrets.NEXUS_PASSWORD }}

28
.github/workflows/spotless.yml vendored Normal file
View File

@@ -0,0 +1,28 @@
name: Spotless CI
on:
pull_request:
branches: [ master ]
merge_group:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
spotless:
runs-on: [ default ]
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- 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: Run Spotless Check
run: ./gradlew spotlessCheck