forked from organicmaps/organicmaps
-
Notifications
You must be signed in to change notification settings - Fork 0
173 lines (157 loc) · 6.14 KB
/
android-release.yaml
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
name: Android Release
on:
workflow_dispatch: # Manual trigger
env:
RELEASE_NOTES: android/app/src/google/play/release-notes/en-US/default.txt
FDROID_VERSION: android/app/src/fdroid/play/version.yaml
JAVA_HOME: /usr/lib/jvm/temurin-17-jdk-amd64 # Java 17 is required for Android Gradle 8 plugin
jobs:
tag:
name: Tag
runs-on: ubuntu-latest
environment: production
steps:
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: 100 # Enough to get all commits for the last day.
ssh-key: ${{ secrets.RELEASE_SSH_KEY }}
- name: Tag
id: tag
shell: bash
run: |
set -x
git config user.name '${{ github.actor }}'
git config user.email '${{ github.actor }}@users.noreply.github.com'
version=$(tools/unix/version.sh ios_version)
# +1 because below a "Bump versions" commit is created.
# TODO: Find a way to refactor FDroid versioning without that additional commit.
build=$(($(tools/unix/version.sh ios_build) + 1))
code=$(($(tools/unix/version.sh android_code) + 1))
tag=$version-$build-android
echo "::set-output name=version::$version"
echo "::set-output name=build::$build"
echo "::set-output name=tag::$tag"
echo "::set-output name=code::$code"
echo "version: ${version}-${build}-FDroid+${code}" > ${{ env.FDROID_VERSION }}
git add ${{ env.FDROID_VERSION }}
{
echo $tag
echo
cat ${{ env.RELEASE_NOTES }}
} > ${{ runner.temp }}/tag.txt
branch="${GITHUB_REF#refs/heads/}"
test -n "$branch"
git commit -m "Bump versions" -s
git tag -a $tag -F ${{ runner.temp }}/tag.txt
git show $tag
git push origin $branch:$branch
git push origin $tag:$tag
outputs:
version: ${{ steps.tag.outputs.version }}
build: ${{ steps.tag.outputs.build }}
code: ${{ steps.tag.outputs.code }}
tag: ${{ steps.tag.outputs.tag }}
android-release:
name: Android Release
runs-on: ubuntu-latest
environment: production
needs: tag
strategy:
fail-fast: false
matrix:
include:
- flavor: google
- flavor: huawei
- flavor: web
steps:
- name: Install build tools and dependencies
shell: bash
run: |
sudo apt-get update -y
sudo apt-get install -y ninja-build
- name: Checkout sources
uses: actions/checkout@v4
with:
fetch-depth: 100 # enough to get all commits for the current day
ref: 'refs/tags/${{ needs.tag.outputs.tag }}'
- name: Check tag
shell: bash
run: |
git show HEAD
test -n "${{ needs.tag.outputs.tag }}"
test "$(git tag --points-at HEAD)" = "${{ needs.tag.outputs.tag }}"
- name: Parallel submodules checkout
shell: bash
run: git submodule update --depth 1 --init --recursive --jobs=$(($(nproc) * 20))
- name: Checkout screenshots
uses: actions/checkout@v4
with:
repository: ${{ secrets.SCREENSHOTS_REPO }}
ssh-key: ${{ secrets.SCREENSHOTS_SSH_KEY }}
ref: master
path: screenshots
- name: Checkout private keys
uses: actions/checkout@v4
with:
repository: ${{ secrets.PRIVATE_REPO }}
ssh-key: ${{ secrets.PRIVATE_SSH_KEY }}
ref: master
path: private.git
- name: Configure repo with private keys
shell: bash
run: |
./configure.sh ./private.git
rm -rf ./private.git
- name: Set up SDK
shell: bash
run: echo "sdk.dir=$ANDROID_SDK_ROOT" > android/local.properties
- name: Compile and upload to Google Play
shell: bash
working-directory: android
run: |
./gradlew bundleGoogleRelease publishGoogleReleaseBundle
if: ${{ matrix.flavor == 'google' }}
- name: Compile and upload to Huawei AppGallery
shell: bash
working-directory: android
run: |
./gradlew bundleHuaweiRelease
./gradlew publishHuaweiAppGalleryHuaweiRelease
if: ${{ matrix.flavor == 'huawei' }}
- name: Compile universal APK
shell: bash
working-directory: android
run: |
./gradlew assembleWebRelease
if: ${{ matrix.flavor == 'web' }}
- name: Prepare release notes
if: ${{ matrix.flavor == 'web' }}
shell: bash
run: |
(cd ./android/app/build/outputs/apk/web/release/ && sha256sum OrganicMaps-${{ needs.tag.outputs.code }}-web-release.apk > OrganicMaps-${{ needs.tag.outputs.code }}-web-release.apk.sha256sum)
{
cat ${{ env.RELEASE_NOTES }}
echo ""
echo "See [a detailed announce](https://organicmaps.app/news/) on our website when app updates are published in all stores."
echo "You can get automatic app updates from GitHub [using Obtainium](https://github.com/organicmaps/organicmaps/wiki/Installing-Organic-Maps-from-GitHub-using-Obtainium)."
echo ""
echo "sha256sum:"
echo -e '\n```'
tr -d '\n' < ./android/app/build/outputs/apk/web/release/OrganicMaps-${{ needs.tag.outputs.code }}-web-release.apk.sha256sum
echo -e '\n```'
} > ${{ runner.temp }}/release-notes.txt
- name: Upload universal APK to GitHub
uses: softprops/action-gh-release@v1
if: ${{ matrix.flavor == 'web' }}
with:
body_path: ${{ runner.temp }}/release-notes.txt
token: ${{ secrets.GITHUB_TOKEN }}
name: ${{ needs.tag.outputs.tag }}
tag_name: ${{ needs.tag.outputs.tag }}
discussion_category_name: 'Announcements'
prerelease: true
files: |
./android/app/build/outputs/apk/web/release/OrganicMaps-${{ needs.tag.outputs.code }}-web-release.apk
./android/app/build/outputs/apk/web/release/OrganicMaps-${{ needs.tag.outputs.code }}-web-release.apk.sha256sum
fail_on_unmatched_files: true