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
25 changes: 22 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ on:
push:
branches:
- develop
- master

jobs:
ci:

runs-on: macos-26

permissions:
contents: write # create the release tag

steps:
- name: Setup Gradle Repo
uses: Oztechan/Global/actions/setup-gradle-repo@8610938e630b3ed86127765237fe3647b9fabd4f
Expand All @@ -33,8 +35,8 @@ jobs:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: build/reports/kover/report.xml

# Publish only on a merge to develop/master, and only after the build above passes.
# develop -> X.Y-SNAPSHOT (unsigned), master -> X.Y.Z release (signed).
# develop is the release branch: every merge publishes an immutable, signed X.Y.Z to Maven
# Central, once the build above passes. Every other branch builds X.Y-SNAPSHOT and never publishes.
- name: Publish
if: github.event_name == 'push'
# Normalize the armored GPG key: literal "\n" -> real newlines (vanniktech's
Expand All @@ -48,6 +50,23 @@ jobs:
GPG_KEY_RAW: ${{ secrets.GPG_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.GPG_PASSWORD }}

# Read back from Gradle so the tag always matches the version just published to Maven Central.
- name: Resolve version
id: version
if: github.event_name == 'push'
run: echo "version=$(./gradlew -q printVersion | grep '^VERSION_NAME=' | cut -d= -f2)" >> $GITHUB_OUTPUT

# Tags the released commit and cuts the matching GitHub release. Done inline rather than from a
# tag-triggered workflow, because tags pushed with GITHUB_TOKEN never trigger other workflows —
# which is also why automatic_release_tag is set: with no tag ref the action has nothing to cut.
- name: PublishRelease
if: github.event_name == 'push'
uses: marvinpinto/action-automatic-releases@v1.2.1
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
prerelease: false
automatic_release_tag: v${{ steps.version.outputs.version }}

- name: Notify slack success
if: success() && github.event_name == 'push'
env:
Expand Down
16 changes: 0 additions & 16 deletions .github/workflows/publish.yml

This file was deleted.

7 changes: 7 additions & 0 deletions ParserMob.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,10 @@ allprojects {
}
}
}

// Resolved version, read by CI to tag the release. The VERSION_NAME= prefix keeps it parseable
// even when Gradle writes build-scan output to the same stream.
tasks.register("printVersion") {
val projectVersion = version.toString()
doLast { println("VERSION_NAME=$projectVersion") }
}
12 changes: 6 additions & 6 deletions buildSrc/src/main/kotlin/ProjectSettings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ object ProjectSettings {
private const val MAYOR_VERSION = 2
private const val MINOR_VERSION = 0

// git rev-list --first-parent --count master (recalibrated at the 2.0 major bump)
private const val VERSION_DIF = 27
// git rev-list --first-parent --count develop (recalibrated when releases moved off master)
private const val VERSION_DIF = 335

fun getVersionName(project: Project): String = if (isMaster(project)) {
// Permanent, pinnable release: x.y.<commit-count>.
fun getVersionName(project: Project): String = if (isReleaseBranch(project)) {
// Permanent, pinnable release: x.y.<commit-count>. Every merge to develop publishes one.
"$MAYOR_VERSION.$MINOR_VERSION.${gitCommitCount(project).toInt() - VERSION_DIF}"
} else {
// Stable moving snapshot ("latest develop")consumers pin x.y-SNAPSHOT and always get newest.
// Feature branches and local buildsnever published, so the moving snapshot is fine.
"$MAYOR_VERSION.$MINOR_VERSION-SNAPSHOT"
}

private fun isMaster(project: Project): Boolean = currentBranch(project) == "master"
private fun isReleaseBranch(project: Project): Boolean = currentBranch(project) == "develop"

private fun currentBranch(project: Project): String {
// In GitHub Actions the checked-out branch is exposed as GITHUB_REF_NAME; fall back to git locally.
Expand Down