Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: updated ga scripts to upload apks #2314

Merged
merged 1 commit into from
Jan 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 0 additions & 38 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
name: Build

on:
push:
branches:
- master
pull_request:
branches:
- master
- development

jobs:
build:

runs-on: ubuntu-latest

steps:
Expand All @@ -27,37 +23,3 @@ jobs:
- name: Build with Gradle
run: |
bash ./gradlew build --stacktrace
bash ./gradlew bundle --stacktrace

- name: Upload APK
uses: actions/upload-artifact@v2
with:
name: pslab-android-apk
path: |
app/build/outputs/apk/debug/app-debug.apk
app/build/outputs/apk/release/app-release-unsigned.apk

- name: Download Artifact
uses: actions/download-artifact@v2
with:
name: pslab-android-apk

- name: Add APK files to apk branch
if: github.ref=='refs/heads/master'
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git stash
git switch --orphan temp
git push origin --delete apk
git branch -m apk
git config user.name github-actions
git config user.email github-actions@github.com
git add app/build/outputs/bundle/debug/app-debug.aab
git add app/build/outputs/bundle/release/app-release.aab
git add debug/app-debug.apk
git add release/app-release-unsigned.apk
git commit -m "Updated Build"
git push origin apk --force


109 changes: 109 additions & 0 deletions .github/workflows/push-event.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Push

on:
push:
branches:
- master
- development

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
build:
runs-on: ubuntu-latest
outputs:
branch: ${{ steps.branch-name.outputs.current_branch }}

steps:
- name: Download repository
uses: actions/checkout@v2

- name: Setup Java
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '11'

- name: Build with Gradle
run: |
bash ./gradlew build --stacktrace
bash ./gradlew bundle --stacktrace

- name: Store APK files
uses: actions/upload-artifact@v2
with:
name: apk-files
path: |
app/build/outputs/apk/debug/app-debug.apk
app/build/outputs/apk/release/app-release-unsigned.apk
app/build/outputs/bundle/debug/app-debug.aab
app/build/outputs/bundle/release/app-release.aab

- name: Define branch
id: branch-name
run: echo "::set-output name=current_branch::${{ github.ref_name }}"

upload:
needs: build
runs-on: ubuntu-latest

steps:
- name: Clone APK branch
uses: actions/checkout@v2
with:
repository: fossasia/pslab-android
ref: apk

- name: Clean APK branch for master builds
if: ${{ needs.build.outputs.branch == 'master' }}
run: |
rm -rf app-debug-master.apk || true
rm -rf app-release-unsigned-master.apk || true
rm -rf app-debug-master.aab || true
rm -rf app-release-master.aab || true

- name: Clean APK branch for development builds
if: ${{ needs.build.outputs.branch == 'development' }}
run: |
rm -rf app-debug-development.apk || true
rm -rf app-release-unsigned-development.apk || true
rm -rf app-debug-development.aab || true
rm -rf app-release-development.aab || true

- name: Retrieve APK files
uses: actions/download-artifact@v2
with:
name: apk-files

- name: Rename files in master branch
if: ${{ needs.build.outputs.branch == 'master' }}
run: |
mv apk/debug/app-debug.apk app-debug-master.apk
mv apk/release/app-release-unsigned.apk app-release-unsigned-master.apk
mv bundle/debug/app-debug.aab app-debug-master.aab
mv bundle/release/app-release.aab app-release-master.aab

- name: Rename files in development branch
if: ${{ needs.build.outputs.branch == 'development' }}
run: |
mv apk/debug/app-debug.apk app-debug-development.apk
mv apk/release/app-release-unsigned.apk app-release-unsigned-development.apk
mv bundle/debug/app-debug.aab app-debug-development.aab
mv bundle/release/app-release.aab app-release-development.aab

- name: Setup credentials
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'

- name: Update APK branch
run: |
git remote set-url --push origin https://github-actions[bot]:$GITHUB_TOKEN@github.com/${GITHUB_REPOSITORY}
git checkout --orphan temporary
git add .
git commit -m "release: build files from ${{ needs.build.outputs.branch }} branch"
git branch -D apk
git branch -m apk
git push origin apk -f --quiet > /dev/null