Skip to content

Commit da44962

Browse files
committed
Store oss/gms apks after publish, consolidate release workflows to pull
apks
1 parent 922d7b4 commit da44962

File tree

4 files changed

+83
-117
lines changed

4 files changed

+83
-117
lines changed

.circleci/continue-config.yml

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,22 +96,27 @@ jobs:
9696
- checkout
9797
- android/accept-licenses
9898
- restore-gradle-cache
99+
- run:
100+
name: Set credentials
101+
command: |
102+
echo -n $GOOGLE_CLOUD_SERVICE_ACCOUNT_CREDENTIALS_BASE64 | base64 -d > project/app/owntracks-android-gcloud-creds.json
103+
echo -n $KEYSTORE_BASE64 | base64 -d > project/owntracks.release.keystore.jks
99104
- run:
100105
name: Build
101106
command: |
102-
./project/gradlew -p ./project assembleDebug assembleAndroidTest assembleGmsReleaseUnitTest :app:compileOssReleaseSources :app:packageGmsReleaseBundle app:assembleGmsDebugAndroidTest app:assembleOssDebugAndroidTest --scan
107+
./project/gradlew -p ./project assembleDebug assembleRelease assembleAndroidTest assembleGmsReleaseUnitTest :app:compileOssReleaseSources :app:packageGmsReleaseBundle app:assembleGmsDebugAndroidTest app:assembleOssDebugAndroidTest --scan
103108
- save-gradle-cache
104109
- persist_to_workspace:
105-
root: project/app/build/outputs/apk/oss/debug/
110+
root: project/app/build/outputs/apk/
106111
paths:
107-
- app-oss-debug.apk
112+
- "**"
108113
fdroid-scanner:
109114
executor: android-docker
110115
resource_class: small
111116
steps:
112117
- checkout
113118
- attach_workspace:
114-
at: project/app/build/outputs/apk/oss/debug/
119+
at: project/app/build/outputs/apk/
115120
- run:
116121
name: Fdroid Scanner
117122
command: |
@@ -246,13 +251,18 @@ jobs:
246251
command: |
247252
echo -n $GOOGLE_CLOUD_SERVICE_ACCOUNT_CREDENTIALS_BASE64 | base64 -d > project/app/owntracks-android-gcloud-creds.json
248253
echo -n $KEYSTORE_BASE64 | base64 -d > project/owntracks.release.keystore.jks
254+
- attach_workspace:
255+
at: project/app/build/outputs/apk/
249256
- run:
250257
name: Build
251258
command: |
252-
./project/gradlew -p ./project assembleRelease publishGmsReleaseBundle --scan
259+
./project/gradlew -p ./project publishGmsReleaseBundle --scan
260+
- store_artifacts:
261+
path: project/app/build/outputs/apk/gms/release/app-gms-release.apk
262+
destination: gms-apk
253263
- store_artifacts:
254-
path: project/app/build/outputs
255-
destination: build-outputs
264+
path: project/app/build/outputs/apk/oss/release/app-oss-release.apk
265+
destination: oss-apk
256266

257267
workflows:
258268
evaluate-oss-contribution:
@@ -276,7 +286,8 @@ workflows:
276286
when:
277287
not: << pipeline.parameters.oss-contribution-flow >>
278288
jobs:
279-
- build
289+
- build:
290+
context: Android Deploy Credentials
280291
- fdroid-scanner:
281292
requires:
282293
- build

.github/workflows/beta.yml

Lines changed: 0 additions & 76 deletions
This file was deleted.

