diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..177658b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,48 @@ +name: Release Version + +on: + push: + branches: + - release + +jobs: + bump-and-tag: + runs-on: ubuntu-latest + + permissions: + contents: write + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Bump Version + run: | + FILE=version.properties + + source $FILE + + NEW_CODE=$((VERSION_CODE + 1)) + + IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION_NAME" + NEW_PATCH=$((PATCH + 1)) + NEW_NAME="$MAJOR.$MINOR.$NEW_PATCH" + + echo "VERSION_CODE=$NEW_CODE" > $FILE + echo "VERSION_NAME=$NEW_NAME" >> $FILE + + echo "New Version: $NEW_NAME ($NEW_CODE)" + + - name: Commit changes + run: | + git config user.name "github-actions" + git config user.email "github-actions@github.com" + git add version.properties + git commit -m "Release: bump version" + git push + + - name: Create Git Tag + run: | + source version.properties + git tag "v$VERSION_NAME" + git push origin "v$VERSION_NAME" diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 6419b24..cb16ab1 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -16,6 +16,10 @@ android { namespace = "com.byteutility.dev.leetcode.plus" compileSdk = 35 + val versionPropsFile = rootProject.file("version.properties") + val versionProps = Properties() + versionProps.load(FileInputStream(versionPropsFile)) + // Load local properties val localPropertiesFile = rootProject.file("local.properties") val localProperties = Properties() @@ -34,8 +38,8 @@ android { applicationId = "com.byteutility.dev.leetcode.plus" minSdk = 29 targetSdk = 35 - versionCode = 15 - versionName = "1.1.4" + versionCode = versionProps["VERSION_CODE"].toString().toInt() + versionName = versionProps["VERSION_NAME"].toString() testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } diff --git a/version.properties b/version.properties new file mode 100644 index 0000000..7ec739d --- /dev/null +++ b/version.properties @@ -0,0 +1,2 @@ +VERSION_CODE=15 +VERSION_NAME=1.1.4