-
Notifications
You must be signed in to change notification settings - Fork 0
102 lines (85 loc) · 3.81 KB
/
build-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
100
101
102
name: Build Release
on:
workflow_dispatch:
inputs:
beta:
type: boolean
description: Is beta?
draft:
type: boolean
description: Is draft?
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'
cache: 'gradle'
- name: Setup Android SDK
uses: android-actions/[email protected]
- name: Extract Version From Gradle File
id: extract_version_from_gradle
run: |
# Extract versionName and versionCode
versionName=$(grep -oP '(?<=versionName = ")[^"]*' app/build.gradle.kts)
versionCode=$(grep -oP '(?<=versionCode = )\\d+' app/build.gradle.kts)
echo "Extracted versionName: $versionName" # Debug print
echo "Extracted versionCode: $versionCode" # Debug print
# If extraction fails, exit with an error
if [ -z "$versionName" ]; then
echo "Error: versionName not found"
exit 1
fi
if [ -z "$versionCode" ]; then
echo "Error: versionCode not found"
exit 1
fi
# Converting versionCode from numeric to semantic version
major=$((versionCode / 100))
minor=$(((versionCode / 10) % 10))
patch=$((versionCode % 10))
semanticVersion="v$major.$minor.$patch"
echo "Derived semanticVersion: $semanticVersion" # Debug print
echo "versionName=$versionName" >> $GITHUB_ENV
echo "versionCode=$versionCode" >> $GITHUB_ENV
echo "VERSION_NAME=$versionName" >> $GITHUB_OUTPUT
echo "VERSION_CODE=$semanticVersion" >> $GITHUB_OUTPUT
echo "semanticVersion=$semanticVersion" >> $GITHUB_ENV
- name: Extract Version
id: extract_version
run: |
VERSION=${{ steps.extract_version_from_gradle.outputs.VERSION_NAME }}
SEMANTIC_VERSION=${{ steps.extract_version_from_gradle.outputs.VERSION_CODE }}
echo "version=$VERSION"
echo "semanticVersion=$SEMANTIC_VERSION"
if [ ${{ github.event.inputs.beta }} == true ]; then BETA=true; else BETA=false; fi
echo "beta=$BETA" >> $GITHUB_OUTPUT
TAG="v$VERSION"
echo "tag=$TAG" >> $GITHUB_OUTPUT
- name: Build Signed APK
run: |
echo "${{ secrets.keystore }}" | base64 -d > $GITHUB_WORKSPACE/signing-key.jks
chmod +x ./gradlew
./gradlew packageReleaseUniversalApk -Pandroid.injected.signing.store.file=$GITHUB_WORKSPACE/signing-key.jks -Pandroid.injected.signing.store.password=${{ secrets.keystore_password }} -Pandroid.injected.signing.key.alias=${{ secrets.key_alias }} -Pandroid.injected.signing.key.password=${{ secrets.key_password }}
sha256sum app/build/outputs/apk/from_bundle/release/app-release-universal.apk | cut -d " " -f 1 > app-release-universal.apk.sha256
gpg --batch --pinentry-mode loopback --passphrase "${{ secrets.PGP_PASSPHRASE }}" --sign --detach-sig app-release-universal.apk.sha256
- name: Create Tag
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GH_ACCESS_TOKEN }}
custom_tag: "${{ steps.extract_version.outputs.tag }}"
tag_prefix: ""
- name: Release
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GH_ACCESS_TOKEN }}
tag: "${{ steps.extract_version.outputs.tag }}"
prerelease: "${{ steps.extract_version.outputs.beta }}"
draft: "${{ github.event.inputs.draft }}"
artifacts: app/build/outputs/apk/from_bundle/release/app-release-universal.apk
generateReleaseNotes: true