Skip to content

Commit

Permalink
fix missing binaries release (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
rolang authored Apr 30, 2024
1 parent ec4659a commit 261a831
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 28 deletions.
19 changes: 17 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,13 @@ jobs:
SCALANATIVE_MODE: release-fast
run: sbt buildCliBinary

- name: Upload command line binaries
if: matrix.project == 'rootNative' && (matrix.scala == '3') && github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')
uses: actions/upload-artifact@v4
with:
name: cli-bin-${{ matrix.os }}
path: modules/cli/native/target/bin/*

- name: Run example (covers reading resources from a jar)
if: matrix.project == 'rootJVM'
run: sbt 'project ${{ matrix.project }}' '++ ${{ matrix.scala }}' example/run
Expand Down Expand Up @@ -276,11 +283,19 @@ jobs:
SONATYPE_CREDENTIAL_HOST: ${{ secrets.SONATYPE_CREDENTIAL_HOST }}
run: sbt tlCiRelease

- name: Download command line binaries
if: startsWith(github.ref, 'refs/tags/')
uses: actions/download-artifact@v4
with:
pattern: cli-bin-*
path: target-cli/bin
merge-multiple: true

- name: Upload release binaries
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v1
with:
files: modules/cli/native/target/bin/*
files: target-cli/bin/*

- name: Release docker image
if: startsWith(github.ref, 'refs/tags/')
Expand All @@ -289,7 +304,7 @@ jobs:
run: |
echo -n "${DOCKER_PASSWORD}" | docker login docker.io -u rolang --password-stdin
export RELEASE_TAG=${GITHUB_REF_NAME#'v'}
cp -r modules/cli/native/target/bin docker-build/bin
cp -r target-cli/bin docker-build/bin
docker build ./docker-build -t rolang/dumbo:${RELEASE_TAG}-alpine
docker run rolang/dumbo:${RELEASE_TAG}-alpine
docker tag rolang/dumbo:${RELEASE_TAG}-alpine rolang/dumbo:latest-alpine
Expand Down
71 changes: 45 additions & 26 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ ThisBuild / semanticdbEnabled := true
ThisBuild / semanticdbVersion := scalafixSemanticdb.revision // use Scalafix compatible version

// githubWorkflow
ThisBuild / githubWorkflowOSes ++= Seq("macos-12", "macos-14")
ThisBuild / githubWorkflowBuildMatrixExclusions ++= Seq(
MatrixExclude(Map("os" -> "macos-12", "project" -> "rootJVM")),
MatrixExclude(Map("os" -> "macos-14", "project" -> "rootJVM")),
lazy val macOsArm = "macos-14"
lazy val macOsIntel = "macos-12"
lazy val macOses = Seq(macOsIntel, macOsArm)
ThisBuild / githubWorkflowOSes ++= Seq(macOsIntel, macOsArm)
ThisBuild / githubWorkflowBuildMatrixExclusions ++= macOses.map(os =>
MatrixExclude(Map("os" -> os, "project" -> "rootJVM"))
)
ThisBuild / githubWorkflowJavaVersions := Seq(JavaSpec.temurin("21"), JavaSpec.temurin("17"))
ThisBuild / tlCiHeaderCheck := true
Expand All @@ -46,8 +48,8 @@ ThisBuild / githubWorkflowBuildPreamble ++= Seq(
)
)
ThisBuild / githubWorkflowBuildPreamble ++= List(
"macos-12" -> "/usr/local/opt",
"macos-14" -> "/opt/homebrew/opt",
macOsIntel -> "/usr/local/opt",
macOsArm -> "/opt/homebrew/opt",
).map { case (os, llvmBase) =>
WorkflowStep.Run(
commands = List(
Expand Down Expand Up @@ -106,31 +108,48 @@ ThisBuild / githubWorkflowBuild ++= List(
)
}

ThisBuild / githubWorkflowPublish += WorkflowStep.Use(
ref = UseRef.Public("softprops", "action-gh-release", "v1"),
name = Some("Upload release binaries"),
params = Map(
"files" -> "modules/cli/native/target/bin/*"
ThisBuild / githubWorkflowBuild += WorkflowStep.Use(
ref = UseRef.Public("actions", "upload-artifact", "v4"),
params = Map("name" -> "cli-bin-${{ matrix.os }}", "path" -> "modules/cli/native/target/bin/*"),
name = Some("Upload command line binaries"),
cond = Some(
"matrix.project == 'rootNative' && (matrix.scala == '3') && github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main')"
),
cond = Some("startsWith(github.ref, 'refs/tags/')"),
)

ThisBuild / githubWorkflowPublish += WorkflowStep.Run(
name = Some("Release docker image"),
commands = List(
"""echo -n "${DOCKER_PASSWORD}" | docker login docker.io -u rolang --password-stdin""",
"export RELEASE_TAG=${GITHUB_REF_NAME#'v'}",
"cp -r modules/cli/native/target/bin docker-build/bin",
"docker build ./docker-build -t rolang/dumbo:${RELEASE_TAG}-alpine",
"docker run rolang/dumbo:${RELEASE_TAG}-alpine", // run for health-checking the docker image
"docker tag rolang/dumbo:${RELEASE_TAG}-alpine rolang/dumbo:latest-alpine",
"docker push rolang/dumbo:${RELEASE_TAG}-alpine",
"docker push rolang/dumbo:latest-alpine",
// publish binaries and docker image
ThisBuild / githubWorkflowPublish ++= Seq(
WorkflowStep.Use(
ref = UseRef.Public("actions", "download-artifact", "v4"),
params = Map("pattern" -> "cli-bin-*", "path" -> "target-cli/bin", "merge-multiple" -> "true"),
name = Some("Download command line binaries"),
cond = Some("startsWith(github.ref, 'refs/tags/')"),
),
env = Map(
"DOCKER_PASSWORD" -> "${{ secrets.DOCKER_PASSWORD }}"
WorkflowStep.Use(
ref = UseRef.Public("softprops", "action-gh-release", "v1"),
name = Some("Upload release binaries"),
params = Map(
"files" -> "target-cli/bin/*"
),
cond = Some("startsWith(github.ref, 'refs/tags/')"),
),
WorkflowStep.Run(
name = Some("Release docker image"),
commands = List(
"""echo -n "${DOCKER_PASSWORD}" | docker login docker.io -u rolang --password-stdin""",
"export RELEASE_TAG=${GITHUB_REF_NAME#'v'}",
"cp -r target-cli/bin docker-build/bin",
"docker build ./docker-build -t rolang/dumbo:${RELEASE_TAG}-alpine",
"docker run rolang/dumbo:${RELEASE_TAG}-alpine", // run for health-checking the docker image
"docker tag rolang/dumbo:${RELEASE_TAG}-alpine rolang/dumbo:latest-alpine",
"docker push rolang/dumbo:${RELEASE_TAG}-alpine",
"docker push rolang/dumbo:latest-alpine",
),
env = Map(
"DOCKER_PASSWORD" -> "${{ secrets.DOCKER_PASSWORD }}"
),
cond = Some("startsWith(github.ref, 'refs/tags/')"),
),
cond = Some("startsWith(github.ref, 'refs/tags/')"),
)

ThisBuild / githubWorkflowBuild += WorkflowStep.Sbt(
Expand Down

0 comments on commit 261a831

Please sign in to comment.