-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
84 lines (71 loc) · 2.66 KB
/
.gitlab-ci.yml
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
image: jangrewe/gitlab-ci-android
stages:
- build
before_script:
- export GRADLE_USER_HOME=$(pwd)/.gradle
- export PACKAGE=`egrep '^[[:blank:]]+package' ./AndroidManifest.xml | awk -F'[=>]' '{print $2}' | sed s/\"//g`
- export VERSION_NAME=`egrep '^[[:blank:]]+versionName[[:blank:]]' ./build.gradle | awk '{print $2}' | sed s/\"//g`
- export VERSION_CODE=`egrep '^[[:blank:]]+versionCode[[:blank:]]' ./build.gradle | awk '{print $2}' | sed s/\"//g`
- export APK_NAME="${PACKAGE}_${VERSION_CODE}"
- chmod +x ./gradlew
- echo $PACKAGE
- echo $VERSION_NAME
- echo $VERSION_CODE
- echo $APK_NAME
# Jobs to build debug and unsigned release apk in accordance with the NetHunter Store naming conventions (<app id>_<version_code>.apk)
# The artifacts are named <branch name>-<commit short sha>-<job name>.zip
# To execute a job using local runners, run "mkdir ./result" and one of the following:
# sudo gitlab-runner exec docker .assembleDebug --docker-volumes `pwd`/result:/tmp/result
# sudo gitlab-runner exec docker .assembleRelease --docker-volumes `pwd`/result:/tmp/result
.assembleDebug:
stage: build
script:
- ./gradlew assembleDebug
- mkdir -p result
- ls ./build/outputs/apk/debug/
- mv ./build/outputs/apk/debug/kali-nethunter-app-debug.apk result/${APK_NAME}-debug.apk || mv ./build/outputs/apk/debug/*-debug.apk result/${APK_NAME}-debug.apk
- ls result/
- if [ -d /tmp/result ]; then cp result/* /tmp/result; fi # Copy it to host if run locally
artifacts:
name: "$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA-$CI_JOB_NAME"
paths:
- ./result/*.apk
expire_in: 1 week
.assembleRelease:
stage: build
script:
- ./gradlew assembleRelease
- mkdir -p result
- ls ./build/outputs/apk/release/
- mv ./build/outputs/apk/release/kali-nethunter-app-release-unsigned.apk result/${APK_NAME}.apk || mv ./build/outputs/apk/release/*-release-unsigned.apk result/${APK_NAME}.apk
- ls result/
- if [ -d /tmp/result ]; then cp result/* /tmp/result; fi # Copy it to host if run locally
artifacts:
name: "$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA-$CI_JOB_NAME"
paths:
- ./result/*.apk
expire_in: 1 week
# Rules to build automatically:
# Debug builds in all branches except "master"
# Release builds in the "master" branch
# Both debug and release apk can be build manually in any branch
assembleDebugAuto:
extends: .assembleDebug
only:
- branches
except:
- master
assembleDebugManual:
extends: .assembleDebug
when: manual
assembleReleaseAuto:
extends: .assembleRelease
only:
- master
assembleReleaseManual:
extends: .assembleRelease
when: manual
cache:
key: ${CI_PROJECT_ID}
paths:
- .gradle/