From 6d43e26c18ca53538e7a58df6b57768dae0d482a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaquim=20St=C3=A4hli?= Date: Wed, 26 Jul 2023 08:46:26 +0200 Subject: [PATCH] 186 improve release ci (#187) --- .github/workflows/code_quality.yml | 7 +- .github/workflows/nightly.yml | 83 +++++++++++ .github/workflows/publish-demo.yml | 50 ------- .github/workflows/publish-library.yml | 73 ---------- .github/workflows/publish-nightly.yml | 39 ------ .github/workflows/release.yml | 72 +++++++--- .github/workflows/run_tests.yml | 8 +- .github/workflows/snapshot.yml | 22 --- VERSION | 1 - buildSrc/src/main/java/VersionConfig.kt | 130 ++++-------------- pillarbox-analytics/build.gradle.kts | 2 +- pillarbox-core-business/build.gradle.kts | 2 +- pillarbox-demo/build.gradle.kts | 25 +++- .../src/debug/res/values/strings.xml | 7 +- .../demo/ui/examples/ExamplesHome.kt | 7 +- .../src/main/res/values/strings.xml | 2 +- .../src/nightly/res/values/strings.xml | 7 + .../src/nightlyDebug/res/values/strings.xml | 7 + pillarbox-player/build.gradle.kts | 2 +- pillarbox-ui/build.gradle.kts | 2 +- 20 files changed, 225 insertions(+), 323 deletions(-) create mode 100644 .github/workflows/nightly.yml delete mode 100644 .github/workflows/publish-demo.yml delete mode 100644 .github/workflows/publish-library.yml delete mode 100644 .github/workflows/publish-nightly.yml delete mode 100644 .github/workflows/snapshot.yml delete mode 100644 VERSION create mode 100644 pillarbox-demo/src/nightly/res/values/strings.xml create mode 100644 pillarbox-demo/src/nightlyDebug/res/values/strings.xml diff --git a/.github/workflows/code_quality.yml b/.github/workflows/code_quality.yml index 8cc936704..89ea9fb30 100644 --- a/.github/workflows/code_quality.yml +++ b/.github/workflows/code_quality.yml @@ -18,11 +18,12 @@ jobs: with: java-version: '17' distribution: 'temurin' + cache: 'gradle' - uses: reviewdog/action-setup@v1 - name: Run android linter uses: gradle/gradle-build-action@v2 with: - arguments: lint + arguments: lintProdDebug - name: review linter uses: dvdandroid/action-android-lint@master with: @@ -46,6 +47,7 @@ jobs: with: java-version: '17' distribution: 'temurin' + cache: 'gradle' - uses: reviewdog/action-setup@v1 - name: review detekt uses: alaegin/Detekt-Action@v1.22.0 @@ -75,7 +77,8 @@ jobs: with: java-version: '17' distribution: 'temurin' + cache: 'gradle' - name: Run android local unit test uses: gradle/gradle-build-action@v2 with: - arguments: testDebug + arguments: testProdDebug diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml new file mode 100644 index 000000000..817e63f57 --- /dev/null +++ b/.github/workflows/nightly.yml @@ -0,0 +1,83 @@ +# Run nightly every nights at midnight or when triggered manually +# https://github.com/orgs/community/discussions/27128 +name: Publish demo nightly + +on: + workflow_dispatch: + inputs: + version_name: + description: 'version name as xx.yy.zz-Optional' + required: true + type: string + schedule: + - cron: '0 0 * * 1,5' + +jobs: + check_date: + runs-on: ubuntu-latest + name: Check latest commit + outputs: + should_run: ${{ steps.should_run.outputs.should_run }} + + steps: + - uses: actions/checkout@v3 + - name: print latest_commit + run: echo ${{ github.sha }} + - id: should_run + continue-on-error: true + name: check latest commit is less than a day + if: ${{ github.event_name == 'schedule' }} + run: test -z $(git rev-list --after="24 hours" ${{ github.sha }}) && echo "should_run=false" >> "$GITHUB_OUTPUT" + + Build-nightly: + needs: check_date + if: ${{ needs.check_date.outputs.should_run != 'false' }} + runs-on: ubuntu-latest + env: + DEMO_KEY_PASSWORD: ${{ secrets.DEMO_KEY_PASSWORD }} + USERNAME: ${{ github.actor }} + GITHUB_TOKEN: ${{ github.token }} + + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 # Required due to the way Git works, without it this action won't be able to find any or the correct tags + - name: VERSION_NAME from inputs + if: ${{ github.event_name == 'workflow_dispatch' }} + run: | + echo "VERSION_NAME=${{ inputs.version_name }}" >> "$GITHUB_ENV" + - name: Find latest tag + if: ${{ github.event_name != 'workflow_dispatch' }} + id: previoustag + uses: "WyriHaximus/github-action-get-previous-tag@v1" + with: + fallback: 0.0.1-alpha01 # Optional fallback tag to use when no tag can be found + - name: Setup VERSION_NAME from latest git tag + if: ${{ github.event_name != 'workflow_dispatch' }} + run: | + echo "VERSION_NAME=${{ steps.previoustag.outputs.tag }}" >> "$GITHUB_ENV" + - name: Print VersionName + run: | + echo "Version name is ${{ env.VERSION_NAME }}" + echo "ref ${GITHUB_REF}" + echo "refname ${GITHUB_REF_NAME}" + echo "refname ${GITHUB_REF_TYPE}" + echo "CI ${{ env.CI }}" + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + cache: 'gradle' + - name: Build with Gradle + uses: gradle/gradle-build-action@v2.3.3 + with: + arguments: assembleNightlyRelease + - name: upload artifact to Firebase App Distribution + uses: wzieba/Firebase-Distribution-Github-Action@v1 + with: + appId: ${{ secrets.NIGHTLY_APP_ID }} + serviceCredentialsFileContent: ${{ secrets.FIREBASE_CREDENTIAL_FILE_CONTENT }} + groups: ${{ secrets.NIGHTLY_GROUPS }} + file: pillarbox-demo/build/outputs/apk/nightly/release/pillarbox-demo-nightly-release.apk + diff --git a/.github/workflows/publish-demo.yml b/.github/workflows/publish-demo.yml deleted file mode 100644 index 47be63ac6..000000000 --- a/.github/workflows/publish-demo.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: Build & upload to Firebase App Distribution - -on: - workflow_call: - inputs: - isSnapshot: - required: false - default: false - type: boolean - secrets: - KEY_PASSWORD: - required: true - FIREBASE_CREDENTIAL_FILE_CONTENT: - required: true - FIREBASE_GROUP: - required: true - FIREBASE_APP_ID: - required: true - -permissions: read-all - -jobs: - build: - - runs-on: ubuntu-latest - env: - DEMO_KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} - IS_SNAPSHOT: ${{ inputs.isSnapshot }} - BRANCH_NAME: ${{ github.head_ref || github.ref_name }} - USERNAME: ${{ github.actor }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - steps: - - uses: actions/checkout@v3 - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'temurin' - - name: Build with Gradle - uses: gradle/gradle-build-action@v2.3.3 - with: - arguments: assembleRelease - - name: upload artifact to Firebase App Distribution - uses: wzieba/Firebase-Distribution-Github-Action@v1 - with: - appId: ${{ secrets.FIREBASE_APP_ID }} - serviceCredentialsFileContent: ${{ secrets.FIREBASE_CREDENTIAL_FILE_CONTENT }} - groups: ${{ secrets.FIREBASE_GROUP }} - file: pillarbox-demo/build/outputs/apk/release/pillarbox-demo-release.apk diff --git a/.github/workflows/publish-library.yml b/.github/workflows/publish-library.yml deleted file mode 100644 index 95a1307ec..000000000 --- a/.github/workflows/publish-library.yml +++ /dev/null @@ -1,73 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. -# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created -# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle -# https://github.com/marketplace/actions/tag-and-release - -name: Build & publish - -on: - workflow_call: - inputs: - isSnapshot: - required: false - default: false - type: boolean -jobs: - build: - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - env: - DEMO_KEY_PASSWORD: ${{ secrets.DEMO_KEY_PASSWORD }} - DEMO_KEY_ALIAS: ${{ secrets.DEMO_KEY_ALIAS }} - - steps: - - uses: actions/checkout@v3 - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'temurin' - server-id: github # Value of the distributionManagement/repository/id field of the pom.xml - settings-path: ${{ github.workspace }} # location for the settings.xml file - - - name: Build with Gradle - uses: gradle/gradle-build-action@v2.3.3 - with: - arguments: build - - # the publishing section of your build.gradle - - name: Publish to GitHub Packages - uses: gradle/gradle-build-action@v2.3.3 - with: - arguments: publish - env: - USERNAME: ${{ github.actor }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - IS_SNAPSHOT: ${{ inputs.isSnapshot }} - release: - if: inputs.isSnapshot == false - needs: build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Read version name - id: read_version - uses: juliangruber/read-file-action@v1 - with: - path: ./VERSION - - name: Echo - run: echo "${{ steps.read_version.outputs.content }}" - - name: Draft a release - id: make_release - uses: avakar/tag-and-release@v1 - with: - draft: true - prerelease: false - tag_name: ${{ steps.read_version.outputs.content }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/publish-nightly.yml b/.github/workflows/publish-nightly.yml deleted file mode 100644 index 4b29992a7..000000000 --- a/.github/workflows/publish-nightly.yml +++ /dev/null @@ -1,39 +0,0 @@ -# Run nightly every nights at midnight or when triggered manually -# https://github.com/orgs/community/discussions/27128 -name: Publish demo nightly - -on: - workflow_dispatch: - schedule: - - cron: '0 0 * * 1,5' - -jobs: - check_date: - runs-on: ubuntu-latest - name: Check latest commit - outputs: - should_run: ${{ steps.should_run.outputs.should_run }} - steps: - - uses: actions/checkout@v3 - - name: print latest_commit - run: echo ${{ github.sha }} - - id: should_run - continue-on-error: true - name: check latest commit is less than a day - if: ${{ github.event_name == 'schedule' }} - run: test -z $(git rev-list --after="24 hours" ${{ github.sha }}) && echo "::set-output name=should_run::false" - - Build-nightly: - needs: check_date - if: ${{ needs.check_date.outputs.should_run != 'false' }} - name: Publish to firebase - uses: ./.github/workflows/publish-demo.yml - with: - isSnapshot: true - secrets: - KEY_PASSWORD: ${{ secrets.DEMO_KEY_PASSWORD }} - FIREBASE_CREDENTIAL_FILE_CONTENT: ${{ secrets.FIREBASE_CREDENTIAL_FILE_CONTENT }} - FIREBASE_GROUP: ${{ secrets.NIGHTLY_GROUPS }} - FIREBASE_APP_ID: ${{ secrets.NIGHTLY_APP_ID }} - - diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1200611e6..0c435a417 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,19 +1,59 @@ name: Release Pillarbox on: - workflow_dispatch: - + push: + # Pattern matched against refs/tags + tags: + - '[0-9]+.[0-9].[0-9]' + - '[0-9]+.[0-9].[0-9]-[0-9a-zA-Z]+' jobs: - PublishRelease: - name: Build and upload library to Github packages - uses: ./.github/workflows/publish-library.yml - with: - isSnapshot: false - secrets: inherit - UploadDemo: - name: Upload Demo to Firebase AppDistribution - uses: ./.github/workflows/publish-demo.yml - secrets: - KEY_PASSWORD: ${{ secrets.DEMO_KEY_PASSWORD }} - FIREBASE_CREDENTIAL_FILE_CONTENT: ${{ secrets.FIREBASE_CREDENTIAL_FILE_CONTENT }} - FIREBASE_GROUP: ${{ secrets.RELEASE_GROUPS }} - FIREBASE_APP_ID: ${{ secrets.RELEASE_APP_ID }} + build: + runs-on: ubuntu-latest + env: + DEMO_KEY_PASSWORD: ${{ secrets.DEMO_KEY_PASSWORD }} + USERNAME: ${{ github.actor }} + GITHUB_TOKEN: ${{ github.token }} + VERSION_NAME: ${{ github.ref_name }} + + steps: + - uses: actions/checkout@v3 + - name: Check if pre release tag + id: check-tag + run: | + if [[ "${GITHUB_REF_NAME}" =~ [0-9]+.[0-9].[0-9]-[0-9a-zA-Z]+ ]]; then + echo "prerelease=true" >> $GITHUB_OUTPUT + fi + - name: Print release tag + run: | + echo "tag = ${GITHUB_REF_NAME}" + echo "version_name = ${VERSION_NAME}" + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + cache: 'gradle' + server-id: github # Value of the distributionManagement/repository/id field of the pom.xml + settings-path: ${{ github.workspace }} # location for the settings.xml file + # the publishing section of your build.gradle + - name: Publish to GitHub Packages + uses: gradle/gradle-build-action@v2.3.3 + with: + arguments: publish + - name: Build with Gradle + uses: gradle/gradle-build-action@v2.3.3 + with: + arguments: assembleProdRelease + - name: upload artifact to Firebase App Distribution + uses: wzieba/Firebase-Distribution-Github-Action@v1 + with: + appId: ${{ secrets.RELEASE_APP_ID }} + serviceCredentialsFileContent: ${{ secrets.FIREBASE_CREDENTIAL_FILE_CONTENT }} + groups: ${{ secrets.RELEASE_GROUPS }} + file: pillarbox-demo/build/outputs/apk/prod/release/pillarbox-demo-prod-release.apk + - name: Create Github release + uses: ncipollo/release-action@v1 + with: + draft: true + prerelease: steps.check-tag.outputs.prerelease == 'true' + skipIfReleaseExists: true + generateReleaseNotes: true diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index aebee5dff..d317ae6a2 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -28,10 +28,8 @@ jobs: distribution: temurin java-version: 17 cache: 'gradle' - - name: Setup and execute Gradle 'buildDebug' task + - name: Gradle cache uses: gradle/gradle-build-action@v2 - with: - arguments: buildDebug - name: AVD cache uses: actions/cache@v3 id: avd-cache @@ -42,7 +40,7 @@ jobs: key: avd-26 - name: create AVD and generate snapshot for caching if: steps.avd-cache.outputs.cache-hit != 'true' - uses: reactivecircus/android-emulator-runner@v2 + uses: reactivecircus/android-emulator-runner@v2.28.0 with: api-level: 26 force-avd-creation: false @@ -50,7 +48,7 @@ jobs: disable-animations: false script: echo "Generated AVD snapshot for caching." - name: run tests - uses: reactivecircus/android-emulator-runner@v2 + uses: reactivecircus/android-emulator-runner@v2.28.0 with: api-level: 26 force-avd-creation: false diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml deleted file mode 100644 index 4a16ff033..000000000 --- a/.github/workflows/snapshot.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Snapshot Pillarbox -on: - workflow_dispatch: - -jobs: - PublishSnapshot: - name: Build and upload library to Github packages - uses: ./.github/workflows/publish-library.yml - with: - isSnapshot: true - secrets: inherit - UploadDemo: - needs: PublishSnapshot - name: Upload Demo to Firebase AppDistribution - uses: ./.github/workflows/publish-demo.yml - with: - isSnapshot: true - secrets: - KEY_PASSWORD: ${{ secrets.DEMO_KEY_PASSWORD }} - FIREBASE_CREDENTIAL_FILE_CONTENT: ${{ secrets.FIREBASE_CREDENTIAL_FILE_CONTENT }} - FIREBASE_GROUP: ${{ secrets.NIGHTLY_GROUPS }} - FIREBASE_APP_ID: ${{ secrets.NIGHTLY_APP_ID }} diff --git a/VERSION b/VERSION deleted file mode 100644 index 267577d47..000000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.4.1 diff --git a/buildSrc/src/main/java/VersionConfig.kt b/buildSrc/src/main/java/VersionConfig.kt index 6f333f3d6..447d7d7c4 100644 --- a/buildSrc/src/main/java/VersionConfig.kt +++ b/buildSrc/src/main/java/VersionConfig.kt @@ -2,9 +2,6 @@ * Copyright (c) 2022. SRG SSR. All rights reserved. * License information is available from the LICENSE file. */ -import org.gradle.api.Project -import java.io.ByteArrayOutputStream -import java.io.File /** * VersionConfig will build @@ -12,127 +9,58 @@ import java.io.File * - Version for Libraries */ object VersionConfig { - private const val ENV_BRANCH_NAME = "BRANCH_NAME" - private const val ENV_IS_SNAPSHOT = "IS_SNAPSHOT" - private const val MAIN_BRANCH = "main" - private const val SNAPSHOT_SUFFIX = "SNAPSHOT" - /** - * Version Name from VERSION file, must contains only "major.minor.patch" text with only one line. + * Environement variable automatically set by Github actions. + * @see [github](https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables) */ - private val VERSION_NAME = (File("VERSION").readLines().firstOrNull() ?: "0.0.99").split(".").map { it.toInt() } - private val MAJOR = VERSION_NAME[0] // 0..99 - private val MINOR = VERSION_NAME[1] // 0..99 - private val PATCH = VERSION_NAME[2] // 0..99 + val isCI: Boolean = System.getenv("CI")?.toBooleanStrictOrNull() ?: false /** - * Maven artifact group + * Environement variable set by workflow. */ - const val GROUP = "ch.srgssr.pillarbox" + private val ENV_VERSION_NAME: String? = System.getenv("VERSION_NAME") + private val versionRegex = "[0-9]+.[0-9].[0-9]-?\\S*".toRegex() + private val versionOnlyRegex = "[0-9]+.[0-9].[0-9]".toRegex() + private val versionSuffixRegex = "-\\S*".toRegex() /** - * @return Version code build from MAJOR, MINOR and PATCH - *
-     *  Samples :
-     *  1.0.0 => 010000
-     *  1.0.1 => 010001
-     *  1.2.0 => 010200
-     *  1.80.40 => 018040
-     *  1.80.2 => 018002
-     *  32.12.67 => 321267
-     *  
+ * Maven artifact group */ - fun versionCode(): Int { - return MAJOR * 10000 + MINOR * 100 + PATCH - } + const val GROUP = "ch.srgssr.pillarbox" /** - * Release version name for Demo app and libraries - * - * @return [MAJOR].[MINOR].[PATCH] + * Semantic version + * @return Major.Minor.Patch string from [ENV_VERSION_NAME] or null if not set. */ - private fun getVersionName(): String { - return "$MAJOR.$MINOR.$PATCH" + fun semanticVersion(): String? { + return ENV_VERSION_NAME?.let { versionOnlyRegex.find(it)?.value } } /** - * Get version name with git branch + * Version name * - * @param suffix added to the end of the version name - * @return [MAJOR].[MINOR].[PATCH].[suffix] + * @return Local if [ENV_VERSION_NAME] no set. */ - private fun getVersionNameWithSuffix(suffix: String): String { - return "${getVersionName()}.$suffix" + fun versionName(): String { + return ENV_VERSION_NAME ?: "Local" } - /** - * if on main branch return $MAJOR.$MINOR.$PATCH - * else $MAJOR.$MINOR.{current git branch name} - * @return the a version name to set to the project + * @return -suffix from MARJOR.MINOR.PATCH-Suffix */ - fun getVersionNameFromProject(project: Project): String { - val gitBranch = gitBranch(project) - return if (isBranchMain(gitBranch)) { - getVersionName() - } else { - getVersionNameWithSuffix(gitBranch) - } + fun versionNameSuffix(): String? { + return ENV_VERSION_NAME?.let { versionSuffixRegex.find(it)?.value } } /** - * if on main branch and not a SNAPSHOT return $MAJOR.$MINOR.$PATCH - * else $MAJOR.$MINOR.{current git branch name}-SNAPSHOT - * @return the a version name to set to the project + * Version code + * It assumes that major.minor.patch each <= 99 + * 0.0.0, 0.0.99, 0.1.0, 0.99.99 */ - fun getLibraryVersionNameFromProject(project: Project): String { - val gitBranch = gitBranch(project) - return if (isSnapshot() || !isBranchMain(gitBranch)) { - val versionName = if (isBranchMain(gitBranch)) getVersionName() else getVersionNameWithSuffix(gitBranch) - "$versionName-$SNAPSHOT_SUFFIX" - } else { - getVersionName() - } - } - - /** - * Is snapshot - * - * @return true is environment variable "isSnapshot" is set to true - */ - @Suppress("MemberVisibilityCanBePrivate") - fun isSnapshot(): Boolean { - return System.getenv(ENV_IS_SNAPSHOT)?.toBoolean() ?: false - } - - /** - * Utility function to retrieve the name of the current git branch. - * If CI send a branch name we use it instead. - * Will not work if build tool detaches head after checkout, which some do! - * Useful for build trigger from github PR's - */ - private fun gitBranch(project: Project): String { - val ciBranch: String? = System.getenv(ENV_BRANCH_NAME) - if (ciBranch != null) { - return ciBranch - } - return try { - val byteOut = ByteArrayOutputStream() - project.exec { - commandLine = "git rev-parse --abbrev-ref HEAD".split(" ") - standardOutput = byteOut - } - String(byteOut.toByteArray()).trim().also { - if (it == "HEAD") - project.logger.warn("Unable to determine current branch: Project is checked out with detached head!") - } - } catch (e: Exception) { - project.logger.warn("Unable to determine current branch: ${e.message}") - "Unknown Branch" - } - } - - private fun isBranchMain(gitBranch: String): Boolean { - return gitBranch.contains(MAIN_BRANCH) + fun versionCode(): Int { + return semanticVersion()?.let { + val versions = it.split(".").map { value -> value.toInt() } + versions[0] * 10000 + versions[1] * 100 + versions[2] + } ?: 9999 } } diff --git a/pillarbox-analytics/build.gradle.kts b/pillarbox-analytics/build.gradle.kts index 351e447f8..62a35e20c 100644 --- a/pillarbox-analytics/build.gradle.kts +++ b/pillarbox-analytics/build.gradle.kts @@ -15,7 +15,7 @@ android { defaultConfig { minSdk = AppConfig.minSdk targetSdk = AppConfig.targetSdk - version = VersionConfig.getLibraryVersionNameFromProject(project) + version = VersionConfig.versionName() group = VersionConfig.GROUP buildConfigField("String", "BUILD_DATE", "\"${AppConfig.getBuildDate()}\"") diff --git a/pillarbox-core-business/build.gradle.kts b/pillarbox-core-business/build.gradle.kts index bf97d046b..cf24d83c4 100644 --- a/pillarbox-core-business/build.gradle.kts +++ b/pillarbox-core-business/build.gradle.kts @@ -16,7 +16,7 @@ android { defaultConfig { minSdk = AppConfig.minSdk targetSdk = AppConfig.targetSdk - version = VersionConfig.getLibraryVersionNameFromProject(project) + version = VersionConfig.versionName() group = VersionConfig.GROUP testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" diff --git a/pillarbox-demo/build.gradle.kts b/pillarbox-demo/build.gradle.kts index f4abb9862..bc5c6514b 100644 --- a/pillarbox-demo/build.gradle.kts +++ b/pillarbox-demo/build.gradle.kts @@ -9,15 +9,12 @@ plugins { android { compileSdk = AppConfig.compileSdk - defaultConfig { applicationId = "ch.srgssr.pillarbox.demo" minSdk = AppConfig.minSdk targetSdk = AppConfig.targetSdk versionCode = VersionConfig.versionCode() - versionName = VersionConfig.getVersionNameFromProject(project) - applicationIdSuffix = if (VersionConfig.isSnapshot()) ".nightly" else null - versionNameSuffix = if (VersionConfig.isSnapshot()) "-nightly" else null + versionName = VersionConfig.versionName() testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" vectorDrawables { useSupportLibrary = true @@ -47,6 +44,19 @@ android { "proguard-rules.pro" ) } + val versionDimension = "version" + flavorDimensions += versionDimension + productFlavors { + create("prod") { + + dimension = versionDimension + } + create("nightly") { + dimension = versionDimension + applicationIdSuffix = ".nightly" + versionNameSuffix = "-nightly" + } + } } compileOptions { sourceCompatibility = JavaVersion.VERSION_17 @@ -77,6 +87,13 @@ android { } } namespace = "ch.srgssr.pillarbox.demo" + + // Hide nightly flavors from BuildVariants in AndroidStudio + androidComponents { + beforeVariants { variant -> + variant.enable = VersionConfig.isCI || variant.flavorName != "nightly" + } + } } dependencies { diff --git a/pillarbox-demo/src/debug/res/values/strings.xml b/pillarbox-demo/src/debug/res/values/strings.xml index 95d736c06..4ea817bdd 100644 --- a/pillarbox-demo/src/debug/res/values/strings.xml +++ b/pillarbox-demo/src/debug/res/values/strings.xml @@ -1,8 +1,7 @@ - - - DebugPillarboxDemo - \ No newline at end of file + Pillarbox Demo Debug + diff --git a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/examples/ExamplesHome.kt b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/examples/ExamplesHome.kt index b887c292e..ae370e316 100644 --- a/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/examples/ExamplesHome.kt +++ b/pillarbox-demo/src/main/java/ch/srgssr/pillarbox/demo/ui/examples/ExamplesHome.kt @@ -24,6 +24,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp +import ch.srgssr.pillarbox.demo.BuildConfig import ch.srgssr.pillarbox.demo.data.DemoItem import ch.srgssr.pillarbox.demo.data.Playlist import ch.srgssr.pillarbox.demo.ui.player.SimplePlayerActivity @@ -63,7 +64,9 @@ private fun ListStreamView(playlistList: List, onItemClicked: (DemoIte .fillMaxWidth() ) { InsertContentView( - modifier = Modifier.fillMaxWidth().padding(6.dp), + modifier = Modifier + .fillMaxWidth() + .padding(6.dp), onItemClicked ) } @@ -76,6 +79,8 @@ private fun ListStreamView(playlistList: List, onItemClicked: (DemoIte } } } + Divider() + Text(text = BuildConfig.VERSION_NAME) } } diff --git a/pillarbox-demo/src/main/res/values/strings.xml b/pillarbox-demo/src/main/res/values/strings.xml index 0c4c0b809..bd20da7f0 100644 --- a/pillarbox-demo/src/main/res/values/strings.xml +++ b/pillarbox-demo/src/main/res/values/strings.xml @@ -3,7 +3,7 @@ ~ License information is available from the LICENSE file. --> - PillarboxDemo + Pillarbox Demo Examples Playlists Layouts diff --git a/pillarbox-demo/src/nightly/res/values/strings.xml b/pillarbox-demo/src/nightly/res/values/strings.xml new file mode 100644 index 000000000..04148fb09 --- /dev/null +++ b/pillarbox-demo/src/nightly/res/values/strings.xml @@ -0,0 +1,7 @@ + + + Pillarbox Demo Nightly + diff --git a/pillarbox-demo/src/nightlyDebug/res/values/strings.xml b/pillarbox-demo/src/nightlyDebug/res/values/strings.xml new file mode 100644 index 000000000..9dde5ab54 --- /dev/null +++ b/pillarbox-demo/src/nightlyDebug/res/values/strings.xml @@ -0,0 +1,7 @@ + + + Pillarbox Demo Nightly Debug + diff --git a/pillarbox-player/build.gradle.kts b/pillarbox-player/build.gradle.kts index 3c8d4d715..90b746064 100644 --- a/pillarbox-player/build.gradle.kts +++ b/pillarbox-player/build.gradle.kts @@ -16,7 +16,7 @@ android { defaultConfig { minSdk = AppConfig.minSdk targetSdk = AppConfig.targetSdk - version = VersionConfig.getLibraryVersionNameFromProject(project) + version = VersionConfig.versionName() group = VersionConfig.GROUP testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" diff --git a/pillarbox-ui/build.gradle.kts b/pillarbox-ui/build.gradle.kts index 4223fd39d..8f5bd13a4 100644 --- a/pillarbox-ui/build.gradle.kts +++ b/pillarbox-ui/build.gradle.kts @@ -16,7 +16,7 @@ android { defaultConfig { minSdk = AppConfig.minSdk targetSdk = AppConfig.targetSdk - version = VersionConfig.getLibraryVersionNameFromProject(project) + version = VersionConfig.versionName() group = VersionConfig.GROUP testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"