Skip to content

Commit 9d5ca8c

Browse files
authored
Merge pull request #157 from sentry-demos/feat/weekly-release
Release weekly automatically
2 parents 5f216d6 + e85b63a commit 9d5ca8c

File tree

3 files changed

+38
-5
lines changed

3 files changed

+38
-5
lines changed

.github/workflows/release.yml

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
name: Release
22
on:
33
workflow_dispatch:
4+
inputs:
5+
version_name:
6+
description: 'The version name to release. E.g. 24.12.31'
7+
required: true
8+
default: null
9+
version_code:
10+
description: 'The version code (numeric) to release. E.g. 241231'
11+
required: true
12+
default: null
13+
schedule:
14+
- cron: "0 0 1,8,15,22 * *" # 1st, 8th, 15th, and 22nd of the month
415

516
jobs:
617
empower-plant-release:
@@ -16,8 +27,26 @@ jobs:
1627
distribution: 'temurin'
1728
java-version: '17'
1829

19-
- name: Run Deploy Script
20-
run: ./deploy_project.sh
30+
- name: Setup Automatic Version Name And Code
31+
if: inputs.version_name == null
32+
run: |
33+
echo "VERSION_NAME=$(date +'%y.%m.%d')" >> $GITHUB_ENV
34+
echo "VERSION_CODE=$(date +'%y%m%d')" >> $GITHUB_ENV
35+
shell: sh
36+
37+
- name: Run Deploy Script (manual version)
38+
if: inputs.version_name != null
39+
run: ./deploy_project.sh ${{ inputs.version_name }}
40+
shell: sh
41+
env:
42+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
44+
VERSION_NAME: ${{ inputs.version_name }}
45+
VERSION_CODE: ${{ inputs.version_code }}
46+
47+
- name: Run Deploy Script (automatic version)
48+
if: inputs.version_name == null
49+
run: ./deploy_project.sh "$(date +'%y.%m.%d')"
2150
shell: sh
2251
env:
2352
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ android {
3838
applicationId "com.example.vu.android"
3939
minSdkVersion 21
4040
targetSdkVersion 29
41-
versionCode 48
42-
versionName "2.11.3"
41+
versionCode System.getenv('VERSION_CODE')?.toInteger() ?: 48
42+
versionName System.getenv('VERSION_NAME') ?: "2.11.3"
4343

4444
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
4545
externalNativeBuild {

deploy_project.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@ if ! command -v gh &> /dev/null; then
99
error_exit "gh is not installed, make sure you run 'make init' (see README.md)."
1010
fi
1111

12+
# 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
13+
PACKAGE_VERSION=$1
14+
if [ -z "$1" ]; then
15+
PACKAGE_VERSION=$(grep 'versionName' app/build.gradle | awk -F\" {'print $2'})
16+
fi
1217
PACKAGE_NAME=$(grep 'applicationId' app/build.gradle | awk -F\" {'print $2'})
13-
PACKAGE_VERSION=$(grep 'versionName' app/build.gradle | awk -F\" {'print $2'})
1418
REPO=sentry-demos/android
1519

1620
# Check if current version was already released

0 commit comments

Comments
 (0)