From aaadef9b1aeecb80c41e02b47d62e98b1c8a5381 Mon Sep 17 00:00:00 2001 From: Mikhail Belyaev Date: Mon, 27 Jan 2020 18:28:09 +0300 Subject: [PATCH] Github actions && m && up the kotlin version --- .github/bintray-settings.xml | 12 +++++ .github/workflows/deployment.yml | 53 +++++++++++++++++++ .github/workflows/integration.yml | 17 ++++++ pom.xml | 12 ++--- .../ru/spbstu/ktuples/Tuples.kt.template | 14 +++++ 5 files changed, 99 insertions(+), 9 deletions(-) create mode 100644 .github/bintray-settings.xml create mode 100644 .github/workflows/deployment.yml create mode 100644 .github/workflows/integration.yml diff --git a/.github/bintray-settings.xml b/.github/bintray-settings.xml new file mode 100644 index 0000000..85f42df --- /dev/null +++ b/.github/bintray-settings.xml @@ -0,0 +1,12 @@ + + + + + bintray-vorpal-research-kotlin-maven + ${env.BINTRAY_USERNAME} + ${env.BINTRAY_PASSWORD} + + + diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml new file mode 100644 index 0000000..3b4aea5 --- /dev/null +++ b/.github/workflows/deployment.yml @@ -0,0 +1,53 @@ +name: Java CD + +on: + release: + types: published + +jobs: + publish: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - name: Set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Deploy to Bintray + id: deploy-to-bintray + run: | + mvn versions:set -DnewVersion=${{ github.event.release.tag_name }} + mvn deploy -s .github/bintray-settings.xml || echo "deploy failed" >&2 + env: + BINTRAY_USERNAME: ${{ secrets.bintray_username }} + BINTRAY_PASSWORD: ${{ secrets.bintray_password }} + + - name: Move sources jar file + run: mv target/*-sources.jar sources.jar + + - name: Move target jar file + run: mv target/*.jar target.jar + + - name: Attach source jar to release + id: upload-source-asset + uses: actions/upload-release-asset@v1.0.1 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: sources.jar + asset_name: ${{ github.event.repository.name }}-${{ github.event.release.tag_name }}-sources.jar + asset_content_type: application/zip + + - name: Attach target jar to release + id: upload-release-asset + uses: actions/upload-release-asset@v1.0.1 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: target.jar + asset_name: ${{ github.event.repository.name }}-${{ github.event.release.tag_name }}.jar + asset_content_type: application/zip \ No newline at end of file diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml new file mode 100644 index 0000000..a02111a --- /dev/null +++ b/.github/workflows/integration.yml @@ -0,0 +1,17 @@ +name: Java CI + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v1 + - name: Set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + - name: Build with Maven + run: mvn -B package diff --git a/pom.xml b/pom.xml index e479d78..211813f 100644 --- a/pom.xml +++ b/pom.xml @@ -6,11 +6,11 @@ ru.spbstu ktuples - 0.0.1.10-SNAPSHOT + 0.0.1.12-SNAPSHOT 1.8 - 1.3.41 + 1.3.61 UTF-8 @@ -23,16 +23,10 @@ org.jetbrains.kotlin - kotlin-test + kotlin-test-junit ${kotlin.version} test - - junit - junit - 4.12 - test - org.codehaus.groovy diff --git a/src/main/resources/kotlin/ru/spbstu/ktuples/Tuples.kt.template b/src/main/resources/kotlin/ru/spbstu/ktuples/Tuples.kt.template index 329a841..490bf2e 100644 --- a/src/main/resources/kotlin/ru/spbstu/ktuples/Tuples.kt.template +++ b/src/main/resources/kotlin/ru/spbstu/ktuples/Tuples.kt.template @@ -184,6 +184,20 @@ fun Pair.toTuple(): Tuple2 = Tuple(first, second) fun Triple.toTuple(): Tuple3 = Tuple(first, second, third) fun Map.Entry.toTuple(): Tuple2 = Tuple(key, value) +fun Tuple2.toPair() = Pair(v0, v1) +fun Tuple3.toTriple() = Triple(v0, v1, v2) + +fun > Iterable>.toMap(m: M): M = + forEach { (k, v) -> m.set(k, v) }.let { m } +fun Collection>.toMap(): Map = when { + this.isEmpty() -> emptyMap() + else -> toMap(LinkedHashMap(size)) +} +fun Iterable>.toMap(): Map = when { + this is Collection<*> -> (this as Collection>).toMap() + else -> toMap(mutableMapOf()) +} + inline fun Tuple0.toTypedArray() = arrayOf() inline fun Tuple0.letAll(f: () -> R) = f()