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
10 changes: 6 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,12 @@ jobs:
permissions:
contents: read
packages: write
env:
# Publish the version the build job computed, not one recomputed from tags added since.
DBOS_VERSION_OVERRIDE: ${{ needs.build.outputs.version }}
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
Expand All @@ -96,11 +97,12 @@ jobs:
needs: [build]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/heads/release/') && needs.build.outputs.prerelease == 'false'
env:
# Publish the version the build job computed, not one recomputed from tags added since.
DBOS_VERSION_OVERRIDE: ${{ needs.build.outputs.version }}
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
Expand Down
8 changes: 7 additions & 1 deletion build-logic/src/main/kotlin/dev/dbos/build/GitVersion.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,14 @@ object GitVersion {
fun gitHash(root: File): String =
cachedHash ?: run(root, "git", "rev-parse", "--short", "HEAD").also { cachedHash = it }

/**
* The version from DBOS_VERSION_OVERRIDE when set, else derived from git. CI sets the override so
* every publish job uses the version the build job computed, even if a tag was added since.
*/
fun version(root: File): String =
cachedVersion ?: calcVersion(root).also { cachedVersion = it }
cachedVersion
?: (System.getenv("DBOS_VERSION_OVERRIDE")?.takeIf { it.isNotBlank() } ?: calcVersion(root))
.also { cachedVersion = it }

private fun gitTag(root: File): String? =
runCatching { run(root, "git", "describe", "--abbrev=0", "--tags") }.getOrNull()
Expand Down
Loading