Skip to content

Commit

Permalink
ci: automatic build, test and release
Browse files Browse the repository at this point in the history
  • Loading branch information
magicsk committed Jul 17, 2022
1 parent f4fdfb2 commit fd4abb4
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 10 deletions.
13 changes: 3 additions & 10 deletions .github/tag-changelog-config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const DEFAULT_CONFIG = {
module.exports = {
types: [
{ types: ["feat", "feature"], label: "Features" },
{ types: ["fix", "bugfix"], label: "Bugfixes" },
Expand All @@ -19,20 +19,13 @@ const DEFAULT_CONFIG = {
let text = `\n## ${label}\n`;

commits.forEach((commit) => {
const scope = commit.scope ? `**${commit.scope}:** ` : "";
text += `- ${scope}${commit.subject}\n`;
text += `- ${commit.subject}\n`;
});

return text;
},

renderNotes: function (notes) {
return "";
},

renderChangelog: function (release, changes) {
return changes;
},
};

module.exports = DEFAULT_CONFIG;
};
100 changes: 100 additions & 0 deletions .github/workflows/android.yml
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

0 comments on commit fd4abb4

Please sign in to comment.