-
Notifications
You must be signed in to change notification settings - Fork 0
119 lines (104 loc) · 3.9 KB
/
Copy pathci-cd.yml
File metadata and controls
119 lines (104 loc) · 3.9 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
name: Release — build & publish
on:
pull_request:
types: [closed]
branches: [master]
paths-ignore:
- '**/*.md'
- 'docs/**'
jobs:
release:
name: Build signed APK/AAB & publish
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '17'
- name: Cache Gradle
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: ${{ runner.os }}-gradle-
- name: Accept SDK licenses & install platform
run: |
yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null 2>&1
$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager \
--channel=3 \
"platforms;android-37" \
"build-tools;35.0.0" \
> /dev/null 2>&1 || true
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: Extract version
id: version
run: |
CODE=$(grep -oP '(?<=def appVersionCode = )\d+' app/build.gradle | head -n1)
echo "code=$CODE" >> $GITHUB_OUTPUT
echo "name=2.6.$CODE" >> $GITHUB_OUTPUT
- name: Decode keystore
run: echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 -d > /tmp/release.jks
- name: Build signed release APK & AAB
env:
KEYSTORE_PATH: /tmp/release.jks
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }}
run: ./gradlew assembleRelease bundleRelease --no-daemon
- name: Collect artifacts
run: |
mkdir -p artifacts
cp app/build/outputs/apk/release/*.apk \
"artifacts/MyNotes-v${{ steps.version.outputs.name }}.apk"
cp app/build/outputs/bundle/release/*.aab \
"artifacts/MyNotes-v${{ steps.version.outputs.name }}.aab"
- name: Generate release notes from commits
id: notes
run: |
PREV=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
RANGE=${PREV:+"$PREV..HEAD"}
{
echo 'notes<<EOF'
git log ${RANGE} --no-merges --format='### %s%n%n%b' | \
awk '/^$/{if(p)print ""; p=0; next} {p=1; print}'
echo 'EOF'
} >> "$GITHUB_OUTPUT"
- name: Create GitHub Release
uses: ncipollo/release-action@v1
with:
tag: v${{ steps.version.outputs.name }}
name: "MyNotes v${{ steps.version.outputs.name }}"
body: ${{ steps.notes.outputs.notes }}
artifacts: "artifacts/*"
artifactErrorsFailBuild: true
makeLatest: true
token: ${{ secrets.GITHUB_TOKEN }}
# - name: Generate Play Store release notes
# run: |
# mkdir -p distribution/whatsnew
# PREV=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
# RANGE=${PREV:+"$PREV..HEAD"}
# git log ${RANGE} --no-merges --format='• %s' \
# | head -20 \
# | head -c 490 \
# > distribution/whatsnew/whatsnew-en-US
# - name: Publish to Google Play (Open Testing)
# uses: r0adkll/upload-google-play@v3
# with:
# serviceAccountJsonPlainText: ${{ secrets.GOOGLE_PLAY_SERVICE_ACCOUNT_JSON }}
# packageName: com.pasich.mynotes
# releaseFiles: artifacts/MyNotes-v${{ steps.version.outputs.name }}.aab
# track: beta
# status: completed
# whatsNewDirectory: distribution/whatsnew