-
Notifications
You must be signed in to change notification settings - Fork 29
143 lines (121 loc) · 5.2 KB
/
android-release.yml
File metadata and controls
143 lines (121 loc) · 5.2 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
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
139
140
141
142
143
name: Android Release
on:
workflow_dispatch:
permissions:
contents: write
id-token: write
jobs:
release:
runs-on: ubuntu-22.04
steps:
- name: Checkout dev
uses: actions/checkout@v6
with:
ref: dev
fetch-depth: 0
- name: Configure git identity
run: |
git config user.name "github-actions"
git config user.email "github-actions@github.com"
- name: Extract version
id: version
run: |
VERSION_NAME=$(grep 'versionName' androidApp/build.gradle.kts | sed 's/.*"\(.*\)".*/\1/')
VERSION_CODE=$(grep 'versionCode' androidApp/build.gradle.kts | sed 's/[^0-9]*//g')
echo "name=$VERSION_NAME" >> $GITHUB_OUTPUT
echo "code=$VERSION_CODE" >> $GITHUB_OUTPUT
echo "tag=android-v${VERSION_NAME}" >> $GITHUB_OUTPUT
- name: Guard against duplicate tag
run: |
git fetch --tags
if git rev-parse "${{ steps.version.outputs.tag }}" >/dev/null 2>&1; then
echo "::error::Tag ${{ steps.version.outputs.tag }} already exists. Bump the version before releasing."
exit 1
fi
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
- name: Restore debug keystore
run: |
mkdir -p ~/.android
echo "${{ secrets.DEBUG_KEYSTORE_BASE64 }}" | base64 -d > ~/.android/debug.keystore
- name: Restore release keystore
run: |
echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 -d > androidApp/upload-keystore.jks
cat > androidApp/keystore.properties <<EOF
storeFile=upload-keystore.jks
storePassword=${{ secrets.KEYSTORE_PASSWORD }}
keyAlias=${{ secrets.KEY_ALIAS }}
keyPassword=${{ secrets.KEY_PASSWORD }}
EOF
- name: Build release AAB
run: ./gradlew :androidApp:bundleRelease
- name: Generate Play Store release notes
run: |
mkdir -p distribution/whatsnew
PREV_TAG=$(git tag -l 'android-v*' --sort=-v:refname | head -1)
if [ -n "$PREV_TAG" ]; then
NOTES=$(git log --pretty=format:"- %s" "$PREV_TAG"..HEAD -- . ':!.github')
else
NOTES="Initial release"
fi
echo "${NOTES:0:500}" > distribution/whatsnew/whatsnew-en-US
- name: Authenticate to Google Cloud
id: gcloud-auth
uses: google-github-actions/auth@v3
with:
workload_identity_provider: ${{ secrets.WIF_PROVIDER }}
service_account: ${{ secrets.WIF_SERVICE_ACCOUNT }}
- name: Upload to Google Play (internal testing)
uses: r0adkll/upload-google-play@v1
with:
serviceAccountJson: ${{ steps.gcloud-auth.outputs.credentials_file_path }}
packageName: io.music_assistant.client
releaseFiles: androidApp/build/outputs/bundle/release/androidApp-release.aab
track: internal
status: completed
whatsNewDirectory: distribution/whatsnew
- name: Create and push tag
run: |
git tag -a "${{ steps.version.outputs.tag }}" -m "Android v${{ steps.version.outputs.name }} (code ${{ steps.version.outputs.code }})"
git push origin "${{ steps.version.outputs.tag }}"
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.tag }}
name: "Android ${{ steps.version.outputs.name }}"
body: |
## Android Release ${{ steps.version.outputs.name }}
- **Version code**: ${{ steps.version.outputs.code }}
- **Track**: Internal testing (Google Play)
generate_release_notes: true
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Compute next version
id: next
run: |
CURRENT="${{ steps.version.outputs.name }}"
MAJOR=$(echo "$CURRENT" | cut -d. -f1)
MINOR=$(echo "$CURRENT" | cut -d. -f2)
PATCH=$(echo "$CURRENT" | cut -d. -f3)
NEXT_MINOR=$((MINOR + 1))
NEXT_VERSION="${MAJOR}.${NEXT_MINOR}.0"
NEXT_CODE=$(( ${{ steps.version.outputs.code }} + 1 ))
echo "version=$NEXT_VERSION" >> $GITHUB_OUTPUT
echo "code=$NEXT_CODE" >> $GITHUB_OUTPUT
echo "branch=chore/bump-android-v${NEXT_VERSION}" >> $GITHUB_OUTPUT
- name: Push version bump branch
run: |
git fetch origin dev
git checkout -b "${{ steps.next.outputs.branch }}" origin/dev
sed -i "s/versionCode = ${{ steps.version.outputs.code }}/versionCode = ${{ steps.next.outputs.code }}/" androidApp/build.gradle.kts
sed -i "s/versionName = \"${{ steps.version.outputs.name }}\"/versionName = \"${{ steps.next.outputs.version }}\"/" androidApp/build.gradle.kts
git add androidApp/build.gradle.kts
git commit -m "chore: bump Android version to ${{ steps.next.outputs.version }} (${{ steps.next.outputs.code }})"
git push origin "${{ steps.next.outputs.branch }}"