Skip to content

Commit

Permalink
Merge pull request #116 from codacy/feat/sbt-native-packager-and-comp…
Browse files Browse the repository at this point in the history
…ress

feat: Add sbt-native-packager to build native image and UPX to compress
  • Loading branch information
josemiguelmelo authored Mar 13, 2020
2 parents 0ef0708 + 19c9776 commit d9d142e
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 142 deletions.
56 changes: 44 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: 2.1

orbs:
codacy: codacy/base@2.1.1
codacy: codacy/base@2.7.0
references:
circleci_job: &circleci_job
docker:
Expand Down Expand Up @@ -48,6 +48,22 @@ jobs:
name: Publish final orb
command: circleci orb publish orb.yml codacy/plugins-test@$(cat .version) --token $CIRCLE_TOKEN

compress_and_package_artifacts:
docker:
- image: hairyhenderson/upx:3.94
working_directory: ~/workdir
steps:
- run: apk add ca-certificates
- attach_workspace:
at: ~/workdir
- run: |
mkdir -p ~/workdir/artifacts/
upx --lzma -o ~/workdir/artifacts/$CIRCLE_PROJECT_REPONAME-linux-$(cat .version) ~/workdir/target/graalvm-native-image/$CIRCLE_PROJECT_REPONAME
- persist_to_workspace:
root: ~/workdir
paths:
- "*"

workflows:
version: 2
build-and-deploy:
Expand Down Expand Up @@ -77,25 +93,41 @@ workflows:
- populate_cache
- codacy/sbt:
name: build_native_image
cmd: sbt graalvm-native-image:packageBin
persist_to_workspace: true
requires:
- compile_and_test
- compress_and_package_artifacts:
requires:
- build_native_image
- codacy/shell:
name: publish_bintray
cmd: |
./scripts/build-native.sh -n $CIRCLE_PROJECT_REPONAME -m codacy.plugins.DockerTest -t docker $(cat .version)
curl -T ~/workdir/$CIRCLE_PROJECT_REPONAME-linux-$(cat .version) -ucodacy-ci:$BINTRAY_API_KEY -H "X-Bintray-Package:$CIRCLE_PROJECT_REPONAME" -H "X-Bintray-Version:$(cat .version)" https://api.bintray.com/content/codacy/Binaries/$(cat .version)/$CIRCLE_PROJECT_REPONAME-linux
curl -X POST -ucodacy-ci:$BINTRAY_API_KEY https://api.bintray.com/content/codacy/Binaries/$CIRCLE_PROJECT_REPONAME/$(cat .version)/publish
GHR_FLAGS=""
if [ "$CIRCLE_BRANCH" != "master" ]; then
GHR_FLAGS+="-prerelease"
fi
mkdir -p /tmp/ghr-publish
cp ~/workdir/$CIRCLE_PROJECT_REPONAME-linux-$(cat .version) /tmp/ghr-publish
go get github.com/tcnksm/ghr
ghr -t $GITHUB_TOKEN -u $CIRCLE_PROJECT_USERNAME -r $CIRCLE_PROJECT_REPONAME -c $CIRCLE_SHA1 $GHR_FLAGS -delete $(cat .version) /tmp/ghr-publish
filters:
branches:
only:
- master
context: CodacyBintray
requires:
- compile_and_test
- compress_and_package_artifacts
- codacy/publish_ghr:
name: publish_ghr
path: ~/workdir/artifacts/
context: CodacyGitHub
filters:
branches:
only:
- master
requires:
- compress_and_package_artifacts
- codacy/tag_version:
name: tag_version
context: CodacyAWS
requires:
- build_native_image
- publish_ghr
- publish_bintray
- publish_dev:
context: CodacyCircleCI
requires:
Expand Down
14 changes: 14 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,17 @@ libraryDependencies ++= Seq("com.codacy" %% "codacy-analysis-core" % "2.1.0",
"com.lihaoyi" %% "pprint" % "0.5.7",
"org.wvlet.airframe" %% "airframe-log" % "19.12.4",
codacy.libs.scalatest)

enablePlugins(GraalVMNativeImagePlugin)
graalVMNativeImageGraalVersion := Some("20.0.0-java8")
graalVMNativeImageOptions := Seq("--enable-http",
"--enable-https",
"--enable-url-protocols=http,https,file,jar",
"--enable-all-security-services",
"-H:+JNI",
"--static",
"-H:IncludeResourceBundles=com.sun.org.apache.xerces.internal.impl.msg.XMLMessages",
"-H:+ReportExceptionStackTraces",
"--no-fallback",
"--initialize-at-build-time",
"--report-unsupported-elements-at-runtime")
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.3.5
sbt.version=1.3.8
3 changes: 2 additions & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
resolvers += Resolver.jcenterRepo
addSbtPlugin("com.codacy" % "codacy-sbt-plugin" % "17.1.5")
addSbtPlugin("com.codacy" % "codacy-sbt-plugin" % "18.0.3")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.6.1")
128 changes: 0 additions & 128 deletions scripts/build-native.sh

This file was deleted.

0 comments on commit d9d142e

Please sign in to comment.