Skip to content

Commit c515db5

Browse files
authored
Add release automation workflow (#384)
1 parent 34fa6e9 commit c515db5

File tree

5 files changed

+62
-38
lines changed

5 files changed

+62
-38
lines changed

.github/workflows/release.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- v*
7+
workflow_dispatch:
8+
9+
jobs:
10+
publish_jvm:
11+
name: Publish
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
with:
16+
fetch-depth: 10000
17+
# Fetch all tags so that sbt-dynver can find the previous release version
18+
- run: git fetch --tags -f
19+
# Install OpenJDK 11
20+
- uses: actions/setup-java@v3
21+
with:
22+
distribution: 'zulu'
23+
java-version: '11'
24+
- name: Setup GPG
25+
env:
26+
PGP_SECRET: ${{ secrets.PGP_SECRET }}
27+
run: echo $PGP_SECRET | base64 --decode | gpg --import --batch --yes
28+
- name: Build bundle
29+
env:
30+
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
31+
run: |
32+
./sbt publishSigned
33+
- name: Release to Sonatype
34+
env:
35+
SONATYPE_USERNAME: '${{ secrets.SONATYPE_USER }}'
36+
SONATYPE_PASSWORD: '${{ secrets.SONATYPE_PASS }}'
37+
run: ./sbt sonatypeBundleRelease

Makefile

+4-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,10 @@ NATIVE_DIR:=src/main/resources/org/xerial/snappy/native/$(OS_NAME)/$(OS_ARCH)
140140
NATIVE_TARGET_DIR:=$(TARGET)/classes/org/xerial/snappy/native/$(OS_NAME)/$(OS_ARCH)
141141
NATIVE_DLL:=$(NATIVE_DIR)/$(LIBNAME)
142142

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

145148
native: jni-header snappy-header $(NATIVE_DLL)
146149
native-nocmake: jni-header $(NATIVE_DLL)

build.sbt

+21-35
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
Global / onChangedBuildSource := ReloadOnSourceChanges
22

3-
name := "snappy-java"
4-
organization := "org.xerial.snappy"
3+
name := "snappy-java"
4+
organization := "org.xerial.snappy"
55
organizationName := "xerial.org"
6-
description := "snappy-java: A fast compression/decompression library"
6+
description := "snappy-java: A fast compression/decompression library"
77

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

22+
// Use dynamic snapshot version strings for non tagged versions
23+
ThisBuild / dynverSonatypeSnapshots := true
24+
// Use coursier friendly version separator
25+
ThisBuild / dynverSeparator := "-"
26+
2227
ThisBuild / scalaVersion := "2.12.11"
2328

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

5964
autoScalaLibrary := false
60-
crossPaths := false
65+
crossPaths := false
6166

6267
libraryDependencies ++= Seq(
63-
"junit" % "junit" % "4.13.2" % "test",
64-
"org.codehaus.plexus" % "plexus-classworlds" % "2.7.0" % "test",
65-
"org.xerial.java" % "xerial-core" % "2.1" % "test",
68+
"junit" % "junit" % "4.13.2" % "test",
69+
"org.codehaus.plexus" % "plexus-classworlds" % "2.7.0" % "test",
70+
"org.xerial.java" % "xerial-core" % "2.1" % "test",
6671
"org.wvlet.airframe" %% "airframe-log" % "22.12.6" % "test",
67-
"org.osgi" % "org.osgi.core" % "4.3.0" % "provided",
68-
"com.github.sbt" % "junit-interface" % "0.13.3" % "test",
72+
"org.osgi" % "org.osgi.core" % "4.3.0" % "provided",
73+
"com.github.sbt" % "junit-interface" % "0.13.3" % "test",
6974
"org.apache.hadoop" % "hadoop-common" % "2.10.2" % "test" exclude ("org.xerial.snappy", "snappy-java")
7075
)
7176

7277
enablePlugins(SbtOsgi)
7378

7479
osgiSettings
7580

76-
OsgiKeys.exportPackage := Seq("org.xerial.snappy", "org.xerial.snappy.buffer", "org.xerial.snappy.pool")
81+
OsgiKeys.exportPackage := Seq("org.xerial.snappy", "org.xerial.snappy.buffer", "org.xerial.snappy.pool")
7782
OsgiKeys.bundleSymbolicName := "org.xerial.snappy.snappy-java"
78-
OsgiKeys.bundleActivator := Option("org.xerial.snappy.SnappyBundleActivator")
79-
OsgiKeys.importPackage := Seq("""org.osgi.framework;version="[1.5,2)"""")
80-
OsgiKeys.requireCapability := """osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.7))""""
83+
OsgiKeys.bundleActivator := Option("org.xerial.snappy.SnappyBundleActivator")
84+
OsgiKeys.importPackage := Seq("""org.osgi.framework;version="[1.5,2)"""")
85+
OsgiKeys.requireCapability := """osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.7))""""
8186

8287
OsgiKeys.additionalHeaders := Map(
8388
"Bundle-NativeCode" -> Seq(
@@ -108,22 +113,3 @@ OsgiKeys.additionalHeaders := Map(
108113
"Bundle-ActivationPolicy" -> "lazy",
109114
"Bundle-Name" -> "snappy-java: A fast compression/decompression library"
110115
)
111-
112-
import ReleaseTransformations._
113-
114-
releaseTagName := { (ThisBuild / version).value }
115-
116-
releaseProcess := Seq[ReleaseStep](
117-
checkSnapshotDependencies,
118-
inquireVersions,
119-
runClean,
120-
runTest,
121-
setReleaseVersion,
122-
commitReleaseVersion,
123-
tagRelease,
124-
releaseStepCommand("publishSigned"),
125-
releaseStepCommand("sonatypeBundleRelease"),
126-
setNextVersion,
127-
commitNextVersion,
128-
pushChanges
129-
)

project/plugins.sbt

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
addSbtPlugin("com.github.sbt" % "sbt-release" % "1.1.0")
21
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.17")
32
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.2.1")
43
addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.9.6")

version.sbt

-1
This file was deleted.

0 commit comments

Comments
 (0)