A composite Github Action to execute the Kotlin Script with compiler plugin and dependency caching!

Overview

Kotlin Script Github Action

Kotlin Script Test

Kotlin can also be used as a scripting language, which is more safer, concise, and fun to write than bash or python. Github has recently enabled Kotlin on Github Action runners, which enables us to use Kotlin Script on Github Action out of the box. But using compiler plugins ( eg: kotlinx-serialization) is not straightforward with Kotlin script and requires a bit of fiddling. kts-exec is a composite Github Action to execute the Kotlin Script (on mac/linux /windows) with a given kotlin compiler plugin and dependency caching.

Inputs

script

Required The Kotlin script to execute. Default script name is script.main.kts.

compiler-plugin

Optional Kotlin compiler plugin to use. Currently supported values are,

  • kotlinx-serialization (Default)
  • allopen
  • noarg
  • lombok
  • sam-with-receiver

Usage

Say, you want to execute the kotlin script with a Serializable data class for JSON processing

script.main.kts
@file:DependsOn("org.jetbrains.kotlinx:kotlinx-serialization-json:1.2.2")

import kotlinx.serialization.*
import kotlinx.serialization.json.*

@Serializable
data class Lang(val name: String, val version: String)

val arg = args.firstOrNull() ?: "Kotlin"
println("Hello $arg!")

val serialized = Json.encodeToString(Lang("Kotlin", KotlinVersion.CURRENT.toString()))
println(serialized)

Add the kt-exec to your workflow and run your kotlin script.

jobs:
  build:
    runs-on: ubuntu-lastest
    steps:
      - name: Check out repository
        uses: actions/checkout@v2

      - name: Run Kotlin Script
        uses: sureshg/[email protected]
        with:
          script: "script.main.kts"
You might also like...
Playground project for Koin Koin Compiler - Sandbox

Koin Compiler - Sandbox The goal of Koin compiler & Annotations project is to help declare Koin definition in a very fast and intuitive way, and gener

This repository is part of a Uni-Project to write a complete Compiler for a subset of Java.

Compiler This repository is part of a Uni-Project to write a complete Compiler for a subset of Java. Features error recovery using context sensitive a

A Open GAL compiler based on OpenGAL 0.3.1

A Open GAL compiler based on OpenGAL 0.3.1

A CLI tool to convert multi-module Jetpack Compose compiler metrics into beautiful HTML reports
A CLI tool to convert multi-module Jetpack Compose compiler metrics into beautiful HTML reports

A CLI tool to convert multi-module Jetpack Compose compiler metrics into beautiful HTML reports 1. What are Jetpack Compose compiler metrics? The Comp

Godot's AdMob Plugin for Android (3.2.2+) using GitHub Actions for CI/CD. Working on Standard and Mono Godot versions.
Godot's AdMob Plugin for Android (3.2.2+) using GitHub Actions for CI/CD. Working on Standard and Mono Godot versions.

Godot AdMob Android A Godot's plugin for Android of AdMob. About • Installation • Docs • Downloads About This repository is for a Godot Engine Plugin

The Action helps you to send a message to a queue on a RabbitMQ running Server

Rabbit Sender Action This Action helps you to send a message to a queue on a RabbitMQ running Server. Inputs Arg Default Description RABBIT_USERNAME g

Dependency Injection library for Kotlin Multiplatform, support iOS and Android

Multiplatform-DI library for Kotlin Multiplatform Lightweight dependency injection framework for Kotlin Multiplatform application Dependency injection

Lightweight Kotlin DSL dependency injection library
Lightweight Kotlin DSL dependency injection library

Warehouse DSL Warehouse is a lightweight Kotlin DSL dependency injection library this library has an extremely faster learning curve and more human fr

Built with Jetpack compose, multi modules MVVM clean architecture, coroutines + flow, dependency injection, jetpack navigation and other jetpack components

RickAndMortyCompose - Work in progress A simple app using Jetpack compose, clean architecture, multi modules, coroutines + flows, dependency injection

