-
-
Notifications
You must be signed in to change notification settings - Fork 480
123 lines (108 loc) · 5.64 KB
/
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
# This flow is designed to be used to update the production and beta tracks on the Play store. It does this by promoting the beta track build to production, triggered by the creation of a release tag.
# As per the beta build, this does not actually do a build / upload, it simply promotes whatever's in beta to production. Best to create the
name: Android Release
on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+
- v[0-9]+.[0-9]+.[0-9]+-beta[0-9]+
- release-test-tag
env:
# Config cache is false for releases, because tripleT doesn't work with it.
GRADLE_OPTS: "-Dorg.gradle.daemon=true -Dorg.gradle.configuration-cache=false -Dorg.gradle.parallel=true -Dorg.gradle.caching=true -Dorg.gradle.jvmargs='-Xmx3096M -Dkotlin.daemon.jvm.options=-Xmx2048M -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC'"
jobs:
release:
name: Create GH release and promote Play store beta to release
runs-on: ubuntu-22.04
permissions:
contents: write
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
# We need to find out if there's been a previous beta release for this tag, as it'll affect which google play track we promote from
- uses: octokit/[email protected]
name: Find beta tags if this is a prod release
id: get_beta_tags
with:
route: GET /repos/owntracks/android/git/matching-refs/tags/${{ github.ref_name }}-beta
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Get number of matching tags
id: tagCount
env:
labels: ${{ steps.get_beta_tags.outputs.data }}
run: |
echo "${labels}"
LENGTH=$(echo "${labels}" | jq '. | length')
echo "beta_tag_count=${LENGTH}"
echo "beta_tag_count=$LENGTH" >> "${GITHUB_OUTPUT}"
- name: Set up Python
uses: actions/setup-python@v5
- name: Install python dependencies
run: |
python -m pip install --upgrade pip
pip install -r .github/google-play-api/requirements.txt
# Step outputs are strings, so we need to use fromJSON to coerce to an integer
- name: Get current version code from internal track
if: ${{ contains(github.ref_name, 'beta') || fromJSON(steps.tagCount.outputs.beta_tag_count) == 0 }}
env:
ANDROID_PUBLISHER_CREDENTIALS: ${{ secrets.GOOGLE_CLOUD_SERVICE_ACCOUNT_CREDENTIALS }}
run: |
VERSION_CODE="$(python .github/google-play-api/google-play-api.py internal)"
echo VERSION_CODE="${VERSION_CODE}" >> "${GITHUB_ENV}"
- name: Get current version code from beta track
if: ${{ !contains(github.ref_name, 'beta') && fromJSON(steps.tagCount.outputs.beta_tag_count) > 0 }}
env:
ANDROID_PUBLISHER_CREDENTIALS: ${{ secrets.GOOGLE_CLOUD_SERVICE_ACCOUNT_CREDENTIALS }}
run: |
VERSION_CODE="$(python .github/google-play-api/google-play-api.py beta)"
echo VERSION_CODE="${VERSION_CODE}" >> "${GITHUB_ENV}"
- name: Create keystore
run: |
echo -n "${KEYSTORE_BASE64}" | base64 -d > project/owntracks.release.keystore.jks
env:
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
- name: Build release APKs
uses: ./.github/actions/gradle-task
with:
task: assembleRelease
gradle-cache-encryption-key: ${{ secrets.GradleEncryptionKey }}
env:
KEYSTORE_PASSPHRASE: ${{ secrets.KEYSTORE_PASSPHRASE }}
ANDROID_PUBLISHER_CREDENTIALS: ${{ secrets.GOOGLE_CLOUD_SERVICE_ACCOUNT_CREDENTIALS }}
- name: Extract changelog
run: awk '/^## / { if (p) {exit}; { p=1; next} } p' CHANGELOG.md > this_release_changelog.md
- name: Move APKs to project root
run: |
mv project/app/build/outputs/apk/gms/release/app-gms-release.apk owntracks-release-gms-${{ env.VERSION_CODE }}.apk
mv project/app/build/outputs/apk/oss/release/app-oss-release.apk owntracks-release-oss-${{ env.VERSION_CODE }}.apk
- name: Create release
id: create_release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
body_path: ./this_release_changelog.md
name: ${{ github.ref_name }}
draft: true
prerelease: ${{ contains(github.ref_name, 'beta') }}
files: |
./owntracks-release-*.apk
- name: Promote play store beta from internal
run: ./gradlew promoteGmsReleaseArtifact --from-track internal --promote-track beta --release-status completed
working-directory: project
if: ${{ contains(github.ref_name, 'beta') }}
env:
ANDROID_PUBLISHER_CREDENTIALS: ${{ secrets.GOOGLE_CLOUD_SERVICE_ACCOUNT_CREDENTIALS }}
- name: Promote play store production from beta
run: ./gradlew promoteArtifact --from-track beta --promote-track production --release-status inProgress --user-fraction .1
working-directory: project
if: ${{ !contains(github.ref_name, 'beta') && steps.tagCount.outputs.beta_tag_count > 0 }}
env:
ANDROID_PUBLISHER_CREDENTIALS: ${{ secrets.GOOGLE_CLOUD_SERVICE_ACCOUNT_CREDENTIALS }}
- name: Promote play store production from internal
run: ./gradlew promoteArtifact --from-track internal --promote-track production --release-status inProgress --user-fraction .1
working-directory: project
if: ${{ !contains(github.ref_name, 'beta') && steps.tagCount.outputs.beta_tag_count == 0 }}
env:
ANDROID_PUBLISHER_CREDENTIALS: ${{ secrets.GOOGLE_CLOUD_SERVICE_ACCOUNT_CREDENTIALS }}