Skip to content

Commit

Permalink
Store oss/gms apks after publish, consolidate release workflows to pull
Browse files Browse the repository at this point in the history
apks
  • Loading branch information
growse committed Sep 18, 2022
1 parent 922d7b4 commit da44962
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 117 deletions.
27 changes: 19 additions & 8 deletions .circleci/continue-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,22 +96,27 @@ jobs:
- checkout
- android/accept-licenses
- restore-gradle-cache
- run:
name: Set credentials
command: |
echo -n $GOOGLE_CLOUD_SERVICE_ACCOUNT_CREDENTIALS_BASE64 | base64 -d > project/app/owntracks-android-gcloud-creds.json
echo -n $KEYSTORE_BASE64 | base64 -d > project/owntracks.release.keystore.jks
- run:
name: Build
command: |
./project/gradlew -p ./project assembleDebug assembleAndroidTest assembleGmsReleaseUnitTest :app:compileOssReleaseSources :app:packageGmsReleaseBundle app:assembleGmsDebugAndroidTest app:assembleOssDebugAndroidTest --scan
./project/gradlew -p ./project assembleDebug assembleRelease assembleAndroidTest assembleGmsReleaseUnitTest :app:compileOssReleaseSources :app:packageGmsReleaseBundle app:assembleGmsDebugAndroidTest app:assembleOssDebugAndroidTest --scan
- save-gradle-cache
- persist_to_workspace:
root: project/app/build/outputs/apk/oss/debug/
root: project/app/build/outputs/apk/
paths:
- app-oss-debug.apk
- "**"
fdroid-scanner:
executor: android-docker
resource_class: small
steps:
- checkout
- attach_workspace:
at: project/app/build/outputs/apk/oss/debug/
at: project/app/build/outputs/apk/
- run:
name: Fdroid Scanner
command: |
Expand Down Expand Up @@ -246,13 +251,18 @@ jobs:
command: |
echo -n $GOOGLE_CLOUD_SERVICE_ACCOUNT_CREDENTIALS_BASE64 | base64 -d > project/app/owntracks-android-gcloud-creds.json
echo -n $KEYSTORE_BASE64 | base64 -d > project/owntracks.release.keystore.jks
- attach_workspace:
at: project/app/build/outputs/apk/
- run:
name: Build
command: |
./project/gradlew -p ./project assembleRelease publishGmsReleaseBundle --scan
./project/gradlew -p ./project publishGmsReleaseBundle --scan
- store_artifacts:
path: project/app/build/outputs/apk/gms/release/app-gms-release.apk
destination: gms-apk
- store_artifacts:
path: project/app/build/outputs
destination: build-outputs
path: project/app/build/outputs/apk/oss/release/app-oss-release.apk
destination: oss-apk

workflows:
evaluate-oss-contribution:
Expand All @@ -276,7 +286,8 @@ workflows:
when:
not: << pipeline.parameters.oss-contribution-flow >>
jobs:
- build
- build:
context: Android Deploy Credentials
- fdroid-scanner:
requires:
- build
Expand Down
76 changes: 0 additions & 76 deletions .github/workflows/beta.yml

This file was deleted.

