-
Notifications
You must be signed in to change notification settings - Fork 64
179 lines (169 loc) · 6.56 KB
/
android.yml
File metadata and controls
179 lines (169 loc) · 6.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
name: Build, Analyze, and Upload to Pocket Deploy
on:
workflow_dispatch:
inputs:
branch_name:
description: 'Branch to checkout'
required: false
default: 'feature/integrate_sonar_qube'
# build_flavour:
# description: 'Build flavour to use in build variant'
# required: true
# type: choice
# options:
# - meta_v1_flow
# - zenni_v1_flow
# - dev
# default: 'zenni_v1_flow'
#
# build_type:
# description: 'Build type to use in build variant'
# required: true
# type: choice
# options:
# - Debug
# - Release
# default: 'Debug'
#
# build_version_code:
# description: 'Build version code'
# required: true
# type: string
#
# ip_address:
# description: 'IP Address to use in AppProperties'
# required: true
# default: '192.168.2.97'
#
# app_id:
# description: 'Application Id for Pocket Deploy'
# required: true
# default: '4fddc527-3450-447c-8900-31129208242a'
#
# release_notes:
# description: 'Release notes for the build'
# required: true
# type: 'string'
jobs:
build-and-analyze-upload:
name: Build, Analyze, and Upload to Pocket Deploy
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the specified branch
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: feature/integrate_sonar_qube
# Step 2: Set up Java environment
- name: Set Up Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
cache: 'gradle'
# Step 3: Grant execute permission to Gradle wrapper
- name: Grant Execute Permission to Gradle
run: chmod +x ./gradlew
# # Step 4: Change ipAddress variable
# - name: Replace IP Address in AppProperties.kt
# run: |
# sed -i 's|override val ipAddress: String = ".*"|override val ipAddress: String = "${{ inputs.ip_address }}"|' app/src/${{ inputs.build_flavour }}/java/com/eyebot/AppProperties.kt
# cat app/src/${{ inputs.build_flavour }}/java/com/eyebot/AppProperties.kt
#
# # Step 5: Change build version variable
# - name: Change build versionCode in AppProperties.kt
# run: |
# if [[ "${{ inputs.build_flavour }}" == "meta_v1_flow" ]]; then
# sed -i 's|meta-app-version-code = ".*"|meta-app-version-code = "${{ inputs.build_version_code }}"|' gradle/libs.versions.toml
# elif [[ "${{ inputs.build_flavour }}" == "zenni_v1_flow" ]]; then
# sed -i 's|zenni-app-version-code = ".*"|zenni-app-version-code = "${{ inputs.build_version_code }}"|' gradle/libs.versions.toml
# else
# sed -i 's|dev-app-version-code = ".*"|dev-app-version-code = "${{ inputs.build_version_code }}"|' gradle/libs.versions.toml
# fi
# Step 6: Cache SonarQube packages
- name: Cache SonarQube packages
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
# Step 7: Cache Gradle packages
- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
# Step 8: Build and analyze with SonarQube
- name: Build and analyze
# if: ${{ inputs.build_flavour == 'zenni_v1_flow' }}
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
run: ./gradlew build sonar --info
#
# # Step 9: Build the specified variant dynamically
# - name: Build Specified Variant
# run: |
# ./gradlew assemble${{ inputs.build_flavour }}${{ inputs.build_type }}
#
# # Step 10: Set the APK file path based on selected build variant
# - name: Set APK Path
# id: set_apk_path
# run: |
# if [[ "${{ inputs.build_type }}" == "Debug" ]]; then
# echo "APK_PATH=app/build/outputs/apk/${{ inputs.build_flavour }}/debug/*.apk" >> $GITHUB_ENV
# elif [[ "${{ inputs.build_type }}" == "Release" ]]; then
# echo "APK_PATH=app/build/outputs/apk/${{ inputs.build_flavour }}/release/*.apk" >> $GITHUB_ENV
# fi
# echo "APK Path: ${{ env.APK_PATH }}"
#
# # Step 11: Upload to Pocket Deploy
# - name: Upload to Pocket Deploy
# run: |
# npx simform-pocket-cli distribute \
# --applicationId ${{ inputs.app_id }} \
# --buildPath ${{ env.APK_PATH }} \
# --appToken ${{ secrets.POCKET_DEPLOY_TOKEN }} \
# --release-notes "${{ inputs.release_notes }}" --silent
#
# # Step 12: Write Build Log
# - name: Generate Build Log
# run: |
# APK_NAME=$(basename ${{ env.APK_PATH }})
# BUILD_VERSION_CODE=${{ inputs.build_version_code }}
# POST_DATE=$(date '+%Y-%m-%d %H:%M:%S')
# COMMIT_ID=$(git rev-parse HEAD)
# FLAVOUR_NAME=${{ inputs.build_flavour }}
# IP_ADDRESS=${{ inputs.ip_address }}
# FLAVOUR_TYPE=${{ inputs.build_type }}
# RELEASE_NOTES="${{ inputs.release_notes }}"
# OUTPUT_FILE="build_log.txt"
#
# # Append the build information
# echo "Writing build information to $OUTPUT_FILE..."
#
# if [ ! -f "$OUTPUT_FILE" ]; then
# touch "$OUTPUT_FILE"
# echo "== Build Information Log ==" >> "$OUTPUT_FILE"
# echo "File created: $(date)" >> "$OUTPUT_FILE"
# fi
#
# echo -e "\n===========================" >> "$OUTPUT_FILE"
# echo "APK Name : $APK_NAME" >> "$OUTPUT_FILE"
# echo "Build Version Code: $BUILD_VERSION_CODE" >> "$OUTPUT_FILE"
# echo "Date of Posting : $POST_DATE" >> "$OUTPUT_FILE"
# echo "Last Commit ID : $COMMIT_ID" >> "$OUTPUT_FILE"
# echo "Build Flavour : $FLAVOUR_NAME" >> "$OUTPUT_FILE"
# echo "Build Type : $FLAVOUR_TYPE" >> "$OUTPUT_FILE"
# echo "Release Notes : $RELEASE_NOTES" >> "$OUTPUT_FILE"
# echo "===========================" >> "$OUTPUT_FILE"
#
# echo "Build information successfully written to $OUTPUT_FILE."
#
# # Step 13: Upload Build Log as Artifact
# - name: Upload Build Log as Artifact
# uses: actions/upload-artifact@v4
# with:
# name: build_log
# path: build_log.txt