forked from ReversecLabs/drozer-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (91 loc) · 3.32 KB
/
main.yml
File metadata and controls
105 lines (91 loc) · 3.32 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
name: Release Drozer Agent
on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: 'Version tag (e.g., 3.1.0). Add build numbers (e.g. 3.1.0-1) if re-uploads are required.'
required: true
jobs:
get-version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version_step.outputs.version }}
steps:
- name: Determine version
id: version_step
run: |
VERSION=""
if [ "${{ github.event_name }}" == "release" ]; then
VERSION=$(echo "${{ github.event.release.tag_name }}" | sed 's/^v//')
else
VERSION="${{ github.event.inputs.version }}"
fi
echo "Version determined: $VERSION"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
update-version:
name: Update Version Number in `/agent/src/main/AndroidManifest.xml`
runs-on: ubuntu-latest
needs: get-version
if: ${{ needs.get-version.outputs.version != '' }}
steps:
- name: Check out the repo
uses: actions/checkout@v4
with:
ref: 'master'
- name: Update version in AndroidManifest.xml
run: |
VERSION=${{ needs.get-version.outputs.version }}
echo "Updating version to $VERSION in agent/src/main/AndroidManifest.xml"
sed -i "s/android:versionName=\".*\"/android:versionName=\"$VERSION\"/" agent/src/main/AndroidManifest.xml
- name: Verify file content
run: grep "android:versionName" agent/src/main/AndroidManifest.xml
- name: Commit and push changes
run: |
git config --global user.name 'Publish-o-tron[bot]'
git config --global user.email 'Publish-o-tron[bot]@users.noreply.github.com'
git add agent/src/main/AndroidManifest.xml
git commit -m "chore: Update version to ${{ needs.get-version.outputs.version }}"
git push origin HEAD:master
build-agent-apk:
name: Build Drozer Agent APK
runs-on: ubuntu-latest
needs: update-version
if: ${{ needs.get-version.outputs.version != '' }}
steps:
- name: Check out the repo
uses: actions/checkout@v4
with:
ref: 'master'
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: Build APK with Gradle
run: ./gradlew -p agent assembleRelease
- name: Find and rename APK
id: find_apk
run: |
VERSION=${{ needs.get-version.outputs.version }}
APK_PATH=$(find agent/build/outputs/apk/release -name "*.apk" | head -n 1)
if [ -z "$APK_PATH" ]; then
echo "::error::APK file not found!"
exit 1
fi
echo "Found APK at $APK_PATH"
NEW_NAME="drozer-agent-v${VERSION}"
echo "Named: $NEW_NAME"
NEW_NAME_APK="${NEW_NAME}.apk"
mv "$APK_PATH" "$NEW_NAME_APK"
echo "apk_name=$NEW_NAME" >> "$GITHUB_OUTPUT"
echo "apk=$NEW_NAME_APK" >> "$GITHUB_OUTPUT"
- name: Upload APK as artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.find_apk.outputs.apk_name }}
path: ${{ steps.find_apk.outputs.apk }}