diff --git a/.github/workflows/deployNewCore.yml b/.github/workflows/deployNewCore.yml index e70bbe5d..ae528f7f 100644 --- a/.github/workflows/deployNewCore.yml +++ b/.github/workflows/deployNewCore.yml @@ -1,24 +1,568 @@ -name: Build & upload the debug package -# Trigger on every tag creation +name: Build & Publish Changed Modules + on: push: branches: - 'new_core' -# A workflow run is made up of one or more jobs that can run sequentially or in parallel + paths-ignore: + - 'samples/**' + - 'core/sample/**' + - 'ui/sample/**' + - '**.md' + - '.gitignore' + +env: + VERSION_SUFFIX: "-alpha" + MAVEN_REPO: "https://maven.pkg.github.com/Meta-CTO/coreapp" + jobs: - build: + # ============================================ + # DETECT CHANGES + # ============================================ + detect-changes: + runs-on: ubuntu-latest + outputs: + core: ${{ steps.changes.outputs.core }} + coreui: ${{ steps.changes.outputs.coreui }} + files: ${{ steps.changes.outputs.files }} + notifications: ${{ steps.changes.outputs.notifications }} + phonecore: ${{ steps.changes.outputs.phonecore }} + camera: ${{ steps.changes.outputs.camera }} + mediaplayers: ${{ steps.changes.outputs.mediaplayers }} + youtube: ${{ steps.changes.outputs.youtube }} + phoneui: ${{ steps.changes.outputs.phoneui }} + imagepicker: ${{ steps.changes.outputs.imagepicker }} + buildsrc: ${{ steps.changes.outputs.buildsrc }} + any_module: ${{ steps.changes.outputs.any_module }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Detect changed modules + id: changes + run: | + # Get changed files between current and previous commit + CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD 2>/dev/null || git diff --name-only HEAD) + echo "Changed files:" + echo "$CHANGED_FILES" + echo "" + + # Check buildSrc changes (triggers all modules) + BUILDSRC_CHANGED=$(echo "$CHANGED_FILES" | grep -q '^buildSrc/' && echo 'true' || echo 'false') + echo "buildsrc=$BUILDSRC_CHANGED" >> $GITHUB_OUTPUT + + # Detect per-module changes + detect_module() { + local module_name=$1 + local path_pattern=$2 + local changed=$(echo "$CHANGED_FILES" | grep -qE "$path_pattern" && echo 'true' || echo 'false') + # If buildSrc changed, mark all modules as changed + if [ "$BUILDSRC_CHANGED" = "true" ]; then + changed="true" + fi + echo "$module_name=$changed" >> $GITHUB_OUTPUT + echo "$module_name: $changed" + } + + detect_module "core" "^core/core/" + detect_module "coreui" "^ui/core-ui/" + detect_module "files" "^core/files/" + detect_module "notifications" "^core/notifications/" + detect_module "phonecore" "^core/phone-core/" + detect_module "camera" "^ui/camera/" + detect_module "mediaplayers" "^ui/media-players/" + detect_module "youtube" "^ui/youtube/" + detect_module "phoneui" "^ui/phone-ui/" + detect_module "imagepicker" "^ui/image-picker/" + + # Check if any module changed + if [ "$BUILDSRC_CHANGED" = "true" ] || echo "$CHANGED_FILES" | grep -qE '^(core/(core|files|notifications|phone-core)|ui/(core-ui|camera|media-players|youtube|phone-ui|image-picker))/'; then + echo "any_module=true" >> $GITHUB_OUTPUT + else + echo "any_module=false" >> $GITHUB_OUTPUT + fi + + # ============================================ + # PUBLISH: CORE + # ============================================ + publish-core: + needs: detect-changes + if: needs.detect-changes.outputs.core == 'true' + runs-on: macos-latest + permissions: + contents: write + packages: write + outputs: + version: ${{ steps.version.outputs.version }} + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: 'temurin' + - name: Cache Gradle + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + - name: Cache Konan + uses: actions/cache@v4 + with: + path: | + ~/.konan/caches + ~/.konan/dependencies + ~/.konan/kotlin-native-prebuilt-macos-* + key: ${{ runner.os }}-konan-${{ hashFiles('**/Dependencies.kt') }} + restore-keys: | + ${{ runner.os }}-konan- + - name: Get latest version from Maven + id: version + env: + GH_TOKEN: ${{ secrets.PUBLISH_REPO_TOKEN }} + run: | + # Query GitHub Packages API for latest version + PACKAGE_NAME="com.metacto.kmm.core" + + # Get versions from GitHub Packages + VERSIONS=$(gh api /orgs/Meta-CTO/packages/maven/$PACKAGE_NAME/versions --jq '.[].name' 2>/dev/null || echo "") + + if [ -z "$VERSIONS" ]; then + # No versions found, start with base version from catalog + CURRENT_VERSION=$(grep 'metacto-core = "' gradle/libs.versions.toml | head -1 | sed 's/.*= "\([^"]*\)".*/\1/') + echo "No published versions found, using catalog version: $CURRENT_VERSION" + else + # Get the latest alpha version + CURRENT_VERSION=$(echo "$VERSIONS" | grep -E '^[0-9]+\.[0-9]+\.[0-9]+-alpha$' | sort -V | tail -1) + if [ -z "$CURRENT_VERSION" ]; then + CURRENT_VERSION=$(grep 'metacto-core = "' gradle/libs.versions.toml | head -1 | sed 's/.*= "\([^"]*\)".*/\1/') + fi + echo "Latest published version: $CURRENT_VERSION" + fi + + # Parse and increment version + VERSION_BASE=$(echo "$CURRENT_VERSION" | sed 's/-[^-]*$//') + MAJOR=$(echo "$VERSION_BASE" | cut -d. -f1) + MINOR=$(echo "$VERSION_BASE" | cut -d. -f2) + PATCH=$(echo "$VERSION_BASE" | cut -d. -f3) + + # Validate parsing + if [ -z "$PATCH" ]; then + echo "ERROR: Failed to parse version. CURRENT_VERSION=$CURRENT_VERSION" + exit 1 + fi + + NEW_PATCH=$((PATCH + 1)) + NEW_VERSION="${MAJOR}.${MINOR}.${NEW_PATCH}${{ env.VERSION_SUFFIX }}" + + echo "New version: $NEW_VERSION" + echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT + - name: Update properties files + env: + PUBLISH_REPO_USER: ${{ secrets.PUBLISH_REPO_USER }} + PUBLISH_REPO_TOKEN: ${{ secrets.PUBLISH_REPO_TOKEN }} + run: | + # Update local.properties for credentials + echo "PUBLISH_REPO_USER=$PUBLISH_REPO_USER" > ./local.properties + echo "PUBLISH_REPO_TOKEN=$PUBLISH_REPO_TOKEN" >> ./local.properties + # Update versions.properties - this is what Gradle reads for the actual version + echo "PUBLISH_CORE_VERSION=${{ steps.version.outputs.version }}" > ./versions.properties + - name: Update version in catalog + run: ./gradlew updateVersionCatalog_core -PmoduleVersion=${{ steps.version.outputs.version }} + - name: Publish core module + run: ./gradlew :core:core:publishAllPublicationsToGithubRepository + - name: Upload updated version catalog + uses: actions/upload-artifact@v4 + with: + name: version-catalog-core + path: gradle/libs.versions.toml + + # ============================================ + # PUBLISH: CORE-UI + # ============================================ + publish-coreui: + needs: detect-changes + if: needs.detect-changes.outputs.coreui == 'true' + runs-on: macos-latest + permissions: + contents: write + packages: write + outputs: + version: ${{ steps.version.outputs.version }} + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: 'temurin' + - name: Cache Gradle + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + - name: Cache Konan + uses: actions/cache@v4 + with: + path: | + ~/.konan/caches + ~/.konan/dependencies + ~/.konan/kotlin-native-prebuilt-macos-* + key: ${{ runner.os }}-konan-${{ hashFiles('**/Dependencies.kt') }} + restore-keys: | + ${{ runner.os }}-konan- + - name: Get latest version from Maven + id: version + env: + GH_TOKEN: ${{ secrets.PUBLISH_REPO_TOKEN }} + run: | + PACKAGE_NAME="com.metacto.kmm.core-ui" + VERSIONS=$(gh api /orgs/Meta-CTO/packages/maven/$PACKAGE_NAME/versions --jq '.[].name' 2>/dev/null || echo "") + + if [ -z "$VERSIONS" ]; then + CURRENT_VERSION=$(grep 'metacto-coreui = "' gradle/libs.versions.toml | sed 's/.*= "\([^"]*\)".*/\1/') + echo "No published versions found, using catalog version: $CURRENT_VERSION" + else + CURRENT_VERSION=$(echo "$VERSIONS" | grep -E '^[0-9]+\.[0-9]+\.[0-9]+-alpha$' | sort -V | tail -1) + if [ -z "$CURRENT_VERSION" ]; then + CURRENT_VERSION=$(grep 'metacto-coreui = "' gradle/libs.versions.toml | sed 's/.*= "\([^"]*\)".*/\1/') + fi + echo "Latest published version: $CURRENT_VERSION" + fi + + VERSION_BASE=$(echo "$CURRENT_VERSION" | sed 's/-[^-]*$//') + MAJOR=$(echo "$VERSION_BASE" | cut -d. -f1) + MINOR=$(echo "$VERSION_BASE" | cut -d. -f2) + PATCH=$(echo "$VERSION_BASE" | cut -d. -f3) + + if [ -z "$PATCH" ]; then + echo "ERROR: Failed to parse version. CURRENT_VERSION=$CURRENT_VERSION" + exit 1 + fi + + NEW_PATCH=$((PATCH + 1)) + NEW_VERSION="${MAJOR}.${MINOR}.${NEW_PATCH}${{ env.VERSION_SUFFIX }}" + + echo "New version: $NEW_VERSION" + echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT + - name: Update properties files + env: + PUBLISH_REPO_USER: ${{ secrets.PUBLISH_REPO_USER }} + PUBLISH_REPO_TOKEN: ${{ secrets.PUBLISH_REPO_TOKEN }} + run: | + echo "PUBLISH_REPO_USER=$PUBLISH_REPO_USER" > ./local.properties + echo "PUBLISH_REPO_TOKEN=$PUBLISH_REPO_TOKEN" >> ./local.properties + echo "PUBLISH_CORE_VERSION=${{ steps.version.outputs.version }}" > ./versions.properties + - name: Update version in catalog + run: ./gradlew updateVersionCatalog_coreui -PmoduleVersion=${{ steps.version.outputs.version }} + - name: Publish core-ui module + run: ./gradlew :ui:core-ui:publishAllPublicationsToGithubRepository + - name: Upload updated version catalog + uses: actions/upload-artifact@v4 + with: + name: version-catalog-coreui + path: gradle/libs.versions.toml + + # ============================================ + # PUBLISH: FILES + # ============================================ + publish-files: + needs: detect-changes + if: needs.detect-changes.outputs.files == 'true' + runs-on: macos-latest + permissions: + contents: write + packages: write + outputs: + version: ${{ steps.version.outputs.version }} + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: 'temurin' + - name: Cache Gradle + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + - name: Cache Konan + uses: actions/cache@v4 + with: + path: | + ~/.konan/caches + ~/.konan/dependencies + ~/.konan/kotlin-native-prebuilt-macos-* + key: ${{ runner.os }}-konan-${{ hashFiles('**/Dependencies.kt') }} + restore-keys: | + ${{ runner.os }}-konan- + - name: Get latest version from Maven + id: version + env: + GH_TOKEN: ${{ secrets.PUBLISH_REPO_TOKEN }} + run: | + PACKAGE_NAME="com.metacto.kmm.files" + VERSIONS=$(gh api /orgs/Meta-CTO/packages/maven/$PACKAGE_NAME/versions --jq '.[].name' 2>/dev/null || echo "") + + if [ -z "$VERSIONS" ]; then + CURRENT_VERSION=$(grep 'metacto-files = "' gradle/libs.versions.toml | sed 's/.*= "\([^"]*\)".*/\1/') + echo "No published versions found, using catalog version: $CURRENT_VERSION" + else + CURRENT_VERSION=$(echo "$VERSIONS" | grep -E '^[0-9]+\.[0-9]+\.[0-9]+-alpha$' | sort -V | tail -1) + if [ -z "$CURRENT_VERSION" ]; then + CURRENT_VERSION=$(grep 'metacto-files = "' gradle/libs.versions.toml | sed 's/.*= "\([^"]*\)".*/\1/') + fi + echo "Latest published version: $CURRENT_VERSION" + fi + + VERSION_BASE=$(echo "$CURRENT_VERSION" | sed 's/-[^-]*$//') + MAJOR=$(echo "$VERSION_BASE" | cut -d. -f1) + MINOR=$(echo "$VERSION_BASE" | cut -d. -f2) + PATCH=$(echo "$VERSION_BASE" | cut -d. -f3) + + if [ -z "$PATCH" ]; then + echo "ERROR: Failed to parse version. CURRENT_VERSION=$CURRENT_VERSION" + exit 1 + fi + + NEW_PATCH=$((PATCH + 1)) + NEW_VERSION="${MAJOR}.${MINOR}.${NEW_PATCH}${{ env.VERSION_SUFFIX }}" + + echo "New version: $NEW_VERSION" + echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT + - name: Update properties files + env: + PUBLISH_REPO_USER: ${{ secrets.PUBLISH_REPO_USER }} + PUBLISH_REPO_TOKEN: ${{ secrets.PUBLISH_REPO_TOKEN }} + run: | + echo "PUBLISH_REPO_USER=$PUBLISH_REPO_USER" > ./local.properties + echo "PUBLISH_REPO_TOKEN=$PUBLISH_REPO_TOKEN" >> ./local.properties + echo "PUBLISH_CORE_VERSION=${{ steps.version.outputs.version }}" > ./versions.properties + - name: Update version in catalog + run: ./gradlew updateVersionCatalog_files -PmoduleVersion=${{ steps.version.outputs.version }} + - name: Publish files module + run: ./gradlew :core:files:publishAllPublicationsToGithubRepository + - name: Upload updated version catalog + uses: actions/upload-artifact@v4 + with: + name: version-catalog-files + path: gradle/libs.versions.toml + + # ============================================ + # PUBLISH: NOTIFICATIONS + # ============================================ + publish-notifications: + needs: detect-changes + if: needs.detect-changes.outputs.notifications == 'true' + runs-on: macos-latest + permissions: + contents: write + packages: write + outputs: + version: ${{ steps.version.outputs.version }} + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: 'temurin' + - name: Cache Gradle + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + - name: Cache Konan + uses: actions/cache@v4 + with: + path: | + ~/.konan/caches + ~/.konan/dependencies + ~/.konan/kotlin-native-prebuilt-macos-* + key: ${{ runner.os }}-konan-${{ hashFiles('**/Dependencies.kt') }} + restore-keys: | + ${{ runner.os }}-konan- + - name: Get latest version from Maven + id: version + env: + GH_TOKEN: ${{ secrets.PUBLISH_REPO_TOKEN }} + run: | + PACKAGE_NAME="com.metacto.kmm.notifications" + VERSIONS=$(gh api /orgs/Meta-CTO/packages/maven/$PACKAGE_NAME/versions --jq '.[].name' 2>/dev/null || echo "") + + if [ -z "$VERSIONS" ]; then + CURRENT_VERSION=$(grep 'metacto-notifications = "' gradle/libs.versions.toml | sed 's/.*= "\([^"]*\)".*/\1/') + echo "No published versions found, using catalog version: $CURRENT_VERSION" + else + CURRENT_VERSION=$(echo "$VERSIONS" | grep -E '^[0-9]+\.[0-9]+\.[0-9]+-alpha$' | sort -V | tail -1) + if [ -z "$CURRENT_VERSION" ]; then + CURRENT_VERSION=$(grep 'metacto-notifications = "' gradle/libs.versions.toml | sed 's/.*= "\([^"]*\)".*/\1/') + fi + echo "Latest published version: $CURRENT_VERSION" + fi + + VERSION_BASE=$(echo "$CURRENT_VERSION" | sed 's/-[^-]*$//') + MAJOR=$(echo "$VERSION_BASE" | cut -d. -f1) + MINOR=$(echo "$VERSION_BASE" | cut -d. -f2) + PATCH=$(echo "$VERSION_BASE" | cut -d. -f3) + + if [ -z "$PATCH" ]; then + echo "ERROR: Failed to parse version. CURRENT_VERSION=$CURRENT_VERSION" + exit 1 + fi + + NEW_PATCH=$((PATCH + 1)) + NEW_VERSION="${MAJOR}.${MINOR}.${NEW_PATCH}${{ env.VERSION_SUFFIX }}" + + echo "New version: $NEW_VERSION" + echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT + - name: Update properties files + env: + PUBLISH_REPO_USER: ${{ secrets.PUBLISH_REPO_USER }} + PUBLISH_REPO_TOKEN: ${{ secrets.PUBLISH_REPO_TOKEN }} + run: | + echo "PUBLISH_REPO_USER=$PUBLISH_REPO_USER" > ./local.properties + echo "PUBLISH_REPO_TOKEN=$PUBLISH_REPO_TOKEN" >> ./local.properties + echo "PUBLISH_CORE_VERSION=${{ steps.version.outputs.version }}" > ./versions.properties + - name: Update version in catalog + run: ./gradlew updateVersionCatalog_notifications -PmoduleVersion=${{ steps.version.outputs.version }} + - name: Publish notifications module + run: ./gradlew :core:notifications:publishAllPublicationsToGithubRepository + - name: Upload updated version catalog + uses: actions/upload-artifact@v4 + with: + name: version-catalog-notifications + path: gradle/libs.versions.toml + + # ============================================ + # PUBLISH: PHONE-CORE + # ============================================ + publish-phonecore: + needs: detect-changes + if: needs.detect-changes.outputs.phonecore == 'true' + runs-on: macos-latest + permissions: + contents: write + packages: write + outputs: + version: ${{ steps.version.outputs.version }} + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: 'temurin' + - name: Cache Gradle + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + - name: Cache Konan + uses: actions/cache@v4 + with: + path: | + ~/.konan/caches + ~/.konan/dependencies + ~/.konan/kotlin-native-prebuilt-macos-* + key: ${{ runner.os }}-konan-${{ hashFiles('**/Dependencies.kt') }} + restore-keys: | + ${{ runner.os }}-konan- + - name: Get latest version from Maven + id: version + env: + GH_TOKEN: ${{ secrets.PUBLISH_REPO_TOKEN }} + run: | + PACKAGE_NAME="com.metacto.kmm.phone-core" + VERSIONS=$(gh api /orgs/Meta-CTO/packages/maven/$PACKAGE_NAME/versions --jq '.[].name' 2>/dev/null || echo "") + + if [ -z "$VERSIONS" ]; then + CURRENT_VERSION=$(grep 'metacto-phonecore = "' gradle/libs.versions.toml | sed 's/.*= "\([^"]*\)".*/\1/') + echo "No published versions found, using catalog version: $CURRENT_VERSION" + else + CURRENT_VERSION=$(echo "$VERSIONS" | grep -E '^[0-9]+\.[0-9]+\.[0-9]+-alpha$' | sort -V | tail -1) + if [ -z "$CURRENT_VERSION" ]; then + CURRENT_VERSION=$(grep 'metacto-phonecore = "' gradle/libs.versions.toml | sed 's/.*= "\([^"]*\)".*/\1/') + fi + echo "Latest published version: $CURRENT_VERSION" + fi + + VERSION_BASE=$(echo "$CURRENT_VERSION" | sed 's/-[^-]*$//') + MAJOR=$(echo "$VERSION_BASE" | cut -d. -f1) + MINOR=$(echo "$VERSION_BASE" | cut -d. -f2) + PATCH=$(echo "$VERSION_BASE" | cut -d. -f3) + + if [ -z "$PATCH" ]; then + echo "ERROR: Failed to parse version. CURRENT_VERSION=$CURRENT_VERSION" + exit 1 + fi + + NEW_PATCH=$((PATCH + 1)) + NEW_VERSION="${MAJOR}.${MINOR}.${NEW_PATCH}${{ env.VERSION_SUFFIX }}" + + echo "New version: $NEW_VERSION" + echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT + - name: Update properties files + env: + PUBLISH_REPO_USER: ${{ secrets.PUBLISH_REPO_USER }} + PUBLISH_REPO_TOKEN: ${{ secrets.PUBLISH_REPO_TOKEN }} + run: | + echo "PUBLISH_REPO_USER=$PUBLISH_REPO_USER" > ./local.properties + echo "PUBLISH_REPO_TOKEN=$PUBLISH_REPO_TOKEN" >> ./local.properties + echo "PUBLISH_CORE_VERSION=${{ steps.version.outputs.version }}" > ./versions.properties + - name: Update version in catalog + run: ./gradlew updateVersionCatalog_phonecore -PmoduleVersion=${{ steps.version.outputs.version }} + - name: Publish phone-core module + run: ./gradlew :core:phone-core:publishAllPublicationsToGithubRepository + - name: Upload updated version catalog + uses: actions/upload-artifact@v4 + with: + name: version-catalog-phonecore + path: gradle/libs.versions.toml + + # ============================================ + # PUBLISH: CAMERA + # ============================================ + publish-camera: + needs: detect-changes + if: needs.detect-changes.outputs.camera == 'true' runs-on: macos-latest permissions: contents: write packages: write + outputs: + version: ${{ steps.version.outputs.version }} steps: - - uses: actions/checkout@v3 - - name: set up JDK 17 - uses: actions/setup-java@v1 + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 with: java-version: 17 + distribution: 'temurin' - name: Cache Gradle - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ~/.gradle/caches @@ -27,7 +571,7 @@ jobs: restore-keys: | ${{ runner.os }}-gradle- - name: Cache Konan - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ~/.konan/caches @@ -36,37 +580,595 @@ jobs: key: ${{ runner.os }}-konan-${{ hashFiles('**/Dependencies.kt') }} restore-keys: | ${{ runner.os }}-konan- + - name: Get latest version from Maven + id: version + env: + GH_TOKEN: ${{ secrets.PUBLISH_REPO_TOKEN }} + run: | + PACKAGE_NAME="com.metacto.kmm.camera" + VERSIONS=$(gh api /orgs/Meta-CTO/packages/maven/$PACKAGE_NAME/versions --jq '.[].name' 2>/dev/null || echo "") + + if [ -z "$VERSIONS" ]; then + CURRENT_VERSION=$(grep 'metacto-camera = "' gradle/libs.versions.toml | sed 's/.*= "\([^"]*\)".*/\1/') + echo "No published versions found, using catalog version: $CURRENT_VERSION" + else + CURRENT_VERSION=$(echo "$VERSIONS" | grep -E '^[0-9]+\.[0-9]+\.[0-9]+-alpha$' | sort -V | tail -1) + if [ -z "$CURRENT_VERSION" ]; then + CURRENT_VERSION=$(grep 'metacto-camera = "' gradle/libs.versions.toml | sed 's/.*= "\([^"]*\)".*/\1/') + fi + echo "Latest published version: $CURRENT_VERSION" + fi + + VERSION_BASE=$(echo "$CURRENT_VERSION" | sed 's/-[^-]*$//') + MAJOR=$(echo "$VERSION_BASE" | cut -d. -f1) + MINOR=$(echo "$VERSION_BASE" | cut -d. -f2) + PATCH=$(echo "$VERSION_BASE" | cut -d. -f3) + + if [ -z "$PATCH" ]; then + echo "ERROR: Failed to parse version. CURRENT_VERSION=$CURRENT_VERSION" + exit 1 + fi + + NEW_PATCH=$((PATCH + 1)) + NEW_VERSION="${MAJOR}.${MINOR}.${NEW_PATCH}${{ env.VERSION_SUFFIX }}" - - name: Update local properties + echo "New version: $NEW_VERSION" + echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT + - name: Update properties files env: PUBLISH_REPO_USER: ${{ secrets.PUBLISH_REPO_USER }} PUBLISH_REPO_TOKEN: ${{ secrets.PUBLISH_REPO_TOKEN }} - PUBLISH_CORE_VERSION: 0.2.${{ github.run_number }}-alpha - run: echo PUBLISH_REPO_USER=$PUBLISH_REPO_USER$'\n' - PUBLISH_CORE_VERSION=$PUBLISH_CORE_VERSION$'\n' - PUBLISH_REPO_TOKEN=$PUBLISH_REPO_TOKEN > ./local.properties + run: | + echo "PUBLISH_REPO_USER=$PUBLISH_REPO_USER" > ./local.properties + echo "PUBLISH_REPO_TOKEN=$PUBLISH_REPO_TOKEN" >> ./local.properties + echo "PUBLISH_CORE_VERSION=${{ steps.version.outputs.version }}" > ./versions.properties + - name: Update version in catalog + run: ./gradlew updateVersionCatalog_camera -PmoduleVersion=${{ steps.version.outputs.version }} + - name: Publish camera module + run: ./gradlew :ui:camera:publishAllPublicationsToGithubRepository + - name: Upload updated version catalog + uses: actions/upload-artifact@v4 + with: + name: version-catalog-camera + path: gradle/libs.versions.toml + + # ============================================ + # PUBLISH: MEDIA-PLAYERS + # ============================================ + publish-mediaplayers: + needs: detect-changes + if: needs.detect-changes.outputs.mediaplayers == 'true' + runs-on: macos-latest + permissions: + contents: write + packages: write + outputs: + version: ${{ steps.version.outputs.version }} + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: 'temurin' + - name: Cache Gradle + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + - name: Cache Konan + uses: actions/cache@v4 + with: + path: | + ~/.konan/caches + ~/.konan/dependencies + ~/.konan/kotlin-native-prebuilt-macos-* + key: ${{ runner.os }}-konan-${{ hashFiles('**/Dependencies.kt') }} + restore-keys: | + ${{ runner.os }}-konan- + - name: Get latest version from Maven + id: version + env: + GH_TOKEN: ${{ secrets.PUBLISH_REPO_TOKEN }} + run: | + PACKAGE_NAME="com.metacto.kmm.media-players" + VERSIONS=$(gh api /orgs/Meta-CTO/packages/maven/$PACKAGE_NAME/versions --jq '.[].name' 2>/dev/null || echo "") + + if [ -z "$VERSIONS" ]; then + CURRENT_VERSION=$(grep 'metacto-mediaplayers = "' gradle/libs.versions.toml | sed 's/.*= "\([^"]*\)".*/\1/') + echo "No published versions found, using catalog version: $CURRENT_VERSION" + else + CURRENT_VERSION=$(echo "$VERSIONS" | grep -E '^[0-9]+\.[0-9]+\.[0-9]+-alpha$' | sort -V | tail -1) + if [ -z "$CURRENT_VERSION" ]; then + CURRENT_VERSION=$(grep 'metacto-mediaplayers = "' gradle/libs.versions.toml | sed 's/.*= "\([^"]*\)".*/\1/') + fi + echo "Latest published version: $CURRENT_VERSION" + fi + + VERSION_BASE=$(echo "$CURRENT_VERSION" | sed 's/-[^-]*$//') + MAJOR=$(echo "$VERSION_BASE" | cut -d. -f1) + MINOR=$(echo "$VERSION_BASE" | cut -d. -f2) + PATCH=$(echo "$VERSION_BASE" | cut -d. -f3) - - name: Print local.properties content - run: cat ./local.properties + if [ -z "$PATCH" ]; then + echo "ERROR: Failed to parse version. CURRENT_VERSION=$CURRENT_VERSION" + exit 1 + fi - - name: Update versions properties + NEW_PATCH=$((PATCH + 1)) + NEW_VERSION="${MAJOR}.${MINOR}.${NEW_PATCH}${{ env.VERSION_SUFFIX }}" + + echo "New version: $NEW_VERSION" + echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT + - name: Update properties files env: - PUBLISH_CORE_VERSION: 0.2.${{ github.run_number }}-alpha - run: echo PUBLISH_CORE_VERSION=$PUBLISH_CORE_VERSION> ./versions.properties + PUBLISH_REPO_USER: ${{ secrets.PUBLISH_REPO_USER }} + PUBLISH_REPO_TOKEN: ${{ secrets.PUBLISH_REPO_TOKEN }} + run: | + echo "PUBLISH_REPO_USER=$PUBLISH_REPO_USER" > ./local.properties + echo "PUBLISH_REPO_TOKEN=$PUBLISH_REPO_TOKEN" >> ./local.properties + echo "PUBLISH_CORE_VERSION=${{ steps.version.outputs.version }}" > ./versions.properties + - name: Update version in catalog + run: ./gradlew updateVersionCatalog_mediaplayers -PmoduleVersion=${{ steps.version.outputs.version }} + - name: Publish media-players module + run: ./gradlew :ui:media-players:publishAllPublicationsToGithubRepository + - name: Upload updated version catalog + uses: actions/upload-artifact@v4 + with: + name: version-catalog-mediaplayers + path: gradle/libs.versions.toml - - name: Print versions.properties content - run: cat ./versions.properties + # ============================================ + # PUBLISH: YOUTUBE + # ============================================ + publish-youtube: + needs: detect-changes + if: needs.detect-changes.outputs.youtube == 'true' + runs-on: macos-latest + permissions: + contents: write + packages: write + outputs: + version: ${{ steps.version.outputs.version }} + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: 'temurin' + - name: Cache Gradle + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + - name: Cache Konan + uses: actions/cache@v4 + with: + path: | + ~/.konan/caches + ~/.konan/dependencies + ~/.konan/kotlin-native-prebuilt-macos-* + key: ${{ runner.os }}-konan-${{ hashFiles('**/Dependencies.kt') }} + restore-keys: | + ${{ runner.os }}-konan- + - name: Get latest version from Maven + id: version + env: + GH_TOKEN: ${{ secrets.PUBLISH_REPO_TOKEN }} + run: | + PACKAGE_NAME="com.metacto.kmm.youtube" + VERSIONS=$(gh api /orgs/Meta-CTO/packages/maven/$PACKAGE_NAME/versions --jq '.[].name' 2>/dev/null || echo "") - - name: Update version catalog - run: ./gradlew updateVersionCatalog + if [ -z "$VERSIONS" ]; then + CURRENT_VERSION=$(grep 'metacto-youtube = "' gradle/libs.versions.toml | sed 's/.*= "\([^"]*\)".*/\1/') + echo "No published versions found, using catalog version: $CURRENT_VERSION" + else + CURRENT_VERSION=$(echo "$VERSIONS" | grep -E '^[0-9]+\.[0-9]+\.[0-9]+-alpha$' | sort -V | tail -1) + if [ -z "$CURRENT_VERSION" ]; then + CURRENT_VERSION=$(grep 'metacto-youtube = "' gradle/libs.versions.toml | sed 's/.*= "\([^"]*\)".*/\1/') + fi + echo "Latest published version: $CURRENT_VERSION" + fi - - name: Commit updated version catalog + VERSION_BASE=$(echo "$CURRENT_VERSION" | sed 's/-[^-]*$//') + MAJOR=$(echo "$VERSION_BASE" | cut -d. -f1) + MINOR=$(echo "$VERSION_BASE" | cut -d. -f2) + PATCH=$(echo "$VERSION_BASE" | cut -d. -f3) + + if [ -z "$PATCH" ]; then + echo "ERROR: Failed to parse version. CURRENT_VERSION=$CURRENT_VERSION" + exit 1 + fi + + NEW_PATCH=$((PATCH + 1)) + NEW_VERSION="${MAJOR}.${MINOR}.${NEW_PATCH}${{ env.VERSION_SUFFIX }}" + + echo "New version: $NEW_VERSION" + echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT + - name: Update properties files + env: + PUBLISH_REPO_USER: ${{ secrets.PUBLISH_REPO_USER }} + PUBLISH_REPO_TOKEN: ${{ secrets.PUBLISH_REPO_TOKEN }} + run: | + echo "PUBLISH_REPO_USER=$PUBLISH_REPO_USER" > ./local.properties + echo "PUBLISH_REPO_TOKEN=$PUBLISH_REPO_TOKEN" >> ./local.properties + echo "PUBLISH_CORE_VERSION=${{ steps.version.outputs.version }}" > ./versions.properties + - name: Update version in catalog + run: ./gradlew updateVersionCatalog_youtube -PmoduleVersion=${{ steps.version.outputs.version }} + - name: Publish youtube module + run: ./gradlew :ui:youtube:publishAllPublicationsToGithubRepository + - name: Upload updated version catalog + uses: actions/upload-artifact@v4 + with: + name: version-catalog-youtube + path: gradle/libs.versions.toml + + # ============================================ + # PUBLISH: PHONE-UI + # ============================================ + publish-phoneui: + needs: detect-changes + if: needs.detect-changes.outputs.phoneui == 'true' + runs-on: macos-latest + permissions: + contents: write + packages: write + outputs: + version: ${{ steps.version.outputs.version }} + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: 'temurin' + - name: Cache Gradle + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + - name: Cache Konan + uses: actions/cache@v4 + with: + path: | + ~/.konan/caches + ~/.konan/dependencies + ~/.konan/kotlin-native-prebuilt-macos-* + key: ${{ runner.os }}-konan-${{ hashFiles('**/Dependencies.kt') }} + restore-keys: | + ${{ runner.os }}-konan- + - name: Get latest version from Maven + id: version + env: + GH_TOKEN: ${{ secrets.PUBLISH_REPO_TOKEN }} + run: | + PACKAGE_NAME="com.metacto.kmm.phone-ui" + VERSIONS=$(gh api /orgs/Meta-CTO/packages/maven/$PACKAGE_NAME/versions --jq '.[].name' 2>/dev/null || echo "") + + if [ -z "$VERSIONS" ]; then + CURRENT_VERSION=$(grep 'metacto-phoneui = "' gradle/libs.versions.toml | sed 's/.*= "\([^"]*\)".*/\1/') + echo "No published versions found, using catalog version: $CURRENT_VERSION" + else + CURRENT_VERSION=$(echo "$VERSIONS" | grep -E '^[0-9]+\.[0-9]+\.[0-9]+-alpha$' | sort -V | tail -1) + if [ -z "$CURRENT_VERSION" ]; then + CURRENT_VERSION=$(grep 'metacto-phoneui = "' gradle/libs.versions.toml | sed 's/.*= "\([^"]*\)".*/\1/') + fi + echo "Latest published version: $CURRENT_VERSION" + fi + + VERSION_BASE=$(echo "$CURRENT_VERSION" | sed 's/-[^-]*$//') + MAJOR=$(echo "$VERSION_BASE" | cut -d. -f1) + MINOR=$(echo "$VERSION_BASE" | cut -d. -f2) + PATCH=$(echo "$VERSION_BASE" | cut -d. -f3) + + if [ -z "$PATCH" ]; then + echo "ERROR: Failed to parse version. CURRENT_VERSION=$CURRENT_VERSION" + exit 1 + fi + + NEW_PATCH=$((PATCH + 1)) + NEW_VERSION="${MAJOR}.${MINOR}.${NEW_PATCH}${{ env.VERSION_SUFFIX }}" + + echo "New version: $NEW_VERSION" + echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT + - name: Update properties files + env: + PUBLISH_REPO_USER: ${{ secrets.PUBLISH_REPO_USER }} + PUBLISH_REPO_TOKEN: ${{ secrets.PUBLISH_REPO_TOKEN }} + run: | + echo "PUBLISH_REPO_USER=$PUBLISH_REPO_USER" > ./local.properties + echo "PUBLISH_REPO_TOKEN=$PUBLISH_REPO_TOKEN" >> ./local.properties + echo "PUBLISH_CORE_VERSION=${{ steps.version.outputs.version }}" > ./versions.properties + - name: Update version in catalog + run: ./gradlew updateVersionCatalog_phoneui -PmoduleVersion=${{ steps.version.outputs.version }} + - name: Publish phone-ui module + run: ./gradlew :ui:phone-ui:publishAllPublicationsToGithubRepository + - name: Upload updated version catalog + uses: actions/upload-artifact@v4 + with: + name: version-catalog-phoneui + path: gradle/libs.versions.toml + + # ============================================ + # PUBLISH: IMAGE-PICKER + # ============================================ + publish-imagepicker: + needs: detect-changes + if: needs.detect-changes.outputs.imagepicker == 'true' + runs-on: macos-latest + permissions: + contents: write + packages: write + outputs: + version: ${{ steps.version.outputs.version }} + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: 'temurin' + - name: Cache Gradle + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + - name: Cache Konan + uses: actions/cache@v4 + with: + path: | + ~/.konan/caches + ~/.konan/dependencies + ~/.konan/kotlin-native-prebuilt-macos-* + key: ${{ runner.os }}-konan-${{ hashFiles('**/Dependencies.kt') }} + restore-keys: | + ${{ runner.os }}-konan- + - name: Get latest version from Maven + id: version + env: + GH_TOKEN: ${{ secrets.PUBLISH_REPO_TOKEN }} + run: | + PACKAGE_NAME="com.metacto.kmm.image-picker" + VERSIONS=$(gh api /orgs/Meta-CTO/packages/maven/$PACKAGE_NAME/versions --jq '.[].name' 2>/dev/null || echo "") + + if [ -z "$VERSIONS" ]; then + CURRENT_VERSION=$(grep 'metacto-imagepicker = "' gradle/libs.versions.toml | sed 's/.*= "\([^"]*\)".*/\1/') + echo "No published versions found, using catalog version: $CURRENT_VERSION" + else + CURRENT_VERSION=$(echo "$VERSIONS" | grep -E '^[0-9]+\.[0-9]+\.[0-9]+-alpha$' | sort -V | tail -1) + if [ -z "$CURRENT_VERSION" ]; then + CURRENT_VERSION=$(grep 'metacto-imagepicker = "' gradle/libs.versions.toml | sed 's/.*= "\([^"]*\)".*/\1/') + fi + echo "Latest published version: $CURRENT_VERSION" + fi + + VERSION_BASE=$(echo "$CURRENT_VERSION" | sed 's/-[^-]*$//') + MAJOR=$(echo "$VERSION_BASE" | cut -d. -f1) + MINOR=$(echo "$VERSION_BASE" | cut -d. -f2) + PATCH=$(echo "$VERSION_BASE" | cut -d. -f3) + + if [ -z "$PATCH" ]; then + echo "ERROR: Failed to parse version. CURRENT_VERSION=$CURRENT_VERSION" + exit 1 + fi + + NEW_PATCH=$((PATCH + 1)) + NEW_VERSION="${MAJOR}.${MINOR}.${NEW_PATCH}${{ env.VERSION_SUFFIX }}" + + echo "New version: $NEW_VERSION" + echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT + - name: Update properties files + env: + PUBLISH_REPO_USER: ${{ secrets.PUBLISH_REPO_USER }} + PUBLISH_REPO_TOKEN: ${{ secrets.PUBLISH_REPO_TOKEN }} + run: | + echo "PUBLISH_REPO_USER=$PUBLISH_REPO_USER" > ./local.properties + echo "PUBLISH_REPO_TOKEN=$PUBLISH_REPO_TOKEN" >> ./local.properties + echo "PUBLISH_CORE_VERSION=${{ steps.version.outputs.version }}" > ./versions.properties + - name: Update version in catalog + run: ./gradlew updateVersionCatalog_imagepicker -PmoduleVersion=${{ steps.version.outputs.version }} + - name: Publish image-picker module + run: ./gradlew :ui:image-picker:publishAllPublicationsToGithubRepository + - name: Upload updated version catalog + uses: actions/upload-artifact@v4 + with: + name: version-catalog-imagepicker + path: gradle/libs.versions.toml + + # ============================================ + # FINALIZE: Merge version catalogs and commit + # ============================================ + finalize: + needs: + - detect-changes + - publish-core + - publish-coreui + - publish-files + - publish-notifications + - publish-phonecore + - publish-camera + - publish-mediaplayers + - publish-youtube + - publish-phoneui + - publish-imagepicker + if: always() && needs.detect-changes.outputs.any_module == 'true' + runs-on: macos-latest + permissions: + contents: write + packages: write + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: 'temurin' + + - name: Cache Gradle + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: Download all version catalog artifacts + uses: actions/download-artifact@v4 + with: + path: version-catalogs + pattern: version-catalog-* + + - name: Merge version catalogs + run: | + echo "Merging version catalogs..." + + # Start with the base version catalog + cp gradle/libs.versions.toml gradle/libs.versions.toml.merged + + # Apply updates from each published module's artifact + merge_version() { + local module=$1 + local version_key=$2 + local artifact_path="version-catalogs/version-catalog-$module/libs.versions.toml" + + if [ -f "$artifact_path" ]; then + # Extract the new version from the artifact + NEW_VERSION=$(grep "$version_key = \"" "$artifact_path" | sed 's/.*= "\([^"]*\)".*/\1/') + if [ -n "$NEW_VERSION" ]; then + echo "Updating $version_key to $NEW_VERSION" + sed -i '' "s/$version_key = \"[^\"]*\"/$version_key = \"$NEW_VERSION\"/" gradle/libs.versions.toml.merged + fi + fi + } + + merge_version "core" "metacto-core" + merge_version "coreui" "metacto-coreui" + merge_version "files" "metacto-files" + merge_version "notifications" "metacto-notifications" + merge_version "phonecore" "metacto-phonecore" + merge_version "camera" "metacto-camera" + merge_version "mediaplayers" "metacto-mediaplayers" + merge_version "youtube" "metacto-youtube" + merge_version "phoneui" "metacto-phoneui" + merge_version "imagepicker" "metacto-imagepicker" + + mv gradle/libs.versions.toml.merged gradle/libs.versions.toml + + echo "Updated version catalog:" + head -30 gradle/libs.versions.toml + + - name: Get latest version-catalog version from Maven + id: version + env: + GH_TOKEN: ${{ secrets.PUBLISH_REPO_TOKEN }} + run: | + PACKAGE_NAME="com.metacto.kmm.version-catalog" + VERSIONS=$(gh api /orgs/Meta-CTO/packages/maven/$PACKAGE_NAME/versions --jq '.[].name' 2>/dev/null || echo "") + + if [ -z "$VERSIONS" ]; then + CURRENT_VERSION="0.2.82-alpha" + echo "No published versions found, using default: $CURRENT_VERSION" + else + CURRENT_VERSION=$(echo "$VERSIONS" | grep -E '^[0-9]+\.[0-9]+\.[0-9]+-alpha$' | sort -V | tail -1) + if [ -z "$CURRENT_VERSION" ]; then + CURRENT_VERSION="0.2.82-alpha" + fi + echo "Latest published version: $CURRENT_VERSION" + fi + + VERSION_BASE=$(echo "$CURRENT_VERSION" | sed 's/-[^-]*$//') + MAJOR=$(echo "$VERSION_BASE" | cut -d. -f1) + MINOR=$(echo "$VERSION_BASE" | cut -d. -f2) + PATCH=$(echo "$VERSION_BASE" | cut -d. -f3) + NEW_VERSION="${MAJOR}.${MINOR}.$((PATCH + 1))-alpha" + + echo "New version: $NEW_VERSION" + echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT + + - name: Update properties files + env: + PUBLISH_REPO_USER: ${{ secrets.PUBLISH_REPO_USER }} + PUBLISH_REPO_TOKEN: ${{ secrets.PUBLISH_REPO_TOKEN }} + run: | + echo "PUBLISH_REPO_USER=$PUBLISH_REPO_USER" > ./local.properties + echo "PUBLISH_REPO_TOKEN=$PUBLISH_REPO_TOKEN" >> ./local.properties + # Update versions.properties - this is what Gradle reads for the actual version + echo "PUBLISH_CORE_VERSION=${{ steps.version.outputs.version }}" > ./versions.properties + + - name: Publish version catalog + run: ./gradlew :version-catalog:publishAllPublicationsToGithubRepository + + - name: Commit and push updated version catalog run: | git config user.name "GitHub Actions Bot" git config user.email "actions@github.com" git add gradle/libs.versions.toml - git commit -m "Update metacto-core version to 0.2.${{ github.run_number }}-alpha" - git push - - name: Publish to GitHub Packages - run: ./gradlew publishAllPublicationsToGithubRepository + # Build commit message with list of updated modules and their versions + COMMIT_MSG="Update module versions:" + + if [ -d "version-catalogs/version-catalog-core" ]; then + VER=$(grep 'metacto-core = "' gradle/libs.versions.toml | head -1 | sed 's/.*= "\([^"]*\)".*/\1/') + COMMIT_MSG="$COMMIT_MSG core@$VER" + fi + if [ -d "version-catalogs/version-catalog-coreui" ]; then + VER=$(grep 'metacto-coreui = "' gradle/libs.versions.toml | sed 's/.*= "\([^"]*\)".*/\1/') + COMMIT_MSG="$COMMIT_MSG core-ui@$VER" + fi + if [ -d "version-catalogs/version-catalog-files" ]; then + VER=$(grep 'metacto-files = "' gradle/libs.versions.toml | sed 's/.*= "\([^"]*\)".*/\1/') + COMMIT_MSG="$COMMIT_MSG files@$VER" + fi + if [ -d "version-catalogs/version-catalog-notifications" ]; then + VER=$(grep 'metacto-notifications = "' gradle/libs.versions.toml | sed 's/.*= "\([^"]*\)".*/\1/') + COMMIT_MSG="$COMMIT_MSG notifications@$VER" + fi + if [ -d "version-catalogs/version-catalog-phonecore" ]; then + VER=$(grep 'metacto-phonecore = "' gradle/libs.versions.toml | sed 's/.*= "\([^"]*\)".*/\1/') + COMMIT_MSG="$COMMIT_MSG phone-core@$VER" + fi + if [ -d "version-catalogs/version-catalog-camera" ]; then + VER=$(grep 'metacto-camera = "' gradle/libs.versions.toml | sed 's/.*= "\([^"]*\)".*/\1/') + COMMIT_MSG="$COMMIT_MSG camera@$VER" + fi + if [ -d "version-catalogs/version-catalog-mediaplayers" ]; then + VER=$(grep 'metacto-mediaplayers = "' gradle/libs.versions.toml | sed 's/.*= "\([^"]*\)".*/\1/') + COMMIT_MSG="$COMMIT_MSG media-players@$VER" + fi + if [ -d "version-catalogs/version-catalog-youtube" ]; then + VER=$(grep 'metacto-youtube = "' gradle/libs.versions.toml | sed 's/.*= "\([^"]*\)".*/\1/') + COMMIT_MSG="$COMMIT_MSG youtube@$VER" + fi + if [ -d "version-catalogs/version-catalog-phoneui" ]; then + VER=$(grep 'metacto-phoneui = "' gradle/libs.versions.toml | sed 's/.*= "\([^"]*\)".*/\1/') + COMMIT_MSG="$COMMIT_MSG phone-ui@$VER" + fi + if [ -d "version-catalogs/version-catalog-imagepicker" ]; then + VER=$(grep 'metacto-imagepicker = "' gradle/libs.versions.toml | sed 's/.*= "\([^"]*\)".*/\1/') + COMMIT_MSG="$COMMIT_MSG image-picker@$VER" + fi + + git commit -m "$COMMIT_MSG" || echo "No changes to commit" + git push diff --git a/build.gradle.kts b/build.gradle.kts index 9d908dc9..243cbf6f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -14,9 +14,24 @@ allprojects { repositories.addProjectRepos() } +// Legacy task: updates all modules with PUBLISH_CORE_VERSION tasks.register("updateVersionCatalog") { group = "publishing" - description = "Updates metacto-core version in libs.versions.toml from versions.properties" + description = "Updates all metacto versions in libs.versions.toml from versions.properties" +} + +// Per-module version update tasks +val modules = listOf( + "core", "coreui", "files", "notifications", "phonecore", + "camera", "mediaplayers", "youtube", "phoneui", "imagepicker" +) + +modules.forEach { module -> + tasks.register("updateVersionCatalog_$module") { + group = "publishing" + description = "Updates metacto-$module version in libs.versions.toml" + moduleName.set(module) + } } // Convenience task to update version catalog and publish diff --git a/buildSrc/src/main/kotlin/UpdateVersionCatalogTask.kt b/buildSrc/src/main/kotlin/UpdateVersionCatalogTask.kt index 9d0ec5a8..7cd0557b 100644 --- a/buildSrc/src/main/kotlin/UpdateVersionCatalogTask.kt +++ b/buildSrc/src/main/kotlin/UpdateVersionCatalogTask.kt @@ -1,28 +1,94 @@ import org.gradle.api.DefaultTask +import org.gradle.api.provider.Property +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.Optional import org.gradle.api.tasks.TaskAction import java.io.File import java.util.Properties -open class UpdateVersionCatalogTask : DefaultTask() { +abstract class UpdateVersionCatalogTask : DefaultTask() { + + /** + * The module name to update (e.g., "core", "coreui", "files"). + * If not set, updates all modules based on versions.properties. + */ + @get:Input + @get:Optional + abstract val moduleName: Property + + /** + * The version to set for the module. + * If not set, reads from versions.properties. + */ + @get:Input + @get:Optional + abstract val moduleVersion: Property + + companion object { + // Map of module names to their version key in libs.versions.toml + val MODULE_VERSION_KEYS = mapOf( + "core" to "metacto-core", + "coreui" to "metacto-coreui", + "files" to "metacto-files", + "notifications" to "metacto-notifications", + "phonecore" to "metacto-phonecore", + "camera" to "metacto-camera", + "mediaplayers" to "metacto-mediaplayers", + "youtube" to "metacto-youtube", + "phoneui" to "metacto-phoneui", + "imagepicker" to "metacto-imagepicker" + ) + } @TaskAction fun updateVersion() { - val versionProperties = Properties().apply { - load(File(project.rootDir, "versions.properties").inputStream()) + val libsVersionsFile = File(project.rootDir, "gradle/libs.versions.toml") + var content = libsVersionsFile.readText() + + if (moduleName.isPresent) { + // Update single module + val module = moduleName.get() + val version = when { + moduleVersion.isPresent -> moduleVersion.get() + project.hasProperty("moduleVersion") -> project.property("moduleVersion").toString() + else -> getVersionFromProperties("PUBLISH_${module.uppercase()}_VERSION") + ?: getVersionFromProperties("PUBLISH_CORE_VERSION") + ?: throw IllegalStateException("No version found for module: $module") + } + + val versionKey = MODULE_VERSION_KEYS[module] + ?: throw IllegalArgumentException("Unknown module: $module. Valid modules: ${MODULE_VERSION_KEYS.keys}") + + content = updateVersionInContent(content, versionKey, version) + println("✅ Updated $versionKey version to $version in libs.versions.toml") + } else { + // Legacy behavior: update all modules with PUBLISH_CORE_VERSION + val publishVersion = getVersionFromProperties("PUBLISH_CORE_VERSION") + ?: throw IllegalStateException("PUBLISH_CORE_VERSION not found in versions.properties") + + MODULE_VERSION_KEYS.values.forEach { versionKey -> + content = updateVersionInContent(content, versionKey, publishVersion) + } + println("✅ Updated all metacto versions to $publishVersion in libs.versions.toml") } - val publishVersion = versionProperties.getProperty("PUBLISH_CORE_VERSION") - val libsVersionsFile = File(project.rootDir, "gradle/libs.versions.toml") - val content = libsVersionsFile.readText() + libsVersionsFile.writeText(content) + } - // Update metacto-core version - val updatedContent = content.replace( - Regex("""metacto-core = "[^"]+""""), - """metacto-core = "$publishVersion"""" - ) + private fun getVersionFromProperties(key: String): String? { + val versionPropertiesFile = File(project.rootDir, "versions.properties") + if (!versionPropertiesFile.exists()) return null - libsVersionsFile.writeText(updatedContent) + val properties = Properties().apply { + load(versionPropertiesFile.inputStream()) + } + return properties.getProperty(key) + } - println("✅ Updated metacto-core version to $publishVersion in libs.versions.toml") + private fun updateVersionInContent(content: String, versionKey: String, version: String): String { + return content.replace( + Regex("""$versionKey = "[^"]+""""), + """$versionKey = "$version"""" + ) } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e3dabfd8..6ca7806e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -13,7 +13,16 @@ coroutines = "1.10.2" serialization-json = "1.6.0" strapi-kmm = "10.0.158" core-network = "2.0.58" -metacto-core = "0.2.81-alpha" +metacto-core = "0.2.82-alpha" +metacto-coreui = "0.2.82-alpha" +metacto-files = "0.2.82-alpha" +metacto-notifications = "0.2.82-alpha" +metacto-phonecore = "0.2.82-alpha" +metacto-camera = "0.2.82-alpha" +metacto-mediaplayers = "0.2.82-alpha" +metacto-youtube = "0.2.83-alpha" +metacto-phoneui = "0.2.82-alpha" +metacto-imagepicker = "0.2.82-alpha" metacto-inspektify = "1.0.0-beta09-meta-2" metacto-downloadmanager = "0.0.4-alpha" metacto-firebase = "1.0.34" @@ -157,15 +166,15 @@ uuid = { module = "com.benasher44:uuid", version.ref = "uuid" } #MetaCto metacto-core = { module = "com.metacto.kmm:core", version.ref = "metacto-core" } -metacto-coreui = { module = "com.metacto.kmm:core-ui", version.ref = "metacto-core" } -metacto-files = { module = "com.metacto.kmm:files", version.ref = "metacto-core" } -metacto-notifications = { module = "com.metacto.kmm:notifications", version.ref = "metacto-core" } -metacto-phonecore = { module = "com.metacto.kmm:phone-core", version.ref = "metacto-core" } -metacto-mediaplayers = { module = "com.metacto.kmm:media-players", version.ref = "metacto-core" } -metacto-camera = { module = "com.metacto.kmm:camera", version.ref = "metacto-core" } -metacto-youtube = { module = "com.metacto.kmm:youtube", version.ref = "metacto-core" } -metacto-phoneui = { module = "com.metacto.kmm:phone-ui", version.ref = "metacto-core" } -metacto-imagepicker = { module = "com.metacto.kmm:image-picker", version.ref = "metacto-core" } +metacto-coreui = { module = "com.metacto.kmm:core-ui", version.ref = "metacto-coreui" } +metacto-files = { module = "com.metacto.kmm:files", version.ref = "metacto-files" } +metacto-notifications = { module = "com.metacto.kmm:notifications", version.ref = "metacto-notifications" } +metacto-phonecore = { module = "com.metacto.kmm:phone-core", version.ref = "metacto-phonecore" } +metacto-mediaplayers = { module = "com.metacto.kmm:media-players", version.ref = "metacto-mediaplayers" } +metacto-camera = { module = "com.metacto.kmm:camera", version.ref = "metacto-camera" } +metacto-youtube = { module = "com.metacto.kmm:youtube", version.ref = "metacto-youtube" } +metacto-phoneui = { module = "com.metacto.kmm:phone-ui", version.ref = "metacto-phoneui" } +metacto-imagepicker = { module = "com.metacto.kmm:image-picker", version.ref = "metacto-imagepicker" } metacto-auth-common = { module = "com.metacto.kmm:auth-common", version.ref = "metacto-firebase" } metacto-auth-firebase = { module = "com.metacto.kmm:firebase-auth-extensions", version.ref = "metacto-firebase" } metacto-remoteconfigs-common = { module = "com.metacto.kmm:remote-config-common", version.ref = "metacto-firebase" } diff --git a/ui/core-ui/src/iosMain/kotlin/com/metacto/core/ui/components/pickers/IosNativeDatePicker.kt b/ui/core-ui/src/iosMain/kotlin/com/metacto/core/ui/components/pickers/IosNativeDatePicker.kt index d575b2c4..a1295aab 100644 --- a/ui/core-ui/src/iosMain/kotlin/com/metacto/core/ui/components/pickers/IosNativeDatePicker.kt +++ b/ui/core-ui/src/iosMain/kotlin/com/metacto/core/ui/components/pickers/IosNativeDatePicker.kt @@ -310,4 +310,4 @@ private fun NSDate.toLocalDateTime(calendar: NSCalendar): LocalDateTime { minute = components.minute.toInt(), second = components.second.toInt() ) -} +} \ No newline at end of file