diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e5004e8 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,30 @@ +name: CI + +on: + push: + branches: + - main # Change to your default branch if different + pull_request: + +env: + JAVA_OPTS: "-Xmx4G -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled" + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Build Docker image + run: docker build -t ecos-java-scala . + + - name: Run tests + run: docker run --rm ecos-java-scala:latest sbt -Dsbt.log.noformat=true +test + + - name: Publish to Github Repositories + if: github.event_name == 'push' && github.ref == 'refs/heads/${{ github.event.repository.default_branch }}' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_ACTOR: ${{ github.actor }} + run: docker run --rm -e GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} -e GITHUB_ACTOR=${{ github.actor }} -e PUBLISH_TO_GITHUB=true ecos-java-scala:latest sbt -Dsbt.log.noformat=true +publish \ No newline at end of file diff --git a/build.sbt b/build.sbt index 5301299..6728408 100644 --- a/build.sbt +++ b/build.sbt @@ -1,7 +1,7 @@ import Dependencies._ ThisBuild / scalaVersion := "2.13.15" -ThisBuild / version := "0.0.10" +ThisBuild / version := "0.0.11" ThisBuild / versionScheme := Some("early-semver") ThisBuild / organization := "io.citrine" ThisBuild / organizationName := "Citrine Informatics" @@ -11,6 +11,21 @@ ThisBuild / artifactClassifier := Some(osNameClassifier + "_" + osArchitecture) lazy val osNameClassifier = System.getProperty("os.name").replace(' ', '_').trim lazy val osArchitecture = System.getProperty("os.arch").replace(' ', '_').trim +ThisBuild / credentials += Credentials( + "GitHub Package Registry", + "maven.pkg.github.com", + sys.env.getOrElse("GITHUB_ACTOR", ""), + sys.env.getOrElse("GITHUB_TOKEN", "") +) + +lazy val githubRepository = "GitHub Package Registry" at s"https://maven.pkg.github.com/CitrineInformatics/ecos-java-scala" +lazy val nexusRepository = "Citrine Nexus" at "https://nexus.corp.citrine.io/repository/citrine/" + +lazy val publishTarget = sys.env.get("PUBLISH_TO_GITHUB") match { + case Some("true") => Some(githubRepository) + case _ => Some(nexusRepository) +} + lazy val commonSettings = Seq( javah / target := sourceDirectory.value / "native" / "include", crossPaths := true, @@ -19,7 +34,7 @@ lazy val commonSettings = Seq( if (isSnapshot.value) { None } else { - Some("Citrine Nexus" at "https://nexus.corp.citrine.io/repository/citrine/") + publishTarget } }, publishConfiguration := publishConfiguration.value.withOverwrite(true)