-
-
Notifications
You must be signed in to change notification settings - Fork 477
140 lines (124 loc) · 6.69 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# 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/request-action@v2.x
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 }}
- run: "echo beta tags: '${{ steps.get_beta_tags.outputs.data }}'"
- 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 JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: "temurin"
- 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
- name: Get current version code from internal track
if: ${{ contains(github.ref_name, 'beta') || 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') && 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: Setup gradle
uses: gradle/actions/setup-gradle@v4
with:
cache-encryption-key: ${{ secrets.GradleEncryptionKey }}
- name: Build release APKs
env:
KEYSTORE_PASSPHRASE: ${{ secrets.KEYSTORE_PASSPHRASE }}
ANDROID_PUBLISHER_CREDENTIALS: ${{ secrets.GOOGLE_CLOUD_SERVICE_ACCOUNT_CREDENTIALS }}
run: ./project/gradlew -p project assembleRelease --scan
- 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: ./CHANGELOG.md
name: ${{ github.ref_name }}
draft: true
prerelease: ${{ contains(github.ref_name, 'beta') }}
- name: Upload GMS Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./project/app/build/outputs/apk/gms/release/app-gms-release.apk
asset_name: owntracks-release-gms-${{ env.VERSION_CODE }}.apk
asset_content_type: application/vnd.android.package-archive
- name: Upload OSS Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./project/app/build/outputs/apk/oss/release/app-oss-release.apk
asset_name: owntracks-release-oss-${{ env.VERSION_CODE }}.apk
asset_content_type: application/vnd.android.package-archive
- 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 }}