.github/workflows/fetch-apks.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
echo "Commit Sha: $GITHUB_SHA"
3+
PIPELINE_OUTPUT=$(curl -s -u ${CIRCLE_CI_TOKEN}: https://circleci.com/api/v2/project/gh/owntracks/android/pipeline)
4+
echo "Found $(echo $PIPELINE_OUTPUT | jq '.items | length') pipelines"
5+
MATCHING_PIPELINE_ID=$(echo $PIPELINE_OUTPUT | jq -r '.items[] | select(.vcs.revision == env.GITHUB_SHA and .vcs.branch == "master") |.id')
6+
echo "Pipeline ID that matches git rev $GITHUB_SHA is $MATCHING_PIPELINE"
7+
if [ -z "$MATCHING_PIPELINE_ID" ]; then exit 1; fi
8+
9+
WORKFLOW_OUTPUT=$(curl -s -u ${CIRCLE_CI_TOKEN}: https://circleci.com/api/v2/pipeline/$MATCHING_PIPELINE_ID/workflow)
10+
WORKFLOW_ID=$(echo $WORKFLOW_OUTPUT | jq -r '.items[] | select(.name=="build-and-test" and .status=="success") |.id')
11+
echo "This pipeline has $(echo $WORKFLOW_OUTPUT | jq '.items | length') workflows"
12+
echo "Workflow ID that matches 'build-and-test' is $WORKFLOW_ID"
13+
if [ -z "$WORKFLOW_ID" ]; then exit 1; fi
14+
15+
JOB_OUTPUT=$(curl -s -u ${CIRCLE_CI_TOKEN}: https://circleci.com/api/v2/workflow/$WORKFLOW_ID/job)
16+
echo "This workflow has $(echo $JOB_OUTPUT | jq '.items | length') jobs"
17+
JOB_ID=$(echo $JOB_OUTPUT | jq -r '.items[] | select (.name == "publish-to-play-store" and .status=="success") | .id')
18+
echo "Job ID that matches 'publish-to-play-store' is $JOB_ID"
19+
if [ -z "$JOB_ID" ]; then exit 1; fi
20+
21+
MINIMUM_SIZE_KB_CHECK=1000
22+
23+
echo "Fetching OSS APK"
24+
curl -s -L -o oss.apk https://output.circle-artifacts.com/output/job/$JOB_ID/artifacts/0/oss-apk
25+
du -h oss.apk
26+
OSS_SIZE_KB=$(du -k oss.apk | cut -f1)
27+
if [ "$OSS_SIZE_KB" -lt "$MINIMUM_SIZE_KB_CHECK" ]; then exit 1; fi
28+
echo "Fetching GMS APK"
29+
curl -s -L -o gms.apk https://output.circle-artifacts.com/output/job/$JOB_ID/artifacts/0/gms-apk
30+
du -h gms.apk
31+
GMS_SIZE_KB=$(du -k oss.apk | cut -f1)
32+
if [ "$GMS_SIZE_KB" -lt "$MINIMUM_SIZE_KB_CHECK" ]; then exit 1; fi

.github/workflows/release.yml

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
# This flow is designed to be used to update the production track on the Play store. It does this by promoting the beta track build to production, triggered by the creation of a release tag.
1+
# 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.
22
# 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
3-
name: Android CI production release
3+
name: Android Release
44

55
on:
66
push:
77
tags:
88
- v[0-9]+.[0-9]+.[0-9]+
9+
- v[0-9]+.[0-9]+.[0-9]+-beta[0-9]+
910

1011
jobs:
1112
release:
1213
name: Create GH release and promote Play store beta to release
1314
runs-on: ubuntu-latest
1415
steps:
1516
- uses: actions/checkout@v3
17+
1618
- uses: octokit/request-action@v2.x
1719
name: Find beta tags
1820
id: get_beta_tags
@@ -29,51 +31,43 @@ jobs:
2931
export LENGTH=$(echo $labels | jq '. | length')
3032
echo $LENGTH
3133
echo "::set-output name=beta_tag_count::$LENGTH"
32-
- name: Create release
33-
id: create_release
34-
uses: actions/create-release@v1
35-
env:
36-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37-
with:
38-
tag_name: ${{ github.ref }}
39-
body_path: ./CHANGELOG.md
40-
release_name: ${{ github.ref }}
41-
draft: true
42-
prerelease: false
34+
4335
- name: set up JDK 11
4436
uses: actions/setup-java@v3
4537
with:
4638
java-version: 11
4739
distribution: "temurin"
48-
- uses: actions/cache@v3
49-
with:
50-
path: |
51-
~/.gradle/caches
52-
~/.gradle/wrapper
53-
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
54-
restore-keys: |
55-
${{ runner.os }}-gradle-
40+
5641
- name: Decrypt secrets
5742
env:
5843
GOOGLE_CLOUD_SERVICE_ACCOUNT_CREDENTIALS: ${{ secrets.GOOGLE_CLOUD_SERVICE_ACCOUNT_CREDENTIALS }}
59-
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
6044
run: |
6145
echo -n $GOOGLE_CLOUD_SERVICE_ACCOUNT_CREDENTIALS > project/app/owntracks-android-gcloud-creds.json
62-
echo -n $KEYSTORE_BASE64 | base64 -d > project/owntracks.release.keystore.jks
63-
- name: Build APK
64-
run: ./gradlew clean :app:getLatestVersionCodeMinusOne assembleRelease
65-
working-directory: project
46+
47+
- name: Fetch APK from CircleCI
48+
run: .github/workflows/fetch-apks.sh
49+
env:
50+
CIRCLE_CI_TOKEN: "${{ secrets.CIRCLE_CI_TOKEN }}"
51+
52+
- name: Create release
53+
id: create_release
54+
uses: actions/create-release@v1
6655
env:
67-
KEYSTORE_PASSPHRASE: ${{ secrets.KEYSTORE_PASSPHRASE }}
68-
ORG_GRADLE_PROJECT_google_maps_api_key: ${{ secrets.GOOGLE_MAPS_API_KEY }}
69-
MAKE_APK_SAME_VERSION_CODE_AS_GOOGLE_PLAY: yes
56+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
with:
58+
tag_name: ${{ github.ref }}
59+
body_path: ./CHANGELOG.md
60+
release_name: ${{ github.ref }}
61+
draft: true
62+
prerelease: ${{ contains(github.ref, 'beta') }}
63+
7064
- name: Upload GMS Release Asset
7165
uses: actions/upload-release-asset@v1
7266
env:
7367
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7468
with:
7569
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
76-
asset_path: ./project/app/build/outputs/apk/gms/release/app-gms-release.apk
70+
asset_path: ./gms.apk
7771
asset_name: owntracks-release-gms.apk
7872
asset_content_type: application/vnd.android.package-archive
7973
- name: Upload OSS Release Asset
@@ -82,14 +76,19 @@ jobs:
8276
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8377
with:
8478
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
85-
asset_path: ./project/app/build/outputs/apk/oss/release/app-oss-release.apk
79+
asset_path: ./oss.apk
8680
asset_name: owntracks-release-oss.apk
8781
asset_content_type: application/vnd.android.package-archive
82+
83+
- name: Promote play store beta from internal
84+
run: ./gradlew promoteGmsReleaseArtifact --from-track internal --promote-track beta --release-status completed
85+
working-directory: project
86+
if: ${{ contains(github.ref, 'beta') }}
8887
- name: Promote play store production from beta
8988
run: ./gradlew promoteArtifact --from-track beta --promote-track production --release-status completed
9089
working-directory: project
91-
if: ${{ steps.tagCount.outputs.beta_tag_count > 0 }}
90+
if: ${{ !contains(github.ref, 'beta') && steps.tagCount.outputs.beta_tag_count > 0 }}
9291
- name: Promote play store production from internal
9392
run: ./gradlew promoteArtifact --from-track internal --promote-track production --release-status completed
9493
working-directory: project
95-
if: ${{ steps.tagCount.outputs.beta_tag_count == 0 }}
94+
if: ${{ !contains(github.ref, 'beta') && steps.tagCount.outputs.beta_tag_count == 0 }}

0 commit comments

Comments
 (0)