Skip to content

Commit

Permalink
Merge pull request #78 from lucidsoftware/ci
Browse files Browse the repository at this point in the history
build: Add github actions
  • Loading branch information
tmccombs authored May 18, 2023
2 parents da42bf2 + 2bd27c3 commit c73bb48
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 9 deletions.
79 changes: 79 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: CI
on:
pull_request:
push:
branches:
- master
tags:
- "*.*"

env:
MYSQL_USER: root
MYSQL_PASSWORD: root

jobs:
build:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: '11'
distribution: corretto
- uses: actions/cache@v3
with:
path: |
~/.ivy2
~/.sbt
key: ${{ runner.os }}-sbt-${{ hashFiles('**/*.sbt') }}
- name: Start mysql
run: sudo /etc/init.d/mysql start
- name: Set SBT_OPTS
run: bash generate_sbt_opts.sh
- name: Build
run: sbt package
- name: Test
run: sbt test
- uses: actions/upload-artifact@v3
with:
name: jars
path: '*/target/**/*.jar'
retention-days: 1
publish:
if: ${{ github.event_name != 'pull_request' }} && (github.repository == 'lucidsoftware/java-thread-context') }}
needs: build
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
~/.ivy2
~/.sbt
key: ${{ runner.os }}-sbt-${{ hashFiles('**/*.sbt') }}
- name: Set SBT_OPTS
run: bash generate_sbt_opts.sh
- name: Publish to Sonatype
run: bash publish.sh
env:
PGP_SECRET: ${{ secrets.PGP_SECRET }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
release:
if: ${{ startsWith(github.ref, 'refs/tags') && (github.repository == 'lucidsoftware/relate') }}
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
name: jars
- name: Upload Assets
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -x
tag="${GITHUB_REF#refs/tags/}"
targets=($(printf -- "-a %s " */target/**/*.jar))
hub release create "${targets[@]}" -m "Release $tag" $tag
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Relate.sublime-project
Relate.sublime-workspace
.ensime
.history
.bsp
.idea*
lib_managed/*

Expand Down
12 changes: 6 additions & 6 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ lazy val `macros2.11` = macros("2.11.12")
lazy val `macros2.12` = macros("2.12.11")
lazy val `macros2.13` = macros("2.13.2")
lazy val macrosAggregate = macros.aggregate(`macros2.11`, `macros2.12`, `macros2.13`).settings(
skip in publish := true
publish / skip := true
)

lazy val relate = project.in(file("relate")).cross
lazy val `relate2.11` = relate("2.11.12")
lazy val `relate2.12` = relate("2.12.11")
lazy val `relate2.13` = relate("2.13.2")
lazy val relateAggregate = relate.aggregate(`relate2.11`, `relate2.12`, `relate2.13`).settings(
skip in publish := true
publish / skip := true
)

lazy val postgres = project.in(file("postgres")).cross.dependsOn(relate)
lazy val `postgres2.11` = postgres("2.11.12")
lazy val `postgres2.12` = postgres("2.12.11")
lazy val `postgres2.13` = postgres("2.13.2")
lazy val postgresAggregate = postgres.aggregate(`postgres2.11`, `postgres2.12`, `postgres2.13`).settings(
skip in publish := true
publish / skip := true
)

val benchmarkTag = Tags.Tag("benchmark")
Expand Down Expand Up @@ -49,9 +49,9 @@ inScope(Global)(Seq(
"-feature"
),
scmInfo := Some(ScmInfo(url("https://github.com/lucidsoftware/relate"), "scm:git:[email protected]:lucidsoftware/relate.git")),
tags in (Benchmark, test) += benchmarkTag -> 1,
tags in (Benchmark, testOnly) += benchmarkTag -> 1,
tags in (Benchmark, testQuick) += benchmarkTag -> 1,
Benchmark / test / tags += benchmarkTag -> 1,
Benchmark / testOnly / tags += benchmarkTag -> 1,
Benchmark / testQuick / tags += benchmarkTag -> 1,
version := sys.props.getOrElse("build.version", "0-SNAPSHOT")
))

Expand Down
7 changes: 7 additions & 0 deletions generate_sbt_opts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
if [[ $GITHUB_REF_TYPE = tag ]]; then
version="${GITHUB_REF_NAME}"
else
version="${GITHUB_HEAD_REF:-$GITHUB_REF_NAME}-SNAPSHOT"
fi
echo "SBT_OPTS=-Dbuild.version=$version" >> $GITHUB_ENV
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.3.3
sbt.version=1.8.2
4 changes: 2 additions & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
addSbtPlugin("com.lucidchart" % "sbt-cross" % "4.0")

addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.0")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.2.1")

addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.8")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.18")
12 changes: 12 additions & 0 deletions publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
set -e

echo "$PGP_SECRET" | base64 --decode | gpg --import
if [[ $GITHUB_REF == refs/tags/* ]]; then
command="; publishSigned; sonatypeBundleRelease"
else
command="publishSigned"
fi
echo "Running: sbt \"$command\""
exec sbt "$command"

0 comments on commit c73bb48

Please sign in to comment.