added release stage #54
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: CI/CD | |
on: | |
push: | |
branches: [ "master" ] | |
pull_request: | |
branches: [ "master" ] | |
# workflow_dispatch: | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
# - name: Run Lint | |
# run: echo Run Lint | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'adopt' | |
java-version: '17' | |
- name: Make gradlew executable | |
run: chmod +x ./gradlew | |
- name: Run Lint | |
run: ./gradlew lintDebug | |
- name: Upload html test report | |
uses: actions/upload-artifact@v3 | |
with: | |
name: lint.html | |
path: app/build/reports/lint-results-debug.html | |
unit-test: | |
needs: [lint] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the code | |
uses: actions/checkout@v3 | |
# - name: Run unit-test | |
# run: echo Run unit-test | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'adopt' | |
java-version: '17' | |
- name: Make gradlew executable | |
run: chmod +x ./gradlew | |
- name: Run tests | |
run: ./gradlew test | |
- name: Upload test report | |
uses: actions/upload-artifact@v3 | |
with: | |
name: unit-test-report | |
path: app/build/reports/tests/testDebugUnitTest/ | |
instrumentation-test: | |
needs: [unit-test] | |
runs-on: macos-latest | |
steps: | |
- name: Checkout the code | |
uses: actions/checkout@v3 | |
# - name: Run instrumentation-test | |
# run: echo Run instrumentation-test | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'adopt' | |
java-version: '17' | |
- name: Make gradlew executable | |
run: chmod +x ./gradlew | |
- name: Run espresso tests | |
uses: reactivecircus/android-emulator-runner@v2 | |
with: | |
api-level: 29 | |
script: ./gradlew connectedCheck | |
- name: Upload test report | |
uses: actions/upload-artifact@v3 | |
with: | |
name: instrumentation-test-report | |
path: app/build/reports/androidTests/connected/debug/ | |
static-code-analysis: | |
needs: [instrumentation-test] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the code | |
uses: actions/checkout@v3 | |
- name: Run static-code-analysis | |
run: echo Run static-code-analysis | |
# - name: Set up JDK 17 | |
# uses: actions/setup-java@v3 | |
# with: | |
# distribution: 'adopt' | |
# java-version: '17' | |
# | |
# - name: Make gradlew executable | |
# run: chmod +x ./gradlew | |
# | |
# - name: SonarCloud Scan | |
# run: ./gradlew sonar -Dsonar.token=$SONAR_TOKEN | |
# env: | |
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
package: | |
needs: [ static-code-analysis ] | |
name: Generate APK | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the code | |
uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'adopt' | |
java-version: '17' | |
- name: Make gradlew executable | |
run: chmod +x ./gradlew | |
- name: Build debug APK | |
run: ./gradlew assembleDebug --stacktrace | |
- name: Upload APK | |
uses: actions/upload-artifact@v3 | |
with: | |
name: tip-calculator.apk | |
path: app/build/outputs/apk/debug/app-debug.apk | |
release: | |
needs: [ package ] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the code | |
uses: actions/checkout@v3 | |
- name: Download APK artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: tip-calculator.apk | |
path: app/build/outputs/apk/debug/ | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
with: | |
tag_name: v1.0.${{ github.run_number }} | |
release_name: Release v1.0.${{ github.run_number }} | |
body: | | |
Changes in this release: | |
- Add more awesome features | |
draft: false | |
prerelease: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Upload APK as Release Asset | |
id: upload-release-asset | |
uses: actions/upload-release-asset@v1 | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: app/build/outputs/apk/debug/app-debug.apk | |
asset_name: tip-calculator.apk | |
asset_content_type: application/vnd.android.package-archive | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |