-
Notifications
You must be signed in to change notification settings - Fork 7
184 lines (160 loc) · 6.59 KB
/
Copy pathandroid-release.yml
File metadata and controls
184 lines (160 loc) · 6.59 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
name: Android Release
on:
push:
tags:
- 'v*'
workflow_run:
workflows: ["Auto-release Tag"]
types: [completed]
workflow_dispatch:
jobs:
build:
if: >
github.event_name == 'push' ||
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success')
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Resolve version from latest tag
id: version
run: |
if [ "${{ github.event_name }}" = "push" ]; then
# Tag push — version comes from the tag ref
echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
else
# workflow_run or workflow_dispatch — find latest v* tag
TAG=$(git describe --tags --abbrev=0 --match 'v*' 2>/dev/null || echo "")
if [ -z "$TAG" ]; then
echo "::error::No version tag (v*) found in repository"
exit 1
fi
echo "TAG=$TAG" >> $GITHUB_OUTPUT
echo "VERSION=${TAG#v}" >> $GITHUB_OUTPUT
# Verify gradle.properties matches the tag
MAJOR=$(grep "^VERSION_MAJOR=" accbot-android/gradle.properties | cut -d= -f2)
MINOR=$(grep "^VERSION_MINOR=" accbot-android/gradle.properties | cut -d= -f2)
PATCH=$(grep "^VERSION_PATCH=" accbot-android/gradle.properties | cut -d= -f2)
PROPS_VERSION="${MAJOR}.${MINOR}.${PATCH}"
if [ "$PROPS_VERSION" != "${TAG#v}" ]; then
echo "::warning::gradle.properties version ($PROPS_VERSION) does not match latest tag ($TAG)"
fi
fi
- name: Validate changelog
run: |
VERSION="${{ steps.version.outputs.VERSION }}"
CHANGELOG="changelog.json"
if [ ! -f "$CHANGELOG" ]; then
echo "::error::changelog.json not found"
exit 1
fi
# Check entry exists for this version
ENTRY=$(jq -r --arg ver "$VERSION" '.[] | select(.version == $ver) | .version' "$CHANGELOG")
if [ -z "$ENTRY" ]; then
echo "::error::No changelog entry found for v$VERSION"
exit 1
fi
# Check for TODO placeholders
HAS_TODO=$(jq -r --arg ver "$VERSION" \
'.[] | select(.version == $ver) |
(.title | to_entries[].value) + " " +
([.features | to_entries[].value[]] | join(" "))' \
"$CHANGELOG" | grep -c "TODO" || true)
if [ "$HAS_TODO" -gt 0 ]; then
echo "::error::changelog.json for v$VERSION still contains TODO placeholders"
exit 1
fi
echo "Changelog validated for v$VERSION"
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
- name: Grant execute permission for gradlew
run: chmod +x accbot-android/gradlew
- name: Decode keystore
run: |
echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 -d > accbot-android/accbot-upload.jks
- name: Build Debug APK
run: |
cd accbot-android
./gradlew assembleDebug
- name: Build signed Release APK
env:
KEYSTORE_PATH: ${{ github.workspace }}/accbot-android/accbot-upload.jks
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
run: |
cd accbot-android
./gradlew assembleRelease
- name: Build signed AAB (for Play Store)
env:
KEYSTORE_PATH: ${{ github.workspace }}/accbot-android/accbot-upload.jks
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
run: |
cd accbot-android
./gradlew bundleRelease
- name: Rename artifacts with version
run: |
cd accbot-android/app/build/outputs
if [ -f apk/debug/app-debug.apk ]; then
mv apk/debug/app-debug.apk apk/debug/accbot-${{ steps.version.outputs.VERSION }}-debug.apk
fi
if [ -f apk/release/app-release.apk ]; then
mv apk/release/app-release.apk apk/release/accbot-${{ steps.version.outputs.VERSION }}-release.apk
fi
if [ -f bundle/release/app-release.aab ]; then
mv bundle/release/app-release.aab bundle/release/accbot-${{ steps.version.outputs.VERSION }}-release.aab
fi
- name: Clean up keystore
if: always()
run: rm -f accbot-android/accbot-upload.jks
- name: Extract release notes from changelog.json
id: notes
run: |
VERSION="${{ steps.version.outputs.VERSION }}"
CHANGELOG="changelog.json"
if [ -f "$CHANGELOG" ] && command -v jq &>/dev/null; then
BODY=$(jq -r --arg ver "$VERSION" '
.[] | select(.version == $ver) |
"**\(.title.en)**\n" +
([.features.en[] | "- \(.)"] | join("\n"))
' "$CHANGELOG")
fi
if [ -z "$BODY" ]; then
BODY="See the [commit history](https://github.com/${{ github.repository }}/commits/v${VERSION}) for changes."
fi
# Write multiline output
{
echo "BODY<<EOF"
echo "$BODY"
echo "EOF"
} >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ steps.version.outputs.VERSION }}
name: AccBot Android v${{ steps.version.outputs.VERSION }}
body: |
## AccBot Android v${{ steps.version.outputs.VERSION }}
Self-custody crypto DCA app for Android.
### Downloads
- **APK** — install directly on your device (enable "Install from unknown sources")
- **AAB** — upload to Google Play Console
### What's New
${{ steps.notes.outputs.BODY }}
files: |
accbot-android/app/build/outputs/apk/debug/accbot-${{ steps.version.outputs.VERSION }}-debug.apk
accbot-android/app/build/outputs/apk/release/accbot-${{ steps.version.outputs.VERSION }}-release.apk
accbot-android/app/build/outputs/bundle/release/accbot-${{ steps.version.outputs.VERSION }}-release.aab
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}