From 8c2a0f584d6a68c6497d5f2307878905fe590443 Mon Sep 17 00:00:00 2001 From: Alexander Gorodnikov Date: Fri, 26 Dec 2025 12:56:13 +0300 Subject: [PATCH 1/5] Configure CI and enhance KMP targets This commit introduces a GitHub Actions workflow to build the project on every push and pull request. It also enhances the Kotlin Multiplatform configuration by: - Enabling Klibs cross-compilation for Apple targets on non-macOS hosts. - Adding `nodejs()`, `browser()`, and `binaries.executable()` to the JS and Wasm targets. - Removing the `FAIL_ON_PROJECT_REPOS` repository mode. --- .github/workflows/ci.yml | 45 ++++++++++++++++++++++++++ automapper/annotation/build.gradle.kts | 5 +++ gradle.properties | 3 ++ gradlew | 0 sample/build.gradle.kts | 5 +++ settings.gradle.kts | 1 - 6 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci.yml mode change 100644 => 100755 gradlew diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..57400cf --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,45 @@ +# This workflow builds the project on every push and pull request to the main branch + +name: Build and Verify + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + # Use the latest version of Ubuntu for the build environment + runs-on: ubuntu-latest + + steps: + # Check out the repository code so the workflow can access it + - name: Checkout repository + uses: actions/checkout@v4 + + # Set up JDK 21, which is required by the project + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: 'temurin' + + # Cache Gradle packages and wrapper to speed up the build process + - name: Cache Gradle packages + uses: actions/cache@v4 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + + # Grant execute permission to the Gradle wrapper script + - name: Grant execute permission for gradlew + run: chmod +x ./gradlew + + # Run the main build task + - name: Build with Gradle + run: ./gradlew build --info diff --git a/automapper/annotation/build.gradle.kts b/automapper/annotation/build.gradle.kts index af0bd07..f1ff954 100644 --- a/automapper/annotation/build.gradle.kts +++ b/automapper/annotation/build.gradle.kts @@ -14,17 +14,22 @@ kotlin { iosArm64() iosSimulatorArm64() js(IR) { + nodejs() browser() + binaries.executable() } @OptIn(ExperimentalWasmDsl::class) wasmWasi { nodejs() + binaries.executable() } @OptIn(ExperimentalWasmDsl::class) wasmJs { nodejs() + browser() + binaries.executable() } } diff --git a/gradle.properties b/gradle.properties index 132244e..0513538 100644 --- a/gradle.properties +++ b/gradle.properties @@ -21,3 +21,6 @@ kotlin.code.style=official # resources declared in the library itself and none from the library's dependencies, # thereby reducing the size of the R class for that library android.nonTransitiveRClass=true + +# Allows compiling Kotlin/Native code for Apple targets (e.g., iOS) on non-macOS hosts like Linux or Windows +kotlin.native.enableKlibsCrossCompilation=true diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 diff --git a/sample/build.gradle.kts b/sample/build.gradle.kts index 5621ade..a3a534d 100644 --- a/sample/build.gradle.kts +++ b/sample/build.gradle.kts @@ -11,17 +11,22 @@ kotlin { iosArm64() iosSimulatorArm64() js(IR) { + nodejs() browser() + binaries.executable() } @OptIn(ExperimentalWasmDsl::class) wasmWasi { nodejs() + binaries.executable() } @OptIn(ExperimentalWasmDsl::class) wasmJs { nodejs() + browser() + binaries.executable() } sourceSets { diff --git a/settings.gradle.kts b/settings.gradle.kts index ac5084f..947be35 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -13,7 +13,6 @@ pluginManagement { } dependencyResolutionManagement { - repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositories { google { content { From fe5892cb6ae98e4f05f290af6acb4a45003ab969 Mon Sep 17 00:00:00 2001 From: Alexander Gorodnikov Date: Fri, 26 Dec 2025 13:01:36 +0300 Subject: [PATCH 2/5] Small code changes --- .github/workflows/ci.yml | 2 +- gradle.properties | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 57400cf..2cbea6a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,4 +42,4 @@ jobs: # Run the main build task - name: Build with Gradle - run: ./gradlew build --info + run: ./gradlew build diff --git a/gradle.properties b/gradle.properties index 0513538..72409c9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -24,3 +24,6 @@ android.nonTransitiveRClass=true # Allows compiling Kotlin/Native code for Apple targets (e.g., iOS) on non-macOS hosts like Linux or Windows kotlin.native.enableKlibsCrossCompilation=true + +# Enables Gradle's build cache +org.gradle.caching=true From fb850b7f264c159a5221d63c0d40a349e5d85922 Mon Sep 17 00:00:00 2001 From: Alexander Gorodnikov Date: Fri, 26 Dec 2025 13:04:03 +0300 Subject: [PATCH 3/5] Change pipeline name --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2cbea6a..c80c0ba 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,6 @@ # This workflow builds the project on every push and pull request to the main branch -name: Build and Verify +name: AutoMapper CI Pipeline on: push: From e1d335334af3f97169cdf2d12a048167bf6b9103 Mon Sep 17 00:00:00 2001 From: Alexander Gorodnikov Date: Fri, 26 Dec 2025 14:19:02 +0300 Subject: [PATCH 4/5] Implement Automated GitFlow Release Workflow --- .github/workflows/ci.yml | 6 +-- .github/workflows/prepare-release.yml | 41 ++++++++++++++++ .github/workflows/release-and-publish.yml | 60 +++++++++++++++++++++++ 3 files changed, 103 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/prepare-release.yml create mode 100644 .github/workflows/release-and-publish.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c80c0ba..f591775 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,12 +1,10 @@ # This workflow builds the project on every push and pull request to the main branch -name: AutoMapper CI Pipeline +name: AutoMapper CI on: - push: - branches: [ "main" ] pull_request: - branches: [ "main" ] + branches: [ "main", "develop" ] jobs: build: diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml new file mode 100644 index 0000000..d4f6a6b --- /dev/null +++ b/.github/workflows/prepare-release.yml @@ -0,0 +1,41 @@ +# This workflow prepares a new release by creating a pull request from 'develop' to 'main'. + +name: AutoMapper Prepare Release + +on: + workflow_dispatch: + inputs: + version: + description: 'The version to release (e.g., 1.0.0)' + required: true + +jobs: + prepare-release: + runs-on: ubuntu-latest + steps: + - name: Checkout develop branch + uses: actions/checkout@v4 + with: + ref: 'develop' + + - name: Update version in build files and README + run: | + VERSION=${{ github.event.inputs.version }} + # Update version in processor/build.gradle.kts + sed -i "s/^version = \".*\"/version = \"$VERSION\"/" automapper/processor/build.gradle.kts + # Update version in annotation/build.gradle.kts + sed -i "s/^version = \".*\"/version = \"$VERSION\"/" automapper/annotation/build.gradle.kts + # Update dependency versions in README.md + sed -i 's/\(io\.github\.jacksever\.automapper:[^:]*:\)[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*/\1$VERSION/g' README.md + + - name: Create Pull Request to main + uses: peter-evans/create-pull-request@v6 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: "Prepare release of Kotlin AutoMapper ${{ github.event.inputs.version }}" + title: "Prepare release of Kotlin AutoMapper ${{ github.event.inputs.version }}" + body: "This PR integrates changes from `develop` into `main` for the ${{ github.event.inputs.version }} release" + branch: "release/${{ github.event.inputs.version }}" + base: "main" + reviewers: ${{ github.actor }} + delete-branch: true diff --git a/.github/workflows/release-and-publish.yml b/.github/workflows/release-and-publish.yml new file mode 100644 index 0000000..32b567c --- /dev/null +++ b/.github/workflows/release-and-publish.yml @@ -0,0 +1,60 @@ +# This workflow creates a tag, publishes to Maven Central, and creates a GitHub Release + +name: AutoMapper Release and Publish + +on: + push: + branches: + - 'main' # Triggers on any push to main, including merges + +jobs: + release: + # This condition ensures the job only runs for merge commits from a release branch + if: startsWith(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, '/release/') + runs-on: ubuntu-latest + permissions: + contents: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Extract version from merge commit + id: get_version + run: | + COMMIT_MSG="${{ github.event.head_commit.message }}" + VERSION=$(echo "$COMMIT_MSG" | sed -n 's/.*\/release\/\([0-9.]*\).*/\1/p') + echo "version=$VERSION" >> $GITHUB_OUTPUT + + - name: Create and push Git Tag + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git tag "${{ steps.get_version.outputs.version }}" + git push origin "${{ steps.get_version.outputs.version }}" + + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: 'temurin' + + - name: Grant execute permission for gradlew + run: chmod +x ./gradlew + +# - name: Publish to Maven Central +# run: ./gradlew publishAllPublicationsToMavenCentralRepository --no-daemon --no-parallel +# env: +# ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }} +# ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_TOKEN }} +# ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_SIGNING_KEY }} +# ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_SIGNING_PASSWORD }} + + - name: Create GitHub Release + uses: ncipollo/release-action@v1 + with: + tag: '${{ steps.get_version.outputs.version }}' + name: '${{ steps.get_version.outputs.version }}' + generateReleaseNotes: true From 70c1ba2c6578d51059b7f050e5c5be31b973338a Mon Sep 17 00:00:00 2001 From: Alexander Gorodnikov Date: Fri, 26 Dec 2025 14:27:43 +0300 Subject: [PATCH 5/5] Small fixes --- .github/workflows/release-and-publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-and-publish.yml b/.github/workflows/release-and-publish.yml index 32b567c..470818e 100644 --- a/.github/workflows/release-and-publish.yml +++ b/.github/workflows/release-and-publish.yml @@ -10,7 +10,7 @@ on: jobs: release: # This condition ensures the job only runs for merge commits from a release branch - if: startsWith(github.event.head_commit.message, 'Merge pull request') && contains(github.event.head_commit.message, '/release/') + if: startsWith(github.event.pull_request.title, 'Prepare release of Kotlin AutoMapper') runs-on: ubuntu-latest permissions: contents: write @@ -25,7 +25,7 @@ jobs: id: get_version run: | COMMIT_MSG="${{ github.event.head_commit.message }}" - VERSION=$(echo "$COMMIT_MSG" | sed -n 's/.*\/release\/\([0-9.]*\).*/\1/p') + VERSION=$(echo "$COMMIT_MSG" | sed 's/Prepare release of Kotlin AutoMapper //') echo "version=$VERSION" >> $GITHUB_OUTPUT - name: Create and push Git Tag