Skip to content

Commit 0cd050d

Browse files
authored
Merge pull request #22 from CitrineInformatics/labday/github-packages
Labday Github Action / Github Packages
2 parents 980d109 + 4b07a90 commit 0cd050d

File tree

2 files changed

+47
-2
lines changed

2 files changed

+47
-2
lines changed

.github/workflows/ci.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main # Change to your default branch if different
7+
pull_request:
8+
9+
env:
10+
JAVA_OPTS: "-Xmx4G -XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled"
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Build Docker image
20+
run: docker build -t ecos-java-scala .
21+
22+
- name: Run tests
23+
run: docker run --rm ecos-java-scala:latest sbt -Dsbt.log.noformat=true +test
24+
25+
- name: Publish to Github Repositories
26+
if: github.event_name == 'push' && github.ref == 'refs/heads/${{ github.event.repository.default_branch }}'
27+
env:
28+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
GITHUB_ACTOR: ${{ github.actor }}
30+
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

build.sbt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Dependencies._
22

33
ThisBuild / scalaVersion := "2.13.15"
4-
ThisBuild / version := "0.0.10"
4+
ThisBuild / version := "0.0.11"
55
ThisBuild / versionScheme := Some("early-semver")
66
ThisBuild / organization := "io.citrine"
77
ThisBuild / organizationName := "Citrine Informatics"
@@ -11,6 +11,21 @@ ThisBuild / artifactClassifier := Some(osNameClassifier + "_" + osArchitecture)
1111
lazy val osNameClassifier = System.getProperty("os.name").replace(' ', '_').trim
1212
lazy val osArchitecture = System.getProperty("os.arch").replace(' ', '_').trim
1313

14+
ThisBuild / credentials += Credentials(
15+
"GitHub Package Registry",
16+
"maven.pkg.github.com",
17+
sys.env.getOrElse("GITHUB_ACTOR", ""),
18+
sys.env.getOrElse("GITHUB_TOKEN", "")
19+
)
20+
21+
lazy val githubRepository = "GitHub Package Registry" at s"https://maven.pkg.github.com/CitrineInformatics/ecos-java-scala"
22+
lazy val nexusRepository = "Citrine Nexus" at "https://nexus.corp.citrine.io/repository/citrine/"
23+
24+
lazy val publishTarget = sys.env.get("PUBLISH_TO_GITHUB") match {
25+
case Some("true") => Some(githubRepository)
26+
case _ => Some(nexusRepository)
27+
}
28+
1429
lazy val commonSettings = Seq(
1530
javah / target := sourceDirectory.value / "native" / "include",
1631
crossPaths := true,
@@ -19,7 +34,7 @@ lazy val commonSettings = Seq(
1934
if (isSnapshot.value) {
2035
None
2136
} else {
22-
Some("Citrine Nexus" at "https://nexus.corp.citrine.io/repository/citrine/")
37+
publishTarget
2338
}
2439
},
2540
publishConfiguration := publishConfiguration.value.withOverwrite(true)

0 commit comments

Comments
 (0)