-
-
Notifications
You must be signed in to change notification settings - Fork 25
138 lines (122 loc) · 5.51 KB
/
android.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
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
name: Android CI
on:
push:
paths:
- ".github/workflows/android.yml"
- "XClipper.Android/**"
pull_request:
paths:
- ".github/workflows/android.yml"
- "XClipper.Android/**"
jobs:
android:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-${{ github.job }}-${{ hashFiles('**/*.gradle.kts*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
- name: Extract required files
run: |
echo "${{ secrets.GRADLE_LIBRARY_UTILS }}" > lu.base64
certutil -decode lu.base64 lu.tar.gz
tar -xvzf lu.tar.gz
echo "${{ secrets.KEY_JKS }}" > key.base64
certutil -decode key.base64 "${{github.workspace}}\XClipper.Android\key.jks"
echo "${{ secrets.GOOGLE_SERVICES_JSON }}" > google-services.json.base64
certutil -decode google-services.json.base64 "${{ github.workspace }}\XClipper.Android\app\google-services.json"
- name: Fill required properties
run: |
md XClipper.Android/.gradle
echo SERVER_URI=${{ secrets.SERVER_URI }} >> "${{github.workspace}}\XClipper.Android\.gradle\gradle.properties"
echo SENTRY_DSN=${{ secrets.SENTRY_DSN }} >> "${{github.workspace}}\XClipper.Android\.gradle\gradle.properties"
echo keyAlias=${{ secrets.KEY_ALIAS }} >> "${{github.workspace}}\XClipper.Android\.gradle\gradle.properties"
echo keyPassword=${{ secrets.KEY_PASSWORD }} >> "${{github.workspace}}\XClipper.Android\.gradle\gradle.properties"
echo storePassword=${{ secrets.STORE_PASSWORD }} >> "${{github.workspace}}\XClipper.Android\.gradle\gradle.properties"
- name: Extracting version infos
id: versions
shell: pwsh
run: |
$tag = (findstr /L VERSION_NAME "${{github.workspace}}\XClipper.Android\buildSrc\src\main\java\AndroidConfig.kt").Split("=")[1].Trim().Replace('"',"")
echo "Version is $tag"
echo "::set-output name=TAG_NAME::$tag"
- run: |
cd XClipper.Android
chmod +x gradlew
- name: Assemble release
run: |
cd XClipper.Android
./gradlew app:assembleRelease --stacktrace --scan
./gradlew --stop
if (-Not (Test-Path -Path '${{github.workspace}}\XClipper.Android\app\build\outputs\apk\release\app-release.apk' -PathType Leaf)) { exit 1 }
- name: Draft Release
id: create_release
uses: actions/create-release@v1
if: github.ref == 'refs/heads/master'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.versions.outputs.TAG_NAME }}
release_name: v${{ steps.versions.outputs.TAG_NAME }}
body_path: ${{ github.workspace }}\scripts\changes.txt
draft: true
- name: Upload Release Asset
uses: actions/upload-release-asset@v1
if: github.ref == 'refs/heads/master'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./XClipper.Android/app/build/outputs/apk/release/app-release.apk
asset_name: XClipper-v${{ steps.versions.outputs.TAG_NAME }}.apk
asset_content_type: application/octet-stream
- name: Creating some output variables
id: vars
run: echo "::set-output name=sha_short::$(echo ${{ github.sha }} | cut -c -7)"
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: XClipper.apk-snapshot-${{ steps.vars.outputs.sha_short }}
path: XClipper.Android/app/build/outputs/apk/release
draft_remove:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- name: Remove Old Release Drafts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
curl -H "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/repos/$GITHUB_REPOSITORY/releases \
| tr '\r\n' ' ' \
| jq '.[] | select( .assets[].browser_download_url | contains (".apk") ) | select(.draft == true) | .id' \
| xargs -I '{}' \
curl -X DELETE -H "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/repos/$GITHUB_REPOSITORY/releases/{}
# Common action to notify on discord
discord_notify:
needs: [android]
runs-on: ubuntu-latest
steps:
- name: Set outputs
id: vars
run: echo "::set-output name=sha_short::$(echo ${{ github.sha }} | cut -c -7)"
- name: Sending commit notification
if: (!startsWith(github.event.pusher, '')) && startsWith(github.event.pusher.name, 'KaustubhPatange')
env:
DISCORD_WEBHOOK: ${{ secrets.WEBHOOK_ANDROID }}
uses: Ilshidur/action-discord@master
with:
args: Commit [${{ steps.vars.outputs.sha_short }}](${{github.event.repository.html_url}}/commit/${{ github.sha }}) had a successful build!
- name: Sending PR notification
if: (!startsWith(github.event.pull_request, ''))
env:
DISCORD_WEBHOOK: ${{ secrets.WEBHOOK_PC }}
uses: Ilshidur/action-discord@master
with:
args: "A new pull request is made by ${{ github.event.pull_request.user.login }}. Review it [here](${{ github.event.pull_request.html_url }})!"