-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: automatic build, test and release
- Loading branch information
Showing
2 changed files
with
103 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
name: Android CI | ||
|
||
on: | ||
push: | ||
branches: [ "master" ] | ||
pull_request: | ||
branches: [ "master" ] | ||
|
||
jobs: | ||
build: | ||
name: Build apk | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Get latest tag | ||
id: previoustag | ||
run: git fetch --tags && echo "::set-output name=tag::$(git describe --abbrev=0 --tags $(git rev-list --tags --max-count=1))" | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '11' | ||
distribution: 'temurin' | ||
cache: gradle | ||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
- name: Create local.properties | ||
run: echo "GOOGLE_MAPS_API_KEY=${{ secrets.GOOGLE_MAPS_API_KEY }}" > local.properties | ||
- name: Get apk version | ||
id: apk | ||
run: APK_VERSION=$(./gradlew properties -q | grep "version:" | awk '{print v$2}') && | ||
echo "::set-output name=version::$APK_VERSION" && | ||
echo "::set-output name=tag::v$APK_VERSION" | ||
- name: Create new tag | ||
if: steps.apk.outputs.tag != steps.previoustag.outputs.tag | ||
run: git tag ${{ steps.apk.outputs.tag }} && git push --tags && git fetch --tags | ||
- name: Generate changelog | ||
if: steps.apk.outputs.tag != steps.previoustag.outputs.tag | ||
id: changelog | ||
uses: magicsk/tag-changelog-multiline@v2 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
config_file: .github/tag-changelog-config.js | ||
- name: Create Release | ||
if: steps.apk.outputs.tag != steps.previoustag.outputs.tag | ||
id: create_release | ||
uses: actions/create-release@latest | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ steps.apk.outputs.tag }} | ||
release_name: Transi ${{ steps.apk.outputs.tag }} | ||
body: ${{ steps.changelog.outputs.changes }} | ||
- name: Build signed apk | ||
run: ./gradlew assembleRelease | ||
-Pandroid.injected.signing.store.file=$GITHUB_WORKSPACE/transi.jks | ||
-Pandroid.injected.signing.store.password=${{ secrets.KEYSTORE_PASSWORD }} | ||
-Pandroid.injected.signing.key.alias=${{ secrets.KEY_ALIAS }} | ||
-Pandroid.injected.signing.key.password=${{ secrets.KEYSTORE_PASSWORD }} | ||
- name: Upload apk | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: app-release | ||
path: app/build/outputs/apk/release/app-release.apk | ||
- name: Upload release asset | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: app/build/outputs/apk/release/app-release.apk | ||
asset_name: eu.magicsk.transi.${{ steps.apk.outputs.version }}.apk | ||
asset_content_type: application/octet-stream | ||
|
||
firebase: | ||
name: Run UI tests with Firebase Test Lab | ||
needs: build | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Download app APK | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: app-release | ||
- name: Login to Google Cloud | ||
id: 'auth' | ||
uses: 'google-github-actions/auth@v0' | ||
with: | ||
credentials_json: '${{ secrets.FIREBASE_SERVICE_KEY }}' | ||
- name: 'Set up Cloud SDK' | ||
uses: google-github-actions/setup-gcloud@v0 | ||
- name: Set current project | ||
run: gcloud config set project ${{ secrets.FIREBASE_PROJECT_ID }} | ||
- name: Run Firebase Robo test | ||
run: gcloud firebase test android run | ||
--app app-release/app-release.apk | ||
--device model=oriole,version=33,locale=en,orientation=portrait | ||
--device model=redfin,version=30,locale=en,orientation=landscape | ||
--device model=x1q,version=29,locale=en,orientation=portrait | ||
--device model=phoenix_sprout,version=28,locale=en,orientation=portrait |