Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/ktor upd #1

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 0 additions & 52 deletions .github/workflows/build-linux-x64.yml

This file was deleted.

50 changes: 50 additions & 0 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Build and Release

on:
workflow_dispatch:
inputs:
version:
required: true
type: string
description: Set the version for the release in the format v1.0.0

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
discussions: write

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build linuxX64 and linuxArm64 artifacts
env:
DOCKER_CLI_EXPERIMENTAL: enabled
run: |
docker buildx build --platform linux/amd64,linux/arm64 -f Dockerfile --output type=local,dest=./build_output .

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: kexe-artifacts
path: |
build_output/KTSynologyDDNSCloudflareMultidomainLinuxX64.kexe
build_output/KTSynologyDDNSCloudflareMultidomainLinuxArm64.kexe

- name: Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.event.inputs.version }}
files: |
build_output/KTSynologyDDNSCloudflareMultidomainLinuxX64.kexe
build_output/KTSynologyDDNSCloudflareMultidomainLinuxArm64.kexe
generate_release_notes: true
make_latest: true
28 changes: 28 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Build

on:
pull_request:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
discussions: write

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build linuxX64 and linuxArm64 artifacts
env:
DOCKER_CLI_EXPERIMENTAL: enabled
run: |
docker buildx build --platform linux/amd64,linux/arm64 -f Dockerfile --output type=local,dest=./build_output .
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Use a base image with Gradle 8.4 and JDK 21
FROM gradle:8.4-jdk21 as builder

# Set the working directory inside the container
WORKDIR /workspace

# Copy the entire project into the working directory
COPY . .

# Ensure that gradlew has execute permissions
RUN chmod +x ./gradlew

# Install any additional dependencies needed for the build (e.g., libcurl)
RUN apt-get update && apt-get install -y libcurl4-openssl-dev

# Create output directory for artifacts
RUN mkdir -p /workspace/build_output

# Build for linux64 and rename the artifact
RUN ./gradlew build -PtargetPlatform=linuxX64 && \
mv build/bin/native/releaseExecutable/KTSynologyDDNSCloudflareMultidomain.kexe /workspace/build_output/KTSynologyDDNSCloudflareMultidomainLinuxX64.kexe

# Build for linuxArm64 and rename the artifact
RUN ./gradlew build -PtargetPlatform=linuxArm64 && \
mv build/bin/native/releaseExecutable/KTSynologyDDNSCloudflareMultidomain.kexe /workspace/build_output/KTSynologyDDNSCloudflareMultidomainLinuxArm64.kexe
22 changes: 14 additions & 8 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,20 @@ repositories {
kotlin {
val hostOs = System.getProperty("os.name")
val isArm64 = System.getProperty("os.arch") == "aarch64"
val isMingwX64 = hostOs.startsWith("Windows")
val nativeTarget = when {
hostOs == "Mac OS X" && isArm64 -> macosArm64("native")
hostOs == "Mac OS X" && !isArm64 -> macosX64("native")
hostOs == "Linux" && isArm64 -> linuxArm64("native")
hostOs == "Linux" && !isArm64 -> linuxX64("native")
isMingwX64 -> mingwX64("native")
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")

val targetPlatform: String? = project.findProperty("targetPlatform") as? String

val nativeTarget = when (targetPlatform ?: "") {
"macosArm64" -> macosArm64("native")
"linuxArm64" -> linuxArm64("native")
"linuxX64" -> linuxX64("native")
"" -> when {
hostOs == "Mac OS X" && isArm64 -> macosArm64("native")
hostOs == "Linux" && isArm64 -> linuxArm64("native")
hostOs == "Linux" && !isArm64 -> linuxX64("native")
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
}
else -> throw GradleException("Unsupported target platform: $targetPlatform")
}

nativeTarget.apply {
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[versions]
kotlin = "2.0.20"
ktor = "3.0.0-rc-1"
ktor = "3.0.0"
serialization = "1.6.3"

[libraries]
Expand Down
Loading