Skip to content

Commit

Permalink
gradle build now reads version name and code from environment variabl…
Browse files Browse the repository at this point in the history
…es, of present

release workflow now runs weekly, other than manually
  • Loading branch information
stefanosiano committed Nov 7, 2024
1 parent 5f216d6 commit 4f76580
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 5 deletions.
33 changes: 31 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
name: Release
on:
workflow_dispatch:
inputs:
version_name:
description: 'The version name to release. E.g. 24.12.31'
required: true
default: null
version_code:
description: 'The version code (numeric) to release. E.g. 241231'
required: true
default: null
schedule:
- cron: "0 0 * * 0" # Runs every Sunday at midnight

jobs:
empower-plant-release:
Expand All @@ -16,8 +27,26 @@ jobs:
distribution: 'temurin'
java-version: '17'

- name: Run Deploy Script
run: ./deploy_project.sh
- name: Setup Automatic Version Name And Code
if: inputs.version_name == null
run: |
echo "VERSION_NAME=$(date +'%y.%m.%d')" >> $GITHUB_ENV
echo "VERSION_CODE=$(date +'%y%m%d')" >> $GITHUB_ENV
shell: sh

- name: Run Deploy Script (manual version)
if: inputs.version_name != null
run: ./deploy_project.sh ${{ inputs.version_name }}
shell: sh
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
VERSION_NAME: ${{ inputs.version_name }}
VERSION_CODE: ${{ inputs.version_code }}

- name: Run Deploy Script (automatic version)
if: inputs.version_name == null
run: ./deploy_project.sh "$(date +'%y.%m.%d')"
shell: sh
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ android {
applicationId "com.example.vu.android"
minSdkVersion 21
targetSdkVersion 29
versionCode 48
versionName "2.11.3"
versionCode System.getenv('VERSION_CODE')?.toInteger() ?: 48
versionName System.getenv('VERSION_NAME') ?: "2.11.3"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
externalNativeBuild {
Expand Down
6 changes: 5 additions & 1 deletion deploy_project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ if ! command -v gh &> /dev/null; then
error_exit "gh is not installed, make sure you run 'make init' (see README.md)."
fi

# When this script is called from release workflow, the version is passed as an argument, otherwise it will be read from the app/build.gradle file
PACKAGE_VERSION=$1
if [ -z "$1" ]; then
PACKAGE_VERSION=$(grep 'versionName' app/build.gradle | awk -F\" {'print $2'})
fi
PACKAGE_NAME=$(grep 'applicationId' app/build.gradle | awk -F\" {'print $2'})
PACKAGE_VERSION=$(grep 'versionName' app/build.gradle | awk -F\" {'print $2'})
REPO=sentry-demos/android

# Check if current version was already released
Expand Down

0 comments on commit 4f76580

Please sign in to comment.