Skip to content

Commit

Permalink
334 - publish artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
regis-leray committed Oct 9, 2024
1 parent 1dbb5c1 commit c89da1c
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 93 deletions.
88 changes: 36 additions & 52 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ on:
tags: [v*]

env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
Expand All @@ -27,101 +23,89 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
scala: [3.3.3, 2.13.11, 2.12.18]
java: [graal_22.3.2@17]
scala: [3.3.4]
java: [graal_graalvm@21]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup GraalVM (graal_22.3.2@17)
if: matrix.java == 'graal_22.3.2@17'
- name: Setup GraalVM (graal_graalvm@21)
if: matrix.java == 'graal_graalvm@21'
uses: graalvm/setup-graalvm@v1
with:
version: 22.3.2
java-version: 17
java-version: 21
distribution: graalvm
components: native-image
github-token: ${{ secrets.GITHUB_TOKEN }}
cache: sbt

- name: Start containers
run: |
chmod -R 777 ./ftp-home/
docker compose -f "docker-compose.yml" up -d --build
chmod -R 777 ./ftp-home/sftp/home/foo/dir1
- name: Setup sbt
uses: sbt/setup-sbt@v1

- name: Check that workflows are up to date
run: sbt '++ ${{ matrix.scala }}' githubWorkflowCheck

- run: sbt '++ ${{ matrix.scala }}' check test
- run: sbt '++ ${{ matrix.scala }}' check

- name: Compress target directories
run: tar cf targets.tar target project/target

- name: Upload target directories
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: target-${{ matrix.os }}-${{ matrix.scala }}-${{ matrix.java }}
path: targets.tar

publish:
name: Publish Artifacts
needs: [build]
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/heads/master') || startsWith(github.ref, 'refs/tags/v'))
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/heads/master') || startsWith(github.ref, 'refs/heads/334') || startsWith(github.ref, 'refs/tags/v'))
strategy:
matrix:
os: [ubuntu-latest]
scala: [3.3.3]
java: [graal_22.3.2@17]
scala: [3.3.4]
java: [graal_graalvm@21]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup GraalVM (graal_22.3.2@17)
if: matrix.java == 'graal_22.3.2@17'
- name: Setup GraalVM (graal_graalvm@21)
if: matrix.java == 'graal_graalvm@21'
uses: graalvm/setup-graalvm@v1
with:
version: 22.3.2
java-version: 17
java-version: 21
distribution: graalvm
components: native-image
github-token: ${{ secrets.GITHUB_TOKEN }}
cache: sbt

- name: Download target directories (3.3.3)
uses: actions/download-artifact@v3
with:
name: target-${{ matrix.os }}-3.3.3-${{ matrix.java }}
- name: Setup sbt
uses: sbt/setup-sbt@v1

- name: Inflate target directories (3.3.3)
run: |
tar xf targets.tar
rm targets.tar
- name: Download target directories (2.13.11)
uses: actions/download-artifact@v3
- name: Download target directories (3.3.4)
uses: actions/download-artifact@v4
with:
name: target-${{ matrix.os }}-2.13.11-${{ matrix.java }}
name: target-${{ matrix.os }}-3.3.4-${{ matrix.java }}

- name: Inflate target directories (2.13.11)
- name: Inflate target directories (3.3.4)
run: |
tar xf targets.tar
rm targets.tar
- name: Download target directories (2.12.18)
uses: actions/download-artifact@v3
with:
name: target-${{ matrix.os }}-2.12.18-${{ matrix.java }}

- name: Inflate target directories (2.12.18)
run: |
tar xf targets.tar
rm targets.tar
- uses: olafurpg/setup-gpg@v3

- run: sbt ci-release
- env:
gpg_private_key: ${{ secrets.PGP_SECRET }}
run: echo "$gpg_private_key" | base64 --decode | gpg --batch --import

