Skip to content

Release / Staging workflow #1

Release / Staging workflow

Release / Staging workflow #1

Workflow file for this run

name: Release / Staging workflow
on:
workflow_dispatch:
inputs:
JWT_SIGNATURE:
description: 'JWT Signature'
required: true
domain_URL:
description: 'Domain URL'
required: true
default: https://attendancebackend-v9zk.onrender.com
APP_VERSION:
description: 'Release Number'
required: true
VERSION_NAME:
description: 'Version name'
required: true
SKIP_DEVELOPER_MODE_CHECK:
description: 'Skip Developer Mode Check'
default: 'false'
type: choice
options:
- 'false'
- 'true'
RELEASE_TYPE:
description: 'Release Type RELEASE|STAGING'
required: true
default: 'RELEASE'
type: choice
options:
- RELEASE
- STAGING
jobs:
build_android:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Node.js environment
uses: actions/setup-node@v2
with:
node-version: '20'
- name: Install dependencies
run: |
yarn install
- name: Setting Secrets
run: |
echo "" >> .env
echo "JWT_SIGNATURE=${{ github.event.inputs.JWT_SIGNATURE }}" >> .env
echo "domain_URL=${{ github.event.inputs.domain_URL }}" >> .env
echo "APP_VERSION=${{ github.event.inputs.APP_VERSION }}" >> .env
echo "VERSION_NAME=${{ github.event.inputs.VERSION_NAME }}" >> .env
echo "SKIP_DEVELOPER_MODE_CHECK=${{ github.event.inputs.SKIP_DEVELOPER_MODE_CHECK }}" >> .env
sed -i "s/{Your app secret here}/${{ secrets.CODE_PUSH_APP_SECRET }}/" "./android/app/src/main/assets/appcenter-config.json"
if [[ "${{ github.event.inputs.RELEASE_TYPE }}" == "RELEASE" ]]; then
sed -i "s/{Your Deployment Key}/${{ secrets.CODE_PUSH_DEPLOYMENT_KEY_PRODUCTION }}/" "./android/app/src/main/res/values/strings.xml"
elif [[ "${{ github.event.inputs.RELEASE_TYPE }}" == "STAGING" ]]; then
sed -i "s/{Your Deployment Key}/${{ secrets.CODE_PUSH_DEPLOYMENT_KEY_STAGING }}/" "./android/app/src/main/res/values/strings.xml"
else
echo "Invalid RELEASE_TYPE. Supported values are RELEASE, STAGING."
exit 1
fi
sh ./setup/run.sh
- name: Build Android release
run: |
cd android
./gradlew assembleRelease
- name: Convert RELEASE_TYPE to lowercase
id: convert_release_type
run: |
echo "RELEASE_TYPE_LOWER=$(echo "${{ github.event.inputs.RELEASE_TYPE }}" | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.event.inputs.APP_VERSION }}
release_name: v${{ github.event.inputs.APP_VERSION }} ${{ env.RELEASE_TYPE_LOWER }}
draft: false
prerelease: false
- name: Upload Release to GitHub
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: README.md
asset_name: app-${{ env.RELEASE_TYPE_LOWER }}.apk
asset_content_type: application/apk