Skip to content

Commit

Permalink
Merge pull request ccellado#2 from ccellado/renew-kiosk
Browse files Browse the repository at this point in the history
Add ci
  • Loading branch information
ccellado authored Mar 7, 2024
2 parents 18271ab + 7619d87 commit 5af8721
Show file tree
Hide file tree
Showing 8 changed files with 149 additions and 12 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: CI

on:
push:
branches:
- master
pull_request:
types:
- opened
- synchronize

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
test_kiosk:
name: Run ergo-kiosk tests and publish a kiosk snapshot
env:
HAS_SECRETS: ${{ secrets.SONATYPE_PASSWORD != '' }}
strategy:
matrix:
os: [ubuntu-latest]
scala: [2.13.12]
java: [[email protected]]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup Java and Scala
uses: olafurpg/setup-scala@v10
with:
java-version: ${{ matrix.java }}

- name: Cache sbt
uses: actions/cache@v2
with:
path: |
~/.sbt
~/.ivy2/cache
~/.coursier/cache/v1
~/.cache/coursier/v1
~/AppData/Local/Coursier/Cache/v1
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Runs ergo-kiosk tests
run: sbt ++${{ matrix.scala }} test

- name: Publish a ergo-kiosk snapshot ${{ github.ref }}
if: env.HAS_SECRETS == 'true'
run: sbt ++${{ matrix.scala }} publish
env:
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
44 changes: 44 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Publish a release

on:
release:
types: [published]

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
publish_release:
name: Publish release to Sonatype
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Setup Java and Scala
uses: olafurpg/setup-scala@v10
with:
java-version: [email protected]

- name: Cache sbt
uses: actions/cache@v2
with:
path: |
~/.sbt
~/.ivy2/cache
~/.coursier/cache/v1
~/.cache/coursier/v1
~/AppData/Local/Coursier/Cache/v1
~/Library/Caches/Coursier/v1
key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }}

- name: Import GPG key
run: ci/import_gpg.sh
env:
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }}

- name: Publish ergo-kiosk
run: sbt +publishSigned sonatypeBundleRelease
env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
2 changes: 2 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
version = "3.8.0"
style = defaultWithAlign
maxColumn = 200
3 changes: 0 additions & 3 deletions .travis.yml

This file was deleted.

26 changes: 20 additions & 6 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
name := "Kiosk"

version := "0.1"

name := "kiosk"
version := "1.0"
updateOptions := updateOptions.value.withLatestSnapshots(false)

scalaVersion := "2.13.12"

libraryDependencies ++= Seq(
"org.scala-lang.modules" %% "scala-collection-compat" % "2.11.0",
// "org.bouncycastle" % "bcprov-jdk15on" % "1.70",
"org.ergoplatform" %% "ergo-appkit" % "5.0.4",
"com.squareup.okhttp3" % "mockwebserver" % "4.12.0" % Test,
"org.scalatest" %% "scalatest" % "3.2.18" % Test,
Expand All @@ -26,9 +23,26 @@ resolvers ++= Seq(
lazy val root = (project in file("."))
.settings(
updateOptions := updateOptions.value.withLatestSnapshots(false),
assemblyMergeStrategy in assembly := {
assembly / assemblyMergeStrategy := {
case PathList("reference.conf") => MergeStrategy.concat
case PathList("META-INF", xs @ _*) => MergeStrategy.discard
case x => MergeStrategy.first
}
)

/* PUBLISHING */
ThisBuild / publishMavenStyle := true
Test / publishArtifact := true

// PGP key for signing a release build published to sonatype
// signing is done by sbt-pgp plugin
// how to generate a key - https://central.sonatype.org/pages/working-with-pgp-signatures.html
pgpPublicRing := file("ci/pubring.asc")
pgpSecretRing := file("ci/secring.asc")
pgpPassphrase := sys.env.get("PGP_PASSPHRASE").map(_.toArray)
usePgpKeyHex("D78982639AD538EF361DEC6BF264D529385A0333")

// prefix version with "-SNAPSHOT" for builds without a git tag
ThisBuild / dynverSonatypeSnapshots := true
// use "-" instead of default "+"
ThisBuild / dynverSeparator := "-"
21 changes: 21 additions & 0 deletions ci/import_gpg.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
# setting up gpg2 for reading passphrase from parameters
# via https://github.com/beautiful-scala/scalastyle/blob/master/.github/workflows/release.yml#L16
# from https://github.com/olafurpg/sbt-ci-release/issues/95

# setup gpg
mkdir ~/.gnupg && chmod 700 ~/.gnupg
echo use-agent >> ~/.gnupg/gpg.conf
echo pinentry-mode loopback >> ~/.gnupg/gpg.conf
echo allow-loopback-pinentry >> ~/.gnupg/gpg-agent.conf
chmod 600 ~/.gnupg/*
echo RELOADAGENT | gpg-connect-agent

# decode key
# private key should be previously exported with:
# gpg --export-secret-keys [id] | base64 | pbcopy
# and stored as github repository secret under the following name (see env var name below)
printf "$GPG_SIGNING_KEY" | base64 --decode > ~/.gnupg/private.key

# import key
gpg --no-tty --batch --yes --import ~/.gnupg/private.key
6 changes: 5 additions & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.6")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "2.1.5")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.2.1")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.10.0")
addSbtPlugin("com.github.sbt" % "sbt-release" % "1.4.0")
addSbtPlugin("com.github.sbt" % "sbt-dynver" % "5.0.1")
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import org.ergoplatform.appkit.impl.NodeAndExplorerDataSourceImpl;
import org.ergoplatform.explorer.client.ExplorerApiClient;
import org.ergoplatform.restapi.client.ApiClient;
import org.scalatest.tags.Network;

import java.io.IOException;
import java.util.List;
import java.util.function.Function;
Expand Down

0 comments on commit 5af8721

Please sign in to comment.