- name: Publish project
env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
run: sbt ci-release
3 changes: 2 additions & 1 deletion .github/workflows/clean.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Delete artifacts
shell: bash {0}
run: |
# Customize those three lines with your repository and credentials:
REPO=${GITHUB_API_URL}/repos/${{ github.repository }}
Expand All @@ -25,7 +26,7 @@ jobs:
ghapi() { curl --silent --location --user _:$GITHUB_TOKEN "$@"; }
# A temporary file which receives HTTP response headers.
TMPFILE=/tmp/tmp.$$
TMPFILE=$(mktemp)
# An associative array, key: artifact name, value: number of artifacts of that name.
declare -A ARTCOUNT
Expand Down
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,13 +185,18 @@ pub rsa4096 2018-08-22 [SC]
uid [ultimate] your name <[email protected]>
sub rsa4096 2018-08-22 [E]
$>LONG_ID=1234517530FB96F147C6A146A326F592D39AAAAA
#send key to server
$> gpg --keyserver keyserver.ubuntu.com --send-keys $LONG_ID
$> gpg --keyserver hkp://keyserver.ubuntu.com --send-key $LONG_ID && \
gpg --keyserver hkp://pgp.mit.edu --send-key $LONG_ID && \
gpg --keyserver hkp://pool.sks-keyservers.net --send-key $LONG_ID
# declare in travis (settings) PGP_SECRET in base64 (with no return carriage), dont put "" around the value !
# declare in github / repo / settings / secrets (new ewpository secret) PGP_SECRET in base64 (with no return carriage), dont put "" around the value !
gpg --armor --export-secret-keys $LONG_ID | base64 -w0 | pbcopy
# declare in travis (settings) PGP_PASSPHRASE in plain text
# declare in github (settings) PGP_PASSPHRASE in plain text
The randomly generated password you used to create a fresh gpg key
```

Expand Down
81 changes: 47 additions & 34 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
lazy val scala212 = "2.12.18"
lazy val scala213 = "2.13.11"
lazy val scala330 = "3.3.3"
lazy val scala212 = "2.12.20"
lazy val scala213 = "2.13.15"
lazy val scala330 = "3.3.4"

val fs2Version = "3.8.0"
val fs2Version = "3.11.0"

inThisBuild(
List(
Expand All @@ -16,41 +16,54 @@ inThisBuild(
)
)
ThisBuild / scalaVersion := scala330
ThisBuild / crossScalaVersions := List(scala330, scala213, scala212)
ThisBuild / githubWorkflowJavaVersions := Seq(JavaSpec.graalvm("22.3.2", "17"))
//ThisBuild / crossScalaVersions := List(scala330, scala213, scala212)
ThisBuild / githubWorkflowJavaVersions := Seq(JavaSpec.graalvm(Graalvm.Distribution("graalvm"), "21"))
ThisBuild / versionScheme := Some("early-semver")

ThisBuild / githubWorkflowBuildPreamble ++= Seq(
WorkflowStep.Run(
List(
"chmod -R 777 ./ftp-home/",
"docker compose -f \"docker-compose.yml\" up -d --build",
"chmod -R 777 ./ftp-home/sftp/home/foo/dir1"
),
name = Some("Start containers")
)
)
ThisBuild / githubWorkflowBuild := Seq(
WorkflowStep.Sbt(List("check", "test"))
)
ThisBuild / sonatypeCredentialHost := "oss.sonatype.org"

//sbt-ci-release settings
ThisBuild / githubWorkflowPublishPreamble := Seq(
WorkflowStep.Use(UseRef.Public("olafurpg", "setup-gpg", "v3"))
//ThisBuild / githubWorkflowBuildPreamble ++= Seq(
// WorkflowStep.Run(
// List(
// "chmod -R 777 ./ftp-home/",
// "docker compose -f \"docker-compose.yml\" up -d --build",
// "chmod -R 777 ./ftp-home/sftp/home/foo/dir1"
// ),
// name = Some("Start containers")
// )
//)

ThisBuild / githubWorkflowBuild := Seq(
WorkflowStep.Sbt(List("check")) //, "test"))
)

ThisBuild / githubWorkflowTargetTags ++= Seq("v*")
ThisBuild / githubWorkflowPublishTargetBranches := Seq(
RefPredicate.StartsWith(Ref.Branch("master")),
RefPredicate.StartsWith(Ref.Branch("334")),
RefPredicate.StartsWith(Ref.Tag("v"))
)
ThisBuild / githubWorkflowPublish := Seq(WorkflowStep.Sbt(List("ci-release")))
ThisBuild / githubWorkflowEnv ++= List(
"PGP_PASSPHRASE",
"PGP_SECRET",
"SONATYPE_PASSWORD",
"SONATYPE_USERNAME"
).map(envKey => envKey -> s"$${{ secrets.$envKey }}").toMap

//sbt-ci-release settings
ThisBuild / githubWorkflowPublishPreamble := Seq(
WorkflowStep.Run(
List("echo \"$gpg_private_key\" | base64 --decode | gpg --batch --import"),
env = Map("gpg_private_key" -> "${{ secrets.PGP_SECRET }}")
)
)

ThisBuild / githubWorkflowPublish := Seq(
WorkflowStep.Sbt(
commands = List("ci-release"),
name = Some("Publish project"),
env = Map(
"PGP_PASSPHRASE" -> "${{ secrets.PGP_PASSPHRASE }}",
"PGP_SECRET" -> "${{ secrets.PGP_SECRET }}",
"SONATYPE_PASSWORD" -> "${{ secrets.SONATYPE_PASSWORD }}",
"SONATYPE_USERNAME" -> "${{ secrets.SONATYPE_USERNAME }}"
)
)
)

lazy val `fs2-ftp` = project
.in(file("."))
Expand Down Expand Up @@ -80,13 +93,13 @@ lazy val `fs2-ftp` = project
libraryDependencies ++= Seq(
"co.fs2" %% "fs2-core" % fs2Version,
"co.fs2" %% "fs2-io" % fs2Version,
"org.scala-lang.modules" %% "scala-collection-compat" % "2.11.0",
"org.scala-lang.modules" %% "scala-collection-compat" % "2.12.0",
"com.hierynomus" % "sshj" % "0.39.0",
"commons-net" % "commons-net" % "3.11.1",
"org.apache.logging.log4j" % "log4j-api" % "2.20.0" % Test,
"org.apache.logging.log4j" % "log4j-core" % "2.20.0" % Test,
"org.apache.logging.log4j" % "log4j-slf4j-impl" % "2.20.0" % Test,
"org.scalatest" %% "scalatest" % "3.2.15" % Test
"org.apache.logging.log4j" % "log4j-api" % "2.23.1" % Test,
"org.apache.logging.log4j" % "log4j-core" % "2.23.1" % Test,
"org.apache.logging.log4j" % "log4j-slf4j-impl" % "2.23.1" % Test,
"org.scalatest" %% "scalatest" % "3.2.19" % Test
)
)

Expand Down
6 changes: 3 additions & 3 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.9.3")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.2.1")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.10")
addSbtPlugin("com.github.sbt" % "sbt-github-actions" % "0.15.0")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.7.0")
addSbtPlugin("com.github.sbt" % "sbt-github-actions" % "0.24.0")

0 comments on commit c89da1c

Please sign in to comment.