Skip to content

Commit

Permalink
Github actions && m && up the kotlin version
Browse files Browse the repository at this point in the history
  • Loading branch information
belyaev-mikhail committed Jan 27, 2020
1 parent 3914b1a commit aaadef9
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 9 deletions.
12 changes: 12 additions & 0 deletions .github/bintray-settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>bintray-vorpal-research-kotlin-maven</id>
<username>${env.BINTRAY_USERNAME}</username>
<password>${env.BINTRAY_PASSWORD}</password>
</server>
</servers>
</settings>
53 changes: 53 additions & 0 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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/[email protected]
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
17 changes: 17 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -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
12 changes: 3 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

<groupId>ru.spbstu</groupId>
<artifactId>ktuples</artifactId>
<version>0.0.1.10-SNAPSHOT</version>
<version>0.0.1.12-SNAPSHOT</version>

<properties>
<java.version>1.8</java.version>
<kotlin.version>1.3.41</kotlin.version>
<kotlin.version>1.3.61</kotlin.version>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
Expand All @@ -23,16 +23,10 @@
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test</artifactId>
<artifactId>kotlin-test-junit</artifactId>
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.codehaus.groovy</groupId>
Expand Down
14 changes: 14 additions & 0 deletions src/main/resources/kotlin/ru/spbstu/ktuples/Tuples.kt.template
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,20 @@ fun<A, B> Pair<A, B>.toTuple(): Tuple2<A, B> = Tuple(first, second)
fun<A, B, C> Triple<A, B, C>.toTuple(): Tuple3<A, B, C> = Tuple(first, second, third)
fun<A, B> Map.Entry<A, B>.toTuple(): Tuple2<A, B> = Tuple(key, value)

fun <A, B> Tuple2<A, B>.toPair() = Pair(v0, v1)
fun <A, B, C> Tuple3<A, B, C>.toTriple() = Triple(v0, v1, v2)

fun <A, B, M: MutableMap<A, B>> Iterable<Tuple2<A, B>>.toMap(m: M): M =
forEach { (k, v) -> m.set(k, v) }.let { m }
fun <A, B> Collection<Tuple2<A, B>>.toMap(): Map<A, B> = when {
this.isEmpty() -> emptyMap()
else -> toMap(LinkedHashMap(size))
}
fun <A, B> Iterable<Tuple2<A, B>>.toMap(): Map<A, B> = when {
this is Collection<*> -> (this as Collection<Tuple2<A, B>>).toMap()
else -> toMap(mutableMapOf())
}

inline fun Tuple0.toTypedArray() = arrayOf<Any>()
inline fun<R> Tuple0.letAll(f: () -> R) = f()

Expand Down

0 comments on commit aaadef9

Please sign in to comment.