Skip to content

Commit ce157f8

Browse files
authored
Implement Automated GitFlow Release Workflow (#6)
* Implement Automated GitFlow Release Workflow 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.
1 parent 18276f0 commit ce157f8

8 files changed

Lines changed: 160 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# This workflow builds the project on every push and pull request to the main branch
2+
3+
name: AutoMapper CI
4+
5+
on:
6+
pull_request:
7+
branches: [ "main", "develop" ]
8+
9+
jobs:
10+
build:
11+
# Use the latest version of Ubuntu for the build environment
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
# Check out the repository code so the workflow can access it
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
# Set up JDK 21, which is required by the project
20+
- name: Set up JDK 21
21+
uses: actions/setup-java@v4
22+
with:
23+
java-version: '21'
24+
distribution: 'temurin'
25+
26+
# Cache Gradle packages and wrapper to speed up the build process
27+
- name: Cache Gradle packages
28+
uses: actions/cache@v4
29+
with:
30+
path: |
31+
~/.gradle/caches
32+
~/.gradle/wrapper
33+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
34+
restore-keys: |
35+
${{ runner.os }}-gradle-
36+
37+
# Grant execute permission to the Gradle wrapper script
38+
- name: Grant execute permission for gradlew
39+
run: chmod +x ./gradlew
40+
41+
# Run the main build task
42+
- name: Build with Gradle
43+
run: ./gradlew build
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# This workflow prepares a new release by creating a pull request from 'develop' to 'main'.
2+
3+
name: AutoMapper Prepare Release
4+
5+
on:
6+
workflow_dispatch:
7+
inputs:
8+
version:
9+
description: 'The version to release (e.g., 1.0.0)'
10+
required: true
11+
12+
jobs:
13+
prepare-release:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout develop branch
17+
uses: actions/checkout@v4
18+
with:
19+
ref: 'develop'
20+
21+
- name: Update version in build files and README
22+
run: |
23+
VERSION=${{ github.event.inputs.version }}
24+
# Update version in processor/build.gradle.kts
25+
sed -i "s/^version = \".*\"/version = \"$VERSION\"/" automapper/processor/build.gradle.kts
26+
# Update version in annotation/build.gradle.kts
27+
sed -i "s/^version = \".*\"/version = \"$VERSION\"/" automapper/annotation/build.gradle.kts
28+
# Update dependency versions in README.md
29+
sed -i 's/\(io\.github\.jacksever\.automapper:[^:]*:\)[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*/\1$VERSION/g' README.md
30+
31+
- name: Create Pull Request to main
32+
uses: peter-evans/create-pull-request@v6
33+
with:
34+
token: ${{ secrets.GITHUB_TOKEN }}
35+
commit-message: "Prepare release of Kotlin AutoMapper ${{ github.event.inputs.version }}"
36+
title: "Prepare release of Kotlin AutoMapper ${{ github.event.inputs.version }}"
37+
body: "This PR integrates changes from `develop` into `main` for the ${{ github.event.inputs.version }} release"
38+
branch: "release/${{ github.event.inputs.version }}"
39+
base: "main"
40+
reviewers: ${{ github.actor }}
41+
delete-branch: true
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# This workflow creates a tag, publishes to Maven Central, and creates a GitHub Release
2+
3+
name: AutoMapper Release and Publish
4+
5+
on:
6+
push:
7+
branches:
8+
- 'main' # Triggers on any push to main, including merges
9+
10+
jobs:
11+
release:
12+
# This condition ensures the job only runs for merge commits from a release branch
13+
if: startsWith(github.event.pull_request.title, 'Prepare release of Kotlin AutoMapper')
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: write
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Extract version from merge commit
25+
id: get_version
26+
run: |
27+
COMMIT_MSG="${{ github.event.head_commit.message }}"
28+
VERSION=$(echo "$COMMIT_MSG" | sed 's/Prepare release of Kotlin AutoMapper //')
29+
echo "version=$VERSION" >> $GITHUB_OUTPUT
30+
31+
- name: Create and push Git Tag
32+
run: |
33+
git config user.name "github-actions[bot]"
34+
git config user.email "github-actions[bot]@users.noreply.github.com"
35+
git tag "${{ steps.get_version.outputs.version }}"
36+
git push origin "${{ steps.get_version.outputs.version }}"
37+
38+
- name: Set up JDK 21
39+
uses: actions/setup-java@v4
40+
with:
41+
java-version: '21'
42+
distribution: 'temurin'
43+
44+
- name: Grant execute permission for gradlew
45+
run: chmod +x ./gradlew
46+
47+
# - name: Publish to Maven Central
48+
# run: ./gradlew publishAllPublicationsToMavenCentralRepository --no-daemon --no-parallel
49+
# env:
50+
# ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.OSSRH_USERNAME }}
51+
# ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.OSSRH_TOKEN }}
52+
# ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_SIGNING_KEY }}
53+
# ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_SIGNING_PASSWORD }}
54+
55+
- name: Create GitHub Release
56+
uses: ncipollo/release-action@v1
57+
with:
58+
tag: '${{ steps.get_version.outputs.version }}'
59+
name: '${{ steps.get_version.outputs.version }}'
60+
generateReleaseNotes: true

automapper/annotation/build.gradle.kts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,22 @@ kotlin {
1414
iosArm64()
1515
iosSimulatorArm64()
1616
js(IR) {
17+
nodejs()
1718
browser()
19+
binaries.executable()
1820
}
1921

2022
@OptIn(ExperimentalWasmDsl::class)
2123
wasmWasi {
2224
nodejs()
25+
binaries.executable()
2326
}
2427

2528
@OptIn(ExperimentalWasmDsl::class)
2629
wasmJs {
2730
nodejs()
31+
browser()
32+
binaries.executable()
2833
}
2934
}
3035

gradle.properties

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,9 @@ kotlin.code.style=official
2121
# resources declared in the library itself and none from the library's dependencies,
2222
# thereby reducing the size of the R class for that library
2323
android.nonTransitiveRClass=true
24+
25+
# Allows compiling Kotlin/Native code for Apple targets (e.g., iOS) on non-macOS hosts like Linux or Windows
26+
kotlin.native.enableKlibsCrossCompilation=true
27+
28+
# Enables Gradle's build cache
29+
org.gradle.caching=true

gradlew

100644100755
File mode changed.

sample/build.gradle.kts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,22 @@ kotlin {
1111
iosArm64()
1212
iosSimulatorArm64()
1313
js(IR) {
14+
nodejs()
1415
browser()
16+
binaries.executable()
1517
}
1618

1719
@OptIn(ExperimentalWasmDsl::class)
1820
wasmWasi {
1921
nodejs()
22+
binaries.executable()
2023
}
2124

2225
@OptIn(ExperimentalWasmDsl::class)
2326
wasmJs {
2427
nodejs()
28+
browser()
29+
binaries.executable()
2530
}
2631

2732
sourceSets {

settings.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ pluginManagement {
1313
}
1414

1515
dependencyResolutionManagement {
16-
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
1716
repositories {
1817
google {
1918
content {

0 commit comments

Comments
 (0)