Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
145 changes: 133 additions & 12 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ on:
SIGNING_KEY:
required: true
SIGNING_KEY_PASSWORD:
required: true
required: true
workflow_dispatch:

jobs:
publish:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/v')
steps:
- name: Checkout code
uses: actions/checkout@v6
Expand All @@ -29,41 +28,163 @@ jobs:
java-version: '21'
distribution: 'temurin'

- name: Publish
- name: Build
run: ./gradlew assemble

# only publish main & release/* builds to maven central
- name: Publish to Maven Central
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/')
run: ./gradlew publishToMavenCentral
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.SIGNING_KEY_PASSWORD }}

- name: Upload jars
uses: actions/upload-artifact@v7
with:
name: jars
path: transact*/build/libs/*.jar

# GraalVM Native Image cannot cross-compile, so each platform's binary is
# built on its own native runner.
#
# windows-arm64 is intentionally absent: GraalVM ships no windows-aarch64
# Native Image distribution, so native-image cannot run there (even though
# GitHub now offers windows-11-arm runners). Windows-on-ARM runs the
# windows-x64 binary via the OS's built-in x64 emulation.
#
# Native images are built on every run and uploaded as build artifacts; the
# `release` job only attaches them to a GitHub Release for release builds.
build-native:
strategy:
fail-fast: false
matrix:
include:
- { os: ubuntu-latest, platform: linux-x64, ext: '' }
- { os: ubuntu-24.04-arm, platform: linux-arm64, ext: '' }
- { os: macos-latest, platform: macos-arm64, ext: '' }
- { os: macos-15-intel, platform: macos-x64, ext: '' }
- { os: windows-latest, platform: windows-x64, ext: '.exe' }
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0 # fetch-depth 0 needed for version calculation

- name: Set up GraalVM
uses: graalvm/setup-graalvm@v1
with:
java-version: '21'
distribution: 'graalvm-community'

- name: Build native image
# auto-download=false forces Gradle to use the GraalVM installed above
# rather than re-provisioning a toolchain via the foojay resolver.
run: ./gradlew :transact-cli:nativeCompile -Porg.gradle.java.installations.auto-download=false
shell: bash
env:
# Windows-only: native-image puts its scratch dir under the system
# temp on C:, but the workspace is on D:. The build relativizes one
# against the other, which throws "'other' has different root" since
# NIO can't relativize across drives. Pinning temp to RUNNER_TEMP
# (also on D:) keeps both paths on the same drive. No-op elsewhere.
# See https://github.com/oracle/graal/issues/11795
TMP: ${{ runner.temp }}
TEMP: ${{ runner.temp }}

- name: Package binary
shell: bash
run: |
mkdir -p staged
cd transact-cli/build/native/nativeCompile
if [ -n "${{ matrix.ext }}" ]; then
7z a "$GITHUB_WORKSPACE/staged/dbos-${{ matrix.platform }}.zip" "dbos${{ matrix.ext }}"
else
tar czf "$GITHUB_WORKSPACE/staged/dbos-${{ matrix.platform }}.tar.gz" dbos
fi

- name: Upload binary
uses: actions/upload-artifact@v7
with:
name: dbos-${{ matrix.platform }}
path: staged/*

release:
needs: [publish, build-native]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/heads/release/')
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0 # fetch-depth 0 needed for version calculation

- name: Set up OpenJDK 21
uses: actions/setup-java@v5
with:
java-version: '21'
distribution: 'temurin'

- name: Get Gradle project version
id: get_version
run: |
VERSION=$(./gradlew properties -q | grep '^version:' | awk '{print $2}')
COMMIT_COUNT=$(./gradlew properties -q | grep '^commitCount:' | awk '{print $2}')
TAGS=$(git tag --points-at HEAD)

echo "Project version: $VERSION, commit Count: $COMMIT_COUNT, tags: $TAGS"
echo "Project version: $VERSION, tags: $TAGS"

if [ -z "$TAGS" ]; then
echo "is_tagged=false" >> $GITHUB_OUTPUT
else
echo "is_tagged=true" >> $GITHUB_OUTPUT
fi

# A final release is bare semver (X.Y.Z); any suffix (-rc, -m, -a) is a prerelease.
if echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "prerelease=false" >> $GITHUB_OUTPUT
else
echo "prerelease=true" >> $GITHUB_OUTPUT
fi
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "commit_count=$COMMIT_COUNT" >> $GITHUB_OUTPUT

- name: Download jars
uses: actions/download-artifact@v7
with:
name: jars
path: jars

- name: Download native binaries
uses: actions/download-artifact@v7
with:
path: native
pattern: dbos-*
merge-multiple: true

- name: Stage release assets
id: stage
run: |
VERSION="${{ steps.get_version.outputs.version }}"
mkdir -p release-assets
# Include the fat CLI jar (dbos.jar) and every other module's jars,
# but exclude the thin transact-cli library jar (transact-cli-*.jar).
find jars -name '*.jar' ! -name 'transact-cli-*.jar' -exec cp {} release-assets/ \;
for f in native/dbos-*; do
base=$(basename "$f") # e.g. dbos-linux-x64.tar.gz
rest=${base#dbos-} # e.g. linux-x64.tar.gz
cp "$f" "release-assets/dbos-${VERSION}-${rest}"
done
ls -la release-assets

- name: Github Release
if: |
startsWith(github.ref, 'refs/heads/release/v') &&
steps.get_version.outputs.is_tagged == 'true'
if: steps.get_version.outputs.is_tagged == 'true'
uses: softprops/action-gh-release@v2.1.0
with:
name: ${{ steps.get_version.outputs.version }}
tag_name: ${{ steps.get_version.outputs.version }}
target_commitish: ${{ github.sha }}
prerelease: ${{ steps.get_version.outputs.commit_count != '0' }}
prerelease: ${{ steps.get_version.outputs.prerelease }}
files: |
transact*/build/libs/*.jar

release-assets/*
2 changes: 1 addition & 1 deletion build-logic/src/main/kotlin/dev/dbos/build/GitVersion.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ object GitVersion {

return when {
branch == "main" -> "$major.${minor + 1}.$patch-m$commitCount"
branch.startsWith("release/v") ->
branch.startsWith("release/") ->
if (commitCount == 0) "$major.$minor.$patch" else "$major.$minor.${patch + 1}-rc$commitCount"
else -> "$major.${minor + 1}.$patch-a$commitCount-g${gitHash(root)}"
}
Expand Down
3 changes: 3 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
aspectj = "1.9.25.1"
assertj = "3.27.7"
cron-utils = "9.2.1"
graalvm-native = "0.11.1"
hibernate = "7.4.1.Final"
hikaricp = "7.1.0"
jackson = "3.2.0"
Expand Down Expand Up @@ -60,6 +61,7 @@ logback-classic = { module = "ch.qos.logback:logback-classic", version.ref = "lo
maven-artifact = { module = "org.apache.maven:maven-artifact", version.ref = "maven-artifact" }
mockito-core = { module = "org.mockito:mockito-core", version.ref = "mockito" }
picocli = { module = "info.picocli:picocli", version.ref = "picocli" }
picocli-codegen = { module = "info.picocli:picocli-codegen", version.ref = "picocli" }
postgresql = { module = "org.postgresql:postgresql", version.ref = "postgresql" }
rest-assured = { module = "io.rest-assured:rest-assured", version.ref = "rest-assured" }
slf4j-api = { module = "org.slf4j:slf4j-api", version.ref = "slf4j" }
Expand All @@ -82,6 +84,7 @@ testcontainers-postgresql = { module = "org.testcontainers:testcontainers-postgr
testcontainers-toxiproxy = { module = "org.testcontainers:testcontainers-toxiproxy", version.ref = "testcontainers" }

[plugins]
graalvm-native = { id = "org.graalvm.buildtools.native", version.ref = "graalvm-native" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
maven-publish = { id = "com.vanniktech.maven.publish", version.ref = "maven-publish" }
shadow = { id = "com.gradleup.shadow", version.ref = "shadow" }
Expand Down
Loading