-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created a GitHub Action workflow for releasing Ninja Chat
- Loading branch information
1 parent
049f934
commit 233f9af
Showing
2 changed files
with
175 additions
and
2 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,173 @@ | ||
name: Ninja Chat Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
jobs: | ||
test: | ||
name: Run Tests | ||
runs-on: macos-latest | ||
|
||
strategy: | ||
matrix: | ||
api-level: [ 26, 34 ] | ||
target: [ default, google_apis ] | ||
|
||
steps: | ||
- name: Checkout the code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: 17 | ||
distribution: 'temurin' | ||
cache: 'gradle' | ||
|
||
- name: Save google-services.json | ||
env: | ||
GOOGLE_SERVICES: ${{ secrets.GOOGLE_SERVICES }} | ||
run: echo "$GOOGLE_SERVICES" > google-services.json | ||
|
||
- name: Unit Tests | ||
run: ./gradlew -Pci --console=plain testConversationsFreeDebugUnitTest | ||
|
||
# Only upload the reports on failure | ||
- name: Upload Reports | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: Test-Reports | ||
path: build/reports | ||
if: failure() | ||
|
||
bumpVersion: | ||
needs: test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
ref: ninja-master | ||
|
||
- name: Extract version from tag | ||
uses: damienaicheh/[email protected] | ||
|
||
- name: Extract existing version code | ||
run: | | ||
# Set new version name from tag | ||
if [[ -z "${{ env.PATCH }}" ]]; then | ||
version_name=${{ env.MAJOR }}.${{ env.MINOR }} | ||
else | ||
version_name=${{ env.MAJOR }}.${{ env.MINOR }}.${{ env.PATCH }} | ||
fi | ||
# Get existing version code from build.gradle | ||
version_code=$(grep "versionCode " build.gradle | awk '{print $2}' | tr -d '\n') | ||
# Increment existing version code by 1 | ||
version_code=$((version_code + 1)) | ||
# Set environment variable for later use | ||
echo "VERSION_NAME=$version_name" >> $GITHUB_ENV | ||
echo "VERSION_CODE=$version_code" >> $GITHUB_ENV | ||
- name: Increase version code and change version name | ||
run: | | ||
# Update build.gradle with new version code and name | ||
echo "${{ env.VERSION_CODE }} - ${{ env.VERSION_NAME }}" | ||
sed -i "s/versionCode [0-9]\+/versionCode ${{ env.VERSION_CODE }}/g" build.gradle | ||
sed -i "s/versionName \"[^\"]*\"/versionName \"${{ env.VERSION_NAME }}\"/g" build.gradle | ||
- name: Commit and push changes | ||
run: | | ||
git config user.email "[email protected]" | ||
git config user.name "Github Actions" | ||
git add . | ||
git commit -am "Bump version code and change version name to ${{ env.VERSION_NAME }}" | ||
git push origin ninja-master | ||
buildRelease: | ||
needs: bumpVersion | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout the code | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: develop | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: 17 | ||
distribution: 'temurin' | ||
cache: 'gradle' | ||
|
||
- name: Save Keystore | ||
env: | ||
KEYSTORE_FILE: ${{ secrets.KEYSTORE_FILE }} | ||
run: echo $KEYSTORE_FILE | base64 -d > my.keystore | ||
|
||
- name: Save google-services.json | ||
env: | ||
GOOGLE_SERVICES: ${{ secrets.GOOGLE_SERVICES }} | ||
run: echo "$GOOGLE_SERVICES" > google-services.json | ||
|
||
- name: Build Release APK | ||
env: | ||
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} | ||
KEY_ALIAS: ${{ secrets.KEY_ALIAS }} | ||
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} | ||
run: ./gradlew assembleRegularRelease | ||
-Pandroid.injected.signing.store.file=$(pwd)/my.keystore | ||
-Pandroid.injected.signing.store.password=$KEYSTORE_PASSWORD | ||
-Pandroid.injected.signing.key.alias=$KEY_ALIAS | ||
-Pandroid.injected.signing.key.password=$KEY_PASSWORD | ||
|
||
- name: Get base name | ||
run: | | ||
echo "base_name=`./gradlew properties -q | grep 'archivesBaseName:' | awk '{print $2}'`" >> $GITHUB_ENV | ||
echo ${{ env.base_name }} | ||
- name: Upload Release APK | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: Ninja Chat Release APK | ||
path: build/outputs/apk/conversationsFree/release/${{ env.base_name }}-conversations-free-arm64-v8a-release.apk | ||
|
||
- name: Build Release Bundle | ||
env: | ||
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} | ||
KEY_ALIAS: ${{ secrets.KEY_ALIAS }} | ||
KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} | ||
run: ./gradlew bundleConversationsFreeRelease | ||
-Pandroid.injected.signing.store.file=$(pwd)/my.keystore | ||
-Pandroid.injected.signing.store.password=$KEYSTORE_PASSWORD | ||
-Pandroid.injected.signing.key.alias=$KEY_ALIAS | ||
-Pandroid.injected.signing.key.password=$KEY_PASSWORD | ||
|
||
- name: Create a Release in GitHub | ||
uses: ncipollo/release-action@v1 | ||
with: | ||
artifacts: "build/outputs/apk/conversationsFree/release/*arm64-v8a-release.apk" | ||
token: ${{ secrets.GH_TOKEN }} | ||
tag: ${{ steps.version.outputs.content }} | ||
commit: ${{ github.sha }} | ||
generateReleaseNotes: true | ||
draft: true | ||
|
||
- name: Release app to internal track | ||
uses: r0adkll/upload-google-play@v1 | ||
with: | ||
serviceAccountJsonPlainText: ${{ secrets.PLAYSTORE_ACCOUNT_KEY }} | ||
packageName: com.ninja.chat | ||
releaseFiles: build/outputs/bundle/conversationsFreeRelease/${{ env.base_name }}-conversations-free-release.aab | ||
track: internal | ||
status: completed |