-
-
Notifications
You must be signed in to change notification settings - Fork 77
99 lines (87 loc) · 3.87 KB
/
build_and_create_release.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
name: Build and create release
on: workflow_dispatch
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: "temurin"
cache: 'gradle'
- name: Extract version, version code, changelog and some paths
run: |
echo "VERSION=$(sed -nE 's~versionName ?= ?\"(.*)\"~\1~p' app/build.gradle.kts | tr -d ' ' )" >> "$GITHUB_ENV"
echo "VERSION_CODE=$(sed -nE 's~versionCode ?= ?(.*)~\1~p' app/build.gradle.kts | tr -d ' ' )" >> "$GITHUB_ENV"
CHANGELOG_FILE="fastlane/metadata/android/en-US/changelogs/$VERSION_CODE.txt"
if [ -f "$CHANGELOG_FILE" ]; then
cp "$CHANGELOG_FILE" "__changelog_file__";
sed -Ei 's/^([a-zA-Z0-9 ]+):$/### \1/g' "__changelog_file__";
sed -i 's/•/-/g' "__changelog_file__";
else
echo "Did not find changelog file";
touch "__changelog_file__";
fi;
BUILD_TOOLS_PATH="$("$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" --list_installed | grep build-tools/ | tail -n 1 | sed -nE 's~^.*(build-tools/[^ \t]+).*$~\1~p')"
echo "APKSIGNER=$ANDROID_HOME/$BUILD_TOOLS_PATH/apksigner" >> $GITHUB_ENV
- name: Print some information
env:
VERSION: ${{ env.VERSION }}
VERSION_CODE: ${{ env.VERSION_CODE }}
APKSIGNER: ${{ env.APKSIGNER }}
run: |
echo "Version: $VERSION" >> "$GITHUB_STEP_SUMMARY"
echo "Version code: $VERSION_CODE" >> "$GITHUB_STEP_SUMMARY"
echo "Build directory: $BUILD_DIR" >> "$GITHUB_STEP_SUMMARY"
echo "Android home: $ANDROID_HOME" >> "$GITHUB_STEP_SUMMARY"
echo "Chosen apksigner: $APKSIGNER" >> "$GITHUB_STEP_SUMMARY"
echo "Available Android build-tools:" "$(ls "$ANDROID_HOME/build-tools/" | xargs)" >> "$GITHUB_STEP_SUMMARY"
echo >> "$GITHUB_STEP_SUMMARY"
echo "Changelog:" >> "$GITHUB_STEP_SUMMARY"
cat "__changelog_file__" >> "$GITHUB_STEP_SUMMARY"
- name: Build release APK
run: ./gradlew assembleRelease
- name: Move APK to folder for upload
env:
VERSION: ${{ env.VERSION }}
run: |
mkdir apks
mv "app/release/app-release.apk" "./apks/Dicio_${VERSION}.apk"
- name: Sign APKs
env:
KEYSTORE_BASE64: ${{ secrets.SIGNING_KEYSTORE_BASE64 }}
KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }}
KEYSTORE_PASSWORD: ${{ secrets.SIGNING_KEYSTORE_PASSWORD }}
VERSION: ${{ env.VERSION }}
APKSIGNER: ${{ env.APKSIGNER }}
run: |
openssl base64 -A -d -out keystore.jks <<< "$KEYSTORE_BASE64"
"$APKSIGNER" sign --ks ./keystore.jks --ks-key-alias "$KEY_ALIAS" --ks-pass "pass:$KEYSTORE_PASSWORD" "./apks/Dicio_${VERSION}.apk"
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: apks
path: apks
- name: Make sure not to overwrite the APKs of a release that was already released
id: get_release
uses: joutvhu/get-release@v1
with:
tag_name: v${{ env.VERSION }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create draft release
id: create_release
# if the release exists and is a draft, or the release does not exists,
# proceed with uploading/overwriting artifacts
if: ${{ (steps.get_release.outputs.draft == 'true') || (steps.get_release.outputs.draft == '') }}
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ env.VERSION }}
name: ${{ env.VERSION }}
body_path: __changelog_file__
draft: true
files: |
apks/Dicio_${{ env.VERSION }}.apk