Skip to content

Commit

Permalink
added new build actions
Browse files Browse the repository at this point in the history
  • Loading branch information
mrikirill committed Nov 5, 2024
1 parent e0cf13b commit 0e0bf6e
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 61 deletions.
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

0 comments on commit 0e0bf6e

Please sign in to comment.