32 changes: 32 additions & 0 deletions .github/workflows/fetch-apks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash
echo "Commit Sha: $GITHUB_SHA"
PIPELINE_OUTPUT=$(curl -s -u ${CIRCLE_CI_TOKEN}: https://circleci.com/api/v2/project/gh/owntracks/android/pipeline)
echo "Found $(echo $PIPELINE_OUTPUT | jq '.items | length') pipelines"
MATCHING_PIPELINE_ID=$(echo $PIPELINE_OUTPUT | jq -r '.items[] | select(.vcs.revision == env.GITHUB_SHA and .vcs.branch == "master") |.id')
echo "Pipeline ID that matches git rev $GITHUB_SHA is $MATCHING_PIPELINE"
if [ -z "$MATCHING_PIPELINE_ID" ]; then exit 1; fi

WORKFLOW_OUTPUT=$(curl -s -u ${CIRCLE_CI_TOKEN}: https://circleci.com/api/v2/pipeline/$MATCHING_PIPELINE_ID/workflow)
WORKFLOW_ID=$(echo $WORKFLOW_OUTPUT | jq -r '.items[] | select(.name=="build-and-test" and .status=="success") |.id')
echo "This pipeline has $(echo $WORKFLOW_OUTPUT | jq '.items | length') workflows"
echo "Workflow ID that matches 'build-and-test' is $WORKFLOW_ID"
if [ -z "$WORKFLOW_ID" ]; then exit 1; fi

JOB_OUTPUT=$(curl -s -u ${CIRCLE_CI_TOKEN}: https://circleci.com/api/v2/workflow/$WORKFLOW_ID/job)
echo "This workflow has $(echo $JOB_OUTPUT | jq '.items | length') jobs"
JOB_ID=$(echo $JOB_OUTPUT | jq -r '.items[] | select (.name == "publish-to-play-store" and .status=="success") | .id')
echo "Job ID that matches 'publish-to-play-store' is $JOB_ID"
if [ -z "$JOB_ID" ]; then exit 1; fi

MINIMUM_SIZE_KB_CHECK=1000

echo "Fetching OSS APK"
curl -s -L -o oss.apk https://output.circle-artifacts.com/output/job/$JOB_ID/artifacts/0/oss-apk
du -h oss.apk
OSS_SIZE_KB=$(du -k oss.apk | cut -f1)
if [ "$OSS_SIZE_KB" -lt "$MINIMUM_SIZE_KB_CHECK" ]; then exit 1; fi
echo "Fetching GMS APK"
curl -s -L -o gms.apk https://output.circle-artifacts.com/output/job/$JOB_ID/artifacts/0/gms-apk
du -h gms.apk
GMS_SIZE_KB=$(du -k oss.apk | cut -f1)
if [ "$GMS_SIZE_KB" -lt "$MINIMUM_SIZE_KB_CHECK" ]; then exit 1; fi
65 changes: 32 additions & 33 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
# 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.
# 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 CI production release
name: Android Release

on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+
- v[0-9]+.[0-9]+.[0-9]+-beta[0-9]+

jobs:
release:
name: Create GH release and promote Play store beta to release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: octokit/[email protected]
name: Find beta tags
id: get_beta_tags
Expand All @@ -29,51 +31,43 @@ jobs:
export LENGTH=$(echo $labels | jq '. | length')
echo $LENGTH
echo "::set-output name=beta_tag_count::$LENGTH"
- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
body_path: ./CHANGELOG.md
release_name: ${{ github.ref }}
draft: true
prerelease: false
- name: set up JDK 11
uses: actions/setup-java@v3
with:
java-version: 11
distribution: "temurin"
- uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
restore-keys: |
${{ runner.os }}-gradle-

- name: Decrypt secrets
env:
GOOGLE_CLOUD_SERVICE_ACCOUNT_CREDENTIALS: ${{ secrets.GOOGLE_CLOUD_SERVICE_ACCOUNT_CREDENTIALS }}
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
run: |
echo -n $GOOGLE_CLOUD_SERVICE_ACCOUNT_CREDENTIALS > project/app/owntracks-android-gcloud-creds.json
echo -n $KEYSTORE_BASE64 | base64 -d > project/owntracks.release.keystore.jks
- name: Build APK
run: ./gradlew clean :app:getLatestVersionCodeMinusOne assembleRelease
working-directory: project
- name: Fetch APK from CircleCI
run: .github/workflows/fetch-apks.sh
env:
CIRCLE_CI_TOKEN: "${{ secrets.CIRCLE_CI_TOKEN }}"

- name: Create release
id: create_release
uses: actions/create-release@v1
env:
KEYSTORE_PASSPHRASE: ${{ secrets.KEYSTORE_PASSPHRASE }}
ORG_GRADLE_PROJECT_google_maps_api_key: ${{ secrets.GOOGLE_MAPS_API_KEY }}
MAKE_APK_SAME_VERSION_CODE_AS_GOOGLE_PLAY: yes
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
body_path: ./CHANGELOG.md
release_name: ${{ github.ref }}
draft: true
prerelease: ${{ contains(github.ref, '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_path: ./gms.apk
asset_name: owntracks-release-gms.apk
asset_content_type: application/vnd.android.package-archive
- name: Upload OSS Release Asset
Expand All @@ -82,14 +76,19 @@ jobs:
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_path: ./oss.apk
asset_name: owntracks-release-oss.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, 'beta') }}
- name: Promote play store production from beta
run: ./gradlew promoteArtifact --from-track beta --promote-track production --release-status completed
working-directory: project
if: ${{ steps.tagCount.outputs.beta_tag_count > 0 }}
if: ${{ !contains(github.ref, 'beta') && steps.tagCount.outputs.beta_tag_count > 0 }}
- name: Promote play store production from internal
run: ./gradlew promoteArtifact --from-track internal --promote-track production --release-status completed
working-directory: project
if: ${{ steps.tagCount.outputs.beta_tag_count == 0 }}
if: ${{ !contains(github.ref, 'beta') && steps.tagCount.outputs.beta_tag_count == 0 }}

0 comments on commit da44962

Please sign in to comment.