Skip to content
Merged
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
63 changes: 63 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: main

on:
push:
branches:
- 'main'
tags:
- '*'
pull_request:
branches:
- 'main'
types: [opened, synchronize]

jobs:
main:
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: lint
# Run ./gradlew spotlessApply when failing on this step.
run: ./gradlew spotlessCheck
- run: ./gradlew test
- name: Show Current Version
run: ./gradlew printVersion
- name: Build Gem & Put it into './build/gems/' Directory
run: ./gradlew gem

- name: Set up JRuby
uses: ruby/setup-ruby@v1
with:
ruby-version: jruby

- name: Publish to GPR
if: startsWith( github.ref, 'refs/tags/' )
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} ./build/gems/*.gem
env:
GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
OWNER: ${{ github.repository_owner }}

- name: Publish to RubyGems
if: startsWith( github.ref, 'refs/tags/' )
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
# TODO: If it is possible to accept input in the middle of a step, then the OTP Token should be inputted instead of generated.
gem install rotp -v 6.2.0
OTP_TOKEN=$(echo ${OTP_SECRET} | ruby -rtime -rrotp -e "puts ROTP::TOTP.new(STDIN.read.chomp, issuer: 'rubygems.org').at(Time.now)")
gem push --otp="${OTP_TOKEN}" ./build/gems/*.gem
env:
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_API_KEY}}"
OTP_SECRET: "${{secrets.RUBYGEMS_OTP_SECRET}}"
128 changes: 51 additions & 77 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,98 +1,72 @@
plugins {
id "com.jfrog.bintray" version "1.1"
id "com.github.jruby-gradle.base" version "1.5.0"
id "java"
id "checkstyle"
id "maven-publish"
id "org.embulk.embulk-plugins" version "0.4.2"
id "com.diffplug.spotless" version "5.15.0"
id "com.palantir.git-version" version "0.12.3"
}
import com.github.jrubygradle.JRubyExec
repositories {
mavenCentral()
jcenter()
}
configurations {
provided
}

version = "0.1.0"
group = "io.trocco"
description = "An embulk output plugin to egest records as json via http/https."
version = {
def vd = versionDetails()
if (vd.commitDistance == 0 && vd.lastTag ==~ /^[0-9]+\.[0-9]+\.[0-9]+(\.[a-zA-Z0-9]+)?/) {
vd.lastTag
} else {
"0.0.0.${vd.gitHash}"
}
}()

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
compile "org.embulk:embulk-core:0.9.23"
provided "org.embulk:embulk-core:0.9.23"
// compile "YOUR_JAR_DEPENDENCY_GROUP:YOUR_JAR_DEPENDENCY_MODULE:YOUR_JAR_DEPENDENCY_VERSION"
testCompile "junit:junit:4.+"
}
def embulkVersion = "0.10.33"
compileOnly "org.embulk:embulk-api:${embulkVersion}"
compileOnly "org.embulk:embulk-spi:${embulkVersion}"

task classpath(type: Copy, dependsOn: ["jar"]) {
doFirst { file("classpath").deleteDir() }
from (configurations.runtime - configurations.provided + files(jar.archivePath))
into "classpath"
}
clean { delete "classpath" }
compile "org.embulk:embulk-util-config:0.3.0"
compile "org.embulk:embulk-util-json:0.1.1"
compile "javax.validation:validation-api:1.1.0.Final"
compile 'org.apache.bval:bval-jsr303:0.5'

checkstyle {
configFile = file("${project.rootDir}/config/checkstyle/checkstyle.xml")
toolVersion = '6.14.1'
}
checkstyleMain {
configFile = file("${project.rootDir}/config/checkstyle/default.xml")
ignoreFailures = true
}
checkstyleTest {
configFile = file("${project.rootDir}/config/checkstyle/default.xml")
ignoreFailures = true
}
task checkstyle(type: Checkstyle) {
classpath = sourceSets.main.output + sourceSets.test.output
source = sourceSets.main.allJava + sourceSets.test.allJava
testImplementation "junit:junit:4.+"
testImplementation "org.embulk:embulk-core:${embulkVersion}"
testImplementation "org.embulk:embulk-deps:${embulkVersion}"
}

task gem(type: JRubyExec, dependsOn: ["gemspec", "classpath"]) {
jrubyArgs "-S"
script "gem"
scriptArgs "build", "${project.name}.gemspec"
doLast { ant.move(file: "${project.name}-${project.version}.gem", todir: "pkg") }
embulkPlugin {
mainClass = "org.embulk.output.http_json.HttpJsonOutputPlugin"
category = "output"
type = "http_json"
}

task gemPush(type: JRubyExec, dependsOn: ["gem"]) {
jrubyArgs "-S"
script "gem"
scriptArgs "push", "pkg/${project.name}-${project.version}.gem"
}

task "package"(dependsOn: ["gemspec", "classpath"]) {
doLast {
println "> Build succeeded."
println "> You can run embulk with '-L ${file(".").absolutePath}' argument."
publishing {
publications {
embulkPluginMaven(MavenPublication) {
from components.java
}
}
repositories {
maven {
url = "${project.buildDir}/mavenPublishLocal"
}
}
}

task gemspec {
ext.gemspecFile = file("${project.name}.gemspec")
inputs.file "build.gradle"
outputs.file gemspecFile
doLast { gemspecFile.write($/
Gem::Specification.new do |spec|
spec.name = "${project.name}"
spec.version = "${project.version}"
spec.authors = ["civitaspo"]
spec.summary = %[Http Json output plugin for Embulk]
spec.description = %[Dumps records to Http Json.]
spec.email = ["civitaspo@gmail.com"]
spec.licenses = ["MIT"]
# TODO set this: spec.homepage = "https://github.com/civitaspo/embulk-output-http_json"

spec.files = `git ls-files`.split("\n") + Dir["classpath/*.jar"]
spec.test_files = spec.files.grep(%r"^(test|spec)/")
spec.require_paths = ["lib"]

#spec.add_dependency 'YOUR_GEM_DEPENDENCY', ['~> YOUR_GEM_DEPENDENCY_VERSION']
spec.add_development_dependency 'bundler', ['~> 1.0']
spec.add_development_dependency 'rake', ['~> 12.0']
end
/$)
gem {
from("LICENSE.txt")
authors = [ "Civitaspo" ]
email = [ "civitaspo@gmail.com" ]
summary = "An embulk output plugin to egest records as json via http/https."
homepage = "https://github.com/trocco-io/embulk-output-http_json"
licenses = [ "MIT" ]
}
spotless {
java {
importOrder()
removeUnusedImports()
googleJavaFormat().aosp()
}
}
clean { delete "${project.name}.gemspec" }
128 changes: 0 additions & 128 deletions config/checkstyle/checkstyle.xml

This file was deleted.

Loading