Skip to content

Commit

Permalink
Add release automation workflow (#384)
Browse files Browse the repository at this point in the history
  • Loading branch information
xerial authored Jan 28, 2023
1 parent 34fa6e9 commit c515db5
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 38 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Release

on:
push:
tags:
- v*
workflow_dispatch:

jobs:
publish_jvm:
name: Publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 10000
# Fetch all tags so that sbt-dynver can find the previous release version
- run: git fetch --tags -f
# Install OpenJDK 11
- uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: '11'
- name: Setup GPG
env:
PGP_SECRET: ${{ secrets.PGP_SECRET }}
run: echo $PGP_SECRET | base64 --decode | gpg --import --batch --yes
- name: Build bundle
env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
run: |
./sbt publishSigned
- name: Release to Sonatype
env:
SONATYPE_USERNAME: '${{ secrets.SONATYPE_USER }}'
SONATYPE_PASSWORD: '${{ secrets.SONATYPE_PASS }}'
run: ./sbt sonatypeBundleRelease
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,10 @@ NATIVE_DIR:=src/main/resources/org/xerial/snappy/native/$(OS_NAME)/$(OS_ARCH)
NATIVE_TARGET_DIR:=$(TARGET)/classes/org/xerial/snappy/native/$(OS_NAME)/$(OS_ARCH)
NATIVE_DLL:=$(NATIVE_DIR)/$(LIBNAME)

snappy-jar-version:=snappy-java-$(shell cat version.sbt | cut -d'=' -f2 | sed 's/[ \"]//g')
snappy-jar-version:=snappy-java-$(shell ./script/dynver.sh | cut -d'=' -f2 | sed 's/[ \"]//g')

jar-version:
echo $(snappy-jar-version)

native: jni-header snappy-header $(NATIVE_DLL)
native-nocmake: jni-header $(NATIVE_DLL)
Expand Down
56 changes: 21 additions & 35 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Global / onChangedBuildSource := ReloadOnSourceChanges

name := "snappy-java"
organization := "org.xerial.snappy"
name := "snappy-java"
organization := "org.xerial.snappy"
organizationName := "xerial.org"
description := "snappy-java: A fast compression/decompression library"
description := "snappy-java: A fast compression/decompression library"

sonatypeProfileName := "org.xerial"
sonatypeProfileName := "org.xerial"
ThisBuild / publishTo := sonatypePublishToBundle.value
licenses := Seq("Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0.html"))
homepage := Some(url("https://github.com/xerial/snappy-java"))
licenses := Seq("Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0.html"))
homepage := Some(url("https://github.com/xerial/snappy-java"))
scmInfo := Some(
ScmInfo(
browseUrl = url("https://github.com/xerial/snappy-java"),
Expand All @@ -19,6 +19,11 @@ developers := List(
Developer(id = "leo", name = "Taro L. Saito", email = "[email protected]", url = url("http://xerial.org/leo"))
)

// Use dynamic snapshot version strings for non tagged versions
ThisBuild / dynverSonatypeSnapshots := true
// Use coursier friendly version separator
ThisBuild / dynverSeparator := "-"

ThisBuild / scalaVersion := "2.12.11"

// For building jars for JDK8
Expand Down Expand Up @@ -57,27 +62,27 @@ testOptions += Tests.Argument(TestFrameworks.JUnit, "-q", "-v")
Test / parallelExecution := false

autoScalaLibrary := false
crossPaths := false
crossPaths := false

libraryDependencies ++= Seq(
"junit" % "junit" % "4.13.2" % "test",
"org.codehaus.plexus" % "plexus-classworlds" % "2.7.0" % "test",
"org.xerial.java" % "xerial-core" % "2.1" % "test",
"junit" % "junit" % "4.13.2" % "test",
"org.codehaus.plexus" % "plexus-classworlds" % "2.7.0" % "test",
"org.xerial.java" % "xerial-core" % "2.1" % "test",
"org.wvlet.airframe" %% "airframe-log" % "22.12.6" % "test",
"org.osgi" % "org.osgi.core" % "4.3.0" % "provided",
"com.github.sbt" % "junit-interface" % "0.13.3" % "test",
"org.osgi" % "org.osgi.core" % "4.3.0" % "provided",
"com.github.sbt" % "junit-interface" % "0.13.3" % "test",
"org.apache.hadoop" % "hadoop-common" % "2.10.2" % "test" exclude ("org.xerial.snappy", "snappy-java")
)

enablePlugins(SbtOsgi)

osgiSettings

OsgiKeys.exportPackage := Seq("org.xerial.snappy", "org.xerial.snappy.buffer", "org.xerial.snappy.pool")
OsgiKeys.exportPackage := Seq("org.xerial.snappy", "org.xerial.snappy.buffer", "org.xerial.snappy.pool")
OsgiKeys.bundleSymbolicName := "org.xerial.snappy.snappy-java"
OsgiKeys.bundleActivator := Option("org.xerial.snappy.SnappyBundleActivator")
OsgiKeys.importPackage := Seq("""org.osgi.framework;version="[1.5,2)"""")
OsgiKeys.requireCapability := """osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.7))""""
OsgiKeys.bundleActivator := Option("org.xerial.snappy.SnappyBundleActivator")
OsgiKeys.importPackage := Seq("""org.osgi.framework;version="[1.5,2)"""")
OsgiKeys.requireCapability := """osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.7))""""

OsgiKeys.additionalHeaders := Map(
"Bundle-NativeCode" -> Seq(
Expand Down Expand Up @@ -108,22 +113,3 @@ OsgiKeys.additionalHeaders := Map(
"Bundle-ActivationPolicy" -> "lazy",
"Bundle-Name" -> "snappy-java: A fast compression/decompression library"
)

import ReleaseTransformations._

releaseTagName := { (ThisBuild / version).value }

releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
runClean,
runTest,
setReleaseVersion,
commitReleaseVersion,
tagRelease,
releaseStepCommand("publishSigned"),
releaseStepCommand("sonatypeBundleRelease"),
setNextVersion,
commitNextVersion,
pushChanges
)
1 change: 0 additions & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
addSbtPlugin("com.github.sbt" % "sbt-release" % "1.1.0")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.17")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.2.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.9.6")
Expand Down
1 change: 0 additions & 1 deletion version.sbt

This file was deleted.

0 comments on commit c515db5

Please sign in to comment.