Comments
Releases(v2.6)
  • v2.6(Oct 14, 2022)

  • v2.5(Oct 14, 2022)

  • v2.4(Mar 24, 2022)

    What's Changed

    • chore(deps): bump actions/checkout from 2 to 3 by @dependabot in https://github.com/sureshg/kts-exec/pull/1
    • chore(deps): bump actions/cache from 2 to 3 by @dependabot in https://github.com/sureshg/kts-exec/pull/2

    New Contributors

    • @dependabot made their first contribution in https://github.com/sureshg/kts-exec/pull/1

    Full Changelog: https://github.com/sureshg/kts-exec/compare/v2.3...v2.4

    Source code(tar.gz)
    Source code(zip)
  • v2.3(Nov 12, 2021)

    • Enabled kotlin script dependencies caching (cache) configuration.

    Full Changelog: https://github.com/sureshg/kts-exec/compare/v2.2...v2.3

    Source code(tar.gz)
    Source code(zip)
  • v2.2(Sep 23, 2021)

  • v2.1(Sep 15, 2021)

  • v2(Sep 14, 2021)

Owner
Suresh
☕️ Java, Kotlin Developer.
Suresh
Lightweight compiler plugin intended for Kotlin/JVM library development and symbol visibility control.

Restrikt A Kotlin/JVM compiler plugin to restrict symbols access, from external project sources. This plugin offers two ways to hide symbols: An autom

Lorris Creantor 18 Nov 24, 2022
A Kotlin compiler plugin that allows Java callers to pass in null for default parameters

kotlin-null-defaults (Compiler plugin) (Gradle Plugin) ( Currently pending approval) A Kotlin compiler plugin that allows Java callers to pass in null

Youssef Shoaib 7 Oct 14, 2022
🍭 GithubSearchKMM - Github Repos Search - Android - iOS - Kotlin Multiplatform Mobile using Jetpack Compose, SwiftUI, FlowRedux, Coroutines Flow, Dagger Hilt, Koin Dependency Injection, shared KMP ViewModel, Clean Architecture

GithubSearchKMM Github Repos Search - Kotlin Multiplatform Mobile using Jetpack Compose, SwiftUI, FlowRedux, Coroutines Flow, Dagger Hilt, Koin Depend

Petrus Nguyễn Thái Học 50 Jan 7, 2023
A simple example of kotlim compiler plugin with FIR and IR.

A simple Kotlin compiler plugin example This Kotlin compiler plugin generates a top level class: public final class foo.bar.MyClass { fun foo(): S

Anastasiia Birillo 10 Dec 2, 2022
A Kotlin Script which Auto-Create And Assign Gitlab MergeRequests

A Kotlin Script which create merge request automatically and assign it to a developer for review based on a startegy(Currently Queue).

Hamidreza Sahraei 6 Jun 7, 2022
Run shell commands from a Kotlin script or application with ease

Run shell commands from a Kotlin script or application with ease. Turtle simplifies the process of running external commands and processes from your K

Andrew Lord 187 Jan 9, 2023
Very simple Kotlin caching library

Very simple Kotlin caching library

Ji Sungbin 4 Jun 15, 2022
Lightweight data loading and caching library for android

ColdStorage A lightweight data loading and caching library for android Quicklinks Feature requests: Got a new requirement? Request it here and it will

Cryptic Minds 41 Oct 17, 2022
An experimental tool for building console UI in Kotlin using the Jetpack Compose compiler/runtime

An experimental tool for building console UI in Kotlin using the Jetpack Compose compiler/runtime

Jake Wharton 1.4k Dec 28, 2022
Build a compiler in Kotlin (based on the original tutorial by Jack Crenshaw)

Let's Build a Compiler Based on the original series "Let’s Build a Compiler!" by Jack Crenshaw. This is an adaptation of the original series to Kotlin

null 2 Oct 9, 2022