From f05316c4fb0677bdbbce7d2f3fb71185ed0864f6 Mon Sep 17 00:00:00 2001 From: Pablo Cavallo Date: Fri, 11 Apr 2025 20:03:29 +0200 Subject: [PATCH 1/7] Targeting github repositories --- build.sbt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 5301299..748e485 100644 --- a/build.sbt +++ b/build.sbt @@ -11,6 +11,15 @@ 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 commonSettings = Seq( javah / target := sourceDirectory.value / "native" / "include", crossPaths := true, @@ -19,7 +28,7 @@ lazy val commonSettings = Seq( if (isSnapshot.value) { None } else { - Some("Citrine Nexus" at "https://nexus.corp.citrine.io/repository/citrine/") + Some(githubRepository) } }, publishConfiguration := publishConfiguration.value.withOverwrite(true) From a19078c0ae36be0fc094f3582b44ef6af678e8b0 Mon Sep 17 00:00:00 2001 From: Pablo Cavallo Date: Mon, 6 Oct 2025 15:15:06 +0200 Subject: [PATCH 2/7] Add github workflow --- .github/workflows/ci.yml | 30 ++++++++++++++++++++++++++++++ build.sbt | 8 +++++++- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..d16bf5d --- /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/main' + 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 748e485..34b840d 100644 --- a/build.sbt +++ b/build.sbt @@ -19,6 +19,12 @@ ThisBuild / credentials += Credentials( ) 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", @@ -28,7 +34,7 @@ lazy val commonSettings = Seq( if (isSnapshot.value) { None } else { - Some(githubRepository) + Some(publishTarget) } }, publishConfiguration := publishConfiguration.value.withOverwrite(true) From 578cb1a0e1c388a908346ba151afad8640c43e27 Mon Sep 17 00:00:00 2001 From: Pablo Cavallo Date: Mon, 6 Oct 2025 18:26:47 +0200 Subject: [PATCH 3/7] Double wrap --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 34b840d..aaa0a2a 100644 --- a/build.sbt +++ b/build.sbt @@ -34,7 +34,7 @@ lazy val commonSettings = Seq( if (isSnapshot.value) { None } else { - Some(publishTarget) + publishTarget } }, publishConfiguration := publishConfiguration.value.withOverwrite(true) From 8c94ad05c7abb541cdebce40b85b6e98e136968c Mon Sep 17 00:00:00 2001 From: Pablo Cavallo Date: Mon, 6 Oct 2025 18:31:10 +0200 Subject: [PATCH 4/7] Don't hardcode the default branch --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d16bf5d..e5004e8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,7 @@ jobs: 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/main' + if: github.event_name == 'push' && github.ref == 'refs/heads/${{ github.event.repository.default_branch }}' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_ACTOR: ${{ github.actor }} From 4f4fd0f4b32ea62b117e3435508b2f3f1534429b Mon Sep 17 00:00:00 2001 From: Pablo Cavallo Date: Mon, 6 Oct 2025 18:33:10 +0200 Subject: [PATCH 5/7] Test publishing --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e5004e8..83168ed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,7 @@ jobs: 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 }}' + #if: github.event_name == 'push' && github.ref == 'refs/heads/${{ github.event.repository.default_branch }}' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_ACTOR: ${{ github.actor }} From 4e31ae113777d72da777c12813bf918b52ae2830 Mon Sep 17 00:00:00 2001 From: Pablo Cavallo Date: Mon, 6 Oct 2025 18:37:45 +0200 Subject: [PATCH 6/7] It works, putting conditional back --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 83168ed..e5004e8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,7 @@ jobs: 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 }}' + if: github.event_name == 'push' && github.ref == 'refs/heads/${{ github.event.repository.default_branch }}' env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_ACTOR: ${{ github.actor }} From 4b07a90fa4f476fcda30e3a70f17e0982dd8b431 Mon Sep 17 00:00:00 2001 From: Pablo Cavallo Date: Mon, 6 Oct 2025 18:39:17 +0200 Subject: [PATCH 7/7] Bumping version --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index aaa0a2